diff --git a/modelx/core/system.py b/modelx/core/system.py index 08a3fd5..0bda294 100644 --- a/modelx/core/system.py +++ b/modelx/core/system.py @@ -51,7 +51,7 @@ def eval_node(self, node): cells = node[OBJ] key = node[KEY] - if cells.has_node(key): + if cells.is_cached and cells.has_node(key): value = cells.data[key] if self.callstack: # Shortcut for append & pop for performance diff --git a/modelx/tests/core/cells/test_cache.py b/modelx/tests/core/cells/test_cache.py index a8687c7..c681cf6 100644 --- a/modelx/tests/core/cells/test_cache.py +++ b/modelx/tests/core/cells/test_cache.py @@ -77,3 +77,25 @@ def bar(x): assert foo(3) == 12 m.close() + + +def test_unhashable_arg(): + + m = mx.new_model() + + @mx.defcells + def foo(x): + return bar([1, 2, 3]) + + @mx.defcells + def bar(l: list): + return l + + bar.is_cached = False + + foo(0) + + assert foo.preds(0)[0].obj is bar + assert foo.preds(0)[0].args is None + + m.close()