Skip to content

Commit

Permalink
FIX: Error on passing unhashable to uncached
Browse files Browse the repository at this point in the history
  • Loading branch information
fumitoh committed Aug 22, 2024
1 parent fbe6a60 commit ef5326e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modelx/core/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions modelx/tests/core/cells/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit ef5326e

Please sign in to comment.