Skip to content

Divisions of integers not converted to divisions of doubles in generated C++ code of nestml functions #902

Description

@WillemWybo

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions