Closed alebaran closed 4 years ago
Formula definitions of cells in recent versions of modelx are constructed from the source code of their underlying functions so they are not calling the underlying functions anymore, so putting breakpoints in those functions won't work. I could add some option to construct formulas from functions, not from their sources for debug.
It actually works pretty well with the trick above. No need to change, I was just checking.
debug_space
is just importing all cells in a space to the global namespace as the same names. What was your issue? How does debug_space
solve it?
model, space = mx.new_model(), mx.new_space()
@mx.defcells
def a():
return b()
@mx.defcells
def b():
return 1
With the code above I can debug a() calculation by checking in the Python console what the value of b() is. I can't do the same, if the space is created from module. debug_space
allows the same Python console debugging for the space created from module.
I guess the best would be to be able to set current space with mx.cur_space(space)
function to allow Python console debugging for the space.
I didn't manage to find the way to debug cell calculations using normal debugger (pyCharm / Spyder). I'm using the following function to get into the space namespace:
How do you do it?