Skip to content

Commit bf2a953

Browse files
committed
fix hash of SymmOp
1 parent 41e5851 commit bf2a953

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

pymatgen/core/operations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def __eq__(self, other: object) -> bool:
6464
return np.allclose(self.affine_matrix, other.affine_matrix, atol=self.tol)
6565

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

6969
def __repr__(self) -> str:
7070
affine_matrix = self.affine_matrix

tests/core/test_operations.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ class TestSymmOp(PymatgenTest):
1212
def setUp(self):
1313
self.op = SymmOp.from_axis_angle_and_translation([0, 0, 1], 30, translation_vec=[0, 0, 1])
1414

15+
def test_hash(self):
16+
assert hash(self.op) == 2248719638412467238
17+
1518
def test_properties(self):
1619
rot = self.op.rotation_matrix
1720
vec = self.op.translation_vector

0 commit comments

Comments
 (0)