Skip to content

Commit

Permalink
test make_supercell in_place=True and False
Browse files Browse the repository at this point in the history
  • Loading branch information
janosh committed Jul 31, 2023
1 parent 7197592 commit 638c095
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions pymatgen/core/tests/test_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1068,13 +1068,23 @@ def test_mul(self):
self.assert_all_close(struct.lattice.abc, [7.6803959, 17.5979979, 7.6803959])

def test_make_supercell(self):
self.struct.make_supercell([2, 1, 1])
assert self.struct.formula == "Si4"
self.struct.make_supercell([[1, 0, 0], [2, 1, 0], [0, 0, 1]])
assert self.struct.formula == "Si4"
self.struct.make_supercell(2)
assert self.struct.formula == "Si32"
self.assert_all_close(self.struct.lattice.abc, [15.360792, 35.195996, 7.680396], 5)
supercell = self.struct.make_supercell([2, 1, 1])
assert supercell.formula == "Si4"
# test that make_supercell modified the original structure
assert len(self.struct) == len(supercell)

supercell.make_supercell([[1, 0, 0], [2, 1, 0], [0, 0, 1]])
assert supercell.formula == "Si4"
supercell.make_supercell(2)
assert supercell.formula == "Si32"
self.assert_all_close(supercell.lattice.abc, [15.360792, 35.195996, 7.680396], 5)

# test in_place=False leaves original structure unchanged
orig_len = len(self.struct)
# test that make_supercell casts floats to ints
supercell = self.struct.make_supercell([2.5, 1, 1], in_place=False)
assert len(self.struct) == orig_len
assert len(supercell) == 2 * orig_len

def test_make_supercell_labeled(self):
struct = self.labeled_structure.copy()
Expand Down

0 comments on commit 638c095

Please sign in to comment.