Skip to content

Commit 46507cc

Browse files
m-rauenschneiderfelipe
authored andcommitted
changing hash strategy to eliminate errors
1 parent 7f73774 commit 46507cc

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

overreact/_misc.py

+8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
import overreact as rx
1616
from overreact import _constants as constants
1717

18+
def make_hashable(obj):
19+
if isinstance(obj, np.ndarray):
20+
return tuple(obj.ravel())
21+
elif isinstance(obj, (list, set)):
22+
return tuple(map(make_hashable, obj))
23+
else:
24+
return obj
25+
1826
def copy_unhashable(maxsize=128, typed=False):
1927
"""Creates a copy of the arrays received by lru_cache and make them hashable, therefore maintaining the arrays to be passed and caching prototypes of those arrays.
2028

overreact/coords.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1682,7 +1682,7 @@ def gyradius(atommasses, atomcoords, method="iupac"):
16821682
raise ValueError(msg)
16831683

16841684

1685-
@rx._misc.copy_unhashable
1685+
@rx._misc.copy_unhashable()
16861686
def inertia(atommasses, atomcoords, align=True):
16871687
r"""Calculate primary moments and axes from the inertia tensor.
16881688

0 commit comments

Comments
 (0)