fumitoh / modelx

Use Python like a spreadsheet!
https://modelx.io
GNU Lesser General Public License v3.0
89 stars 20 forks source link

inconsistent behaviour of "model" ref #47

Closed alexeybaran closed 3 years ago

alexeybaran commented 3 years ago

Until version 13.1 I used to store explicit reference to the model as a ref:

m = mx.new_model()
m.model = m

Version 14 doesn't allow it as it seems to have built in "model" ref. But for some reason this ref isn't recongnisable in the space formula namespace:

import modelx as mx
m = mx.new_model()
print(m.model)
def s_arg():
    print(model)

s = mx.new_space(formula=s_arg)
s()
fumitoh commented 3 years ago

Model.model has been a read-only property bound to the model itself but assignment had been allowed by mistake until v0.13.1. ad2b131 fixed it.

You can define another name for the model in s, e.g. s.Model = m because s_arg is in s's namespace.

Alternatively, you can do print(_space.model) in stead of print(model). _space is a special reference that reference the space itself.