Skip to content

Commit b735969

Browse files
authored
update coords after shift_orig_zero (#803)
Hi, I think this part of the code was attempting to modify local variables (`ii`) rather than the actual array elements in `self.data["coords"]`. Before: ``` @post_funcs.register("shift_orig_zero") def _shift_orig_zero(self): for ff in self.data["coords"]: for ii in ff: ii = ii - self.data["orig"] ... ``` After: ``` ... self.data["coords"] = self.data["coords"] - self.data["orig"] ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Enhanced the efficiency of coordinate adjustments for improved performance on larger datasets. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: .Del <[email protected]>
1 parent 0679ee2 commit b735969

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

dpdata/system.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -710,9 +710,7 @@ def affine_map(self, trans, f_idx: int | numbers.Integral = 0):
710710

711711
@post_funcs.register("shift_orig_zero")
712712
def _shift_orig_zero(self):
713-
for ff in self.data["coords"]:
714-
for ii in ff:
715-
ii = ii - self.data["orig"]
713+
self.data["coords"] = self.data["coords"] - self.data["orig"]
716714
self.data["orig"] = self.data["orig"] - self.data["orig"]
717715
assert (np.zeros([3]) == self.data["orig"]).all()
718716

0 commit comments

Comments
 (0)