BhallaLab / moose-core

C++ basecode and python scripting interface
https://moose.ncbs.res.in
GNU General Public License v3.0
15 stars 27 forks source link

Error: Function::getValue(),getDerivative,getExpr - invalid state #409

Closed hrani closed 4 years ago

hrani commented 4 years ago

With the latest fix/feature for function, now when created a new instance of function, getting error as

Error: Function::getDerivative() - invalid state

Error: /m[0]/c[0]/f[0]::getExpr() - invalid parser state

Expression was :

Error: Function::getValue() - invalid state

warn: Expr is empty

` functionerror.txt

`

dilawar commented 4 years ago

~Fix are pending in #405~. Related to #405 but not a bug.

dilawar commented 4 years ago

~Duplicate of #401~. Related to #401 but not a bug.

dilawar commented 4 years ago

For this particular example, you can set expr to 0. Empty expression is a warning.

moose.Neutral('/m')
moose.CubeMesh('/m/c')
f = moose.Function('/m/c/f')
f.expr = '0'  # don't leave it blank.
moose.showfield(f)
hrani commented 4 years ago

When one created a new function object one can't expect to fill the values before hand. Default values need to be filled.

dilawar commented 4 years ago

Ok. The old behaviour in 3.1.5 is that if expression is not set it is 0. I'll update #405 to change this behaviour.

[dilawars@localhost ~]$ PYTHONPATH='' python3
Python 3.8.2 (default, Mar 05 2020, 18:58:42) [GCC] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import moose
>>> f = moose.Function('f1')
>>> moose.showfields(f)

[ /f[0] ]
className        = Function
derivative       = 0.0
dt               = 0.1
expr             = 0 
fieldIndex       = 0
idValue          = 452
independent      = x0
index            = 0
mode             = 1
name             = f
numData          = 1
numField         = 1
numVars          = 0
path             = /f[0]
rate             = 0.0
tick             = 12
value            = 0.0
>>>
dilawar commented 4 years ago

Fix are pending in #405 . Once travis passes it, please review and merge it.