diff --git a/pymatgen/core/operations.py b/pymatgen/core/operations.py index 2e5289ceaad..41e9f7660cd 100644 --- a/pymatgen/core/operations.py +++ b/pymatgen/core/operations.py @@ -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 diff --git a/tests/core/test_operations.py b/tests/core/test_operations.py index d2dcc26de42..16f70c8390b 100644 --- a/tests/core/test_operations.py +++ b/tests/core/test_operations.py @@ -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