fumitoh / modelx

Use Python like a spreadsheet!

Home Page:https://modelx.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

inconsistent behaviour of "model" ref

alexeybaran opened this issue · comments

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()

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.