biosimulators / Biosimulators_utils

Utilities for building standardized command-line interfaces for biosimulation software packages
https://docs.biosimulators.org/Biosimulators_utils
MIT License
4 stars 6 forks source link

infix math doesn't follow Python conventions #120

Open luciansmith opened 1 year ago

luciansmith commented 1 year ago

The libsedml.formulaToL3String() (inherited from libsbml) will often work as-is to be interpretable in Python, but there are many cases where it will not. Issue #118 fixed one of them, but several remain. I'll try to come up with a complete list:

Note that avogadro is explicitly defined as exactly that value in libsbml, even though avogadro's number is now different than it was when the SBML spec first introduced the symbol. libsedml doesn't say anything about avogadro, of course, but

I had the vague memory of doing something like this before, and managed to find it:

https://github.com/luciansmith/sedml-script/blob/master/parser/src/registry.cpp#L335

Looks like I didn't get everything above, but a lot of it is there. Seems like the math functions can be imported from a combination of 'math' and 'mpmath', and you have to write your own 'piecewise' function a la

https://github.com/luciansmith/sedml-script/blob/master/parser/src/registry.cpp#L471

luciansmith commented 1 year ago

Looking at the actual code, most of this is indeed already handled, which is great. And I'm not sure if the sbml-specific csymbols (avogadro, delay, rateOf) are allowed in SED-ML anyway, so those are probably fine. But the units definitely need to be removed, and the functions with 0/1 arguments probably should be dealt with, though this probably won't come up very often, if at all.