Skip to content

Commit

Permalink
fix hash of SymmOp
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielYang59 committed May 14, 2024
1 parent 41e5851 commit bf2a953
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pymatgen/core/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __eq__(self, other: object) -> bool:
return np.allclose(self.affine_matrix, other.affine_matrix, atol=self.tol)

def __hash__(self) -> int:
return 7 # DEBUG (DanielYang59): magic hash
return hash((tuple(map(tuple, self.affine_matrix)), self.tol))

def __repr__(self) -> str:
affine_matrix = self.affine_matrix
Expand Down
3 changes: 3 additions & 0 deletions tests/core/test_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ class TestSymmOp(PymatgenTest):
def setUp(self):
self.op = SymmOp.from_axis_angle_and_translation([0, 0, 1], 30, translation_vec=[0, 0, 1])

def test_hash(self):
assert hash(self.op) == 2248719638412467238

def test_properties(self):
rot = self.op.rotation_matrix
vec = self.op.translation_vector
Expand Down

0 comments on commit bf2a953

Please sign in to comment.