Closed fumitoh closed 4 years ago
@alexeybaran Fixed. Thanks for the bug report.
The check isn't dicriminative enough:
from modelx import *
m, s = new_model(), new_space()
@defcells
def a(t):
def my_sum(*args):
return sum(args)
return my_sum('a')
a(1)
More resilient algorithm would be check name correspondence: frame.name == node.name
. If the name doesn't match, frame
content should still be shown, but without extra mx
details
I also noticed that frame.name
can be <lambda>
. cab61ce should fix both your case and the lambda case, as the additional tests show.
i = 0
while len(rolledback) > 0:
node = rolledback.pop()
while tbexc.stack[i].name != node[0].name:
i += 1
self.append(
(node, frame.lineno)
)
?
Won't work. tbexc.stack[i].name
can be "<lambda>"
and node[0].name
can be "lam"
.
import modelx as mx
s = mx.new_space()
s.new_cells("lam", formula=lambda x: qux(x-1) if x > 0 else 1/0)
@mx.defcells
def qux(x):
return lam(x)
s.lam(1)
Clear. Now the error messaging works for me. Thank you very much!
Will you share the fix through pip version?
Just released v0.6.1
Thank you for this development. Unfortunately it breaks in case function is used within the cell:
Originally posted by @alexeybaran in https://github.com/fumitoh/modelx/issues/16#issuecomment-619886334