diff --git a/overreact/_misc.py b/overreact/_misc.py index 6ae6af7..de823ca 100644 --- a/overreact/_misc.py +++ b/overreact/_misc.py @@ -15,6 +15,14 @@ import overreact as rx from overreact import _constants as constants +def make_hashable(obj): + if isinstance(obj, np.ndarray): + return tuple(obj.ravel()) + elif isinstance(obj, (list, set)): + return tuple(map(make_hashable, obj)) + else: + return obj + def copy_unhashable(maxsize=128, typed=False): """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. diff --git a/overreact/coords.py b/overreact/coords.py index 3e2f545..2c1467e 100644 --- a/overreact/coords.py +++ b/overreact/coords.py @@ -1682,7 +1682,7 @@ def gyradius(atommasses, atomcoords, method="iupac"): raise ValueError(msg) -@rx._misc.copy_unhashable +@rx._misc.copy_unhashable() def inertia(atommasses, atomcoords, align=True): r"""Calculate primary moments and axes from the inertia tensor.