fumitoh / modelx

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

Issue with dynamic space formula, creating refs different from 'name' #20

Closed alebaran closed 4 years ago

alebaran commented 4 years ago

There seems to be an issue with with dynamic space formula, when creating refs different from name:

from modelx import *
m = new_model()
def try_param(a):
    return {'b': 1, 'bases': _self}
m.new_space(name='x', formula=try_param)
m.x(1)
Traceback (most recent call last):
  File "...\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 3326, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-2-bc5d1a811ba4>", line 6, in <module>
    m.x(1)
  File "...\Anaconda3\lib\site-packages\modelx\core\space.py", line 346, in __call__
    return self._impl.get_dynspace(args, kwargs).interface
  File "...\Anaconda3\lib\site-packages\modelx\core\space.py", line 1057, in get_dynspace
    space = self._new_dynspace(**space_args)
TypeError: _new_dynspace() got an unexpected keyword argument 'b'
alebaran commented 4 years ago

I figured out how to do it, sorry for raising too early