Skip to content

Commit

Permalink
fix pyright
Browse files Browse the repository at this point in the history
  • Loading branch information
Han Wang committed Jun 5, 2024
2 parents c7bf8fc + 54c7c98 commit b3e18ae
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
4 changes: 3 additions & 1 deletion dpdata/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,9 @@ def replicate(self, ncopy: list[int] | tuple[int, int, int]):
tmp.data["atom_numbs"] = list(
np.array(np.copy(data["atom_numbs"])) * np.prod(ncopy)
)
tmp.data["atom_types"] = np.tile(np.copy(data["atom_types"]), (int(np.prod(ncopy)),) + (1,))
tmp.data["atom_types"] = np.tile(
np.copy(data["atom_types"]), (int(np.prod(ncopy)),) + (1,)
)
tmp.data["atom_types"] = np.transpose(tmp.data["atom_types"]).reshape([-1])

tmp.data["cells"] = np.copy(data["cells"])
Expand Down
19 changes: 14 additions & 5 deletions tests/test_replicate.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,31 @@ def setUp(self):
self.system_2 = dpdata.System("poscars/POSCAR.SiC", fmt="vasp/poscar")
self.places = 6


class TestReplicateTriclinicBox(unittest.TestCase, CompSys, IsPBC):
def setUp(self):
self.system_1 = dpdata.System()
self.system_1.data["atom_names"] = ["foo", "bar"]
self.system_1.data["atom_types"] = np.array([1, 0], dtype=int)
self.system_1.data["atom_numbs"] = [1, 1]
self.system_1.data["cells"] = np.array([10, 0, 0, 0, 10, 0, 0, 0, 10], dtype=float).reshape(1,3,3)
self.system_1.data["coords"] = np.array([0, 0, 0, 0, 0, 1], dtype=float).reshape(1,2,3)
self.system_1 = self.system_1.replicate([2,1,1])
self.system_1.data["cells"] = np.array(
[10, 0, 0, 0, 10, 0, 0, 0, 10], dtype=float
).reshape(1, 3, 3)
self.system_1.data["coords"] = np.array(
[0, 0, 0, 0, 0, 1], dtype=float
).reshape(1, 2, 3)
self.system_1 = self.system_1.replicate([2, 1, 1])

self.system_2 = dpdata.System()
self.system_2.data["atom_names"] = ["foo", "bar"]
self.system_2.data["atom_types"] = np.array([1, 1, 0, 0], dtype=int)
self.system_2.data["atom_numbs"] = [2, 2]
self.system_2.data["cells"] = np.array([20, 0, 0, 0, 10, 0, 0, 0, 10], dtype=float).reshape(1,3,3)
self.system_2.data["coords"] = np.array([0, 0, 0, 10, 0, 0, 0, 0, 1, 10, 0, 1], dtype=float).reshape(1,4,3)
self.system_2.data["cells"] = np.array(
[20, 0, 0, 0, 10, 0, 0, 0, 10], dtype=float
).reshape(1, 3, 3)
self.system_2.data["coords"] = np.array(
[0, 0, 0, 10, 0, 0, 0, 0, 1, 10, 0, 1], dtype=float
).reshape(1, 4, 3)
self.places = 6


Expand Down

0 comments on commit b3e18ae

Please sign in to comment.