From 5036edfdda4b4097a6023774ca408c6f4fea2c5e Mon Sep 17 00:00:00 2001 From: m-rauen Date: Mon, 9 Dec 2024 23:37:32 -0300 Subject: [PATCH] changing hash strategy to eliminate errors --- overreact/_misc.py | 8 ++++++++ overreact/coords.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/overreact/_misc.py b/overreact/_misc.py index 6ae6af71..de823caf 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 3e2f5458..2c1467ea 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.