I encountered an issue with expressions in nestml functions. I had expressions which featured a division of integers, i.e. 4 / 7, which in the C++ code were not converted to divisions of doubles, i.e. 4./7.. I feel that this mixes abstraction levels; when writing models in a high-level language, I would expect more pythonic behaviour, and 4 / 7 should return 0.571429 and not 0.
Furthermore, I suspect the issue would be fixed by simply calling sympy.printing.ccode(sympy.sympify(expr)) with expr the expression in the function block, unless there are some subtle aspects of the code generation for nestml functions that I am missing.
I encountered an issue with expressions in nestml functions. I had expressions which featured a division of integers, i.e.
4 / 7, which in the C++ code were not converted to divisions of doubles, i.e.4./7.. I feel that this mixes abstraction levels; when writing models in a high-level language, I would expect more pythonic behaviour, and4 / 7should return0.571429and not0.Furthermore, I suspect the issue would be fixed by simply calling
sympy.printing.ccode(sympy.sympify(expr))withexprthe expression in the function block, unless there are some subtle aspects of the code generation for nestml functions that I am missing.