Skip to content

Commit 5f8650c

Browse files
committed
ENH: add utility function _hashSymOpList
Compute hash value from sorted symmetry operations.
1 parent 32da806 commit 5f8650c

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/diffpy/structure/spacegroups.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,26 @@ def IsSpaceGroupIdentifier(sgid):
7373
return rv
7474

7575

76+
def _hashSymOpList(symops):
77+
"""Return hash value for a sequence of `SymOp` objects.
78+
79+
The symops are sorted so the results is independent of symops order.
80+
81+
Parameters
82+
----------
83+
symops : sequence
84+
The sequence of `SymOp` objects to be hashed
85+
86+
Returns
87+
-------
88+
int
89+
The hash value.
90+
"""
91+
ssop = sorted(str(o) for o in symops)
92+
rv = hash(tuple(ssop))
93+
return rv
94+
95+
7696
def _buildSGLookupTable():
7797
"""Rebuild space group lookup table from the SpaceGroupList data.
7898

0 commit comments

Comments
 (0)