Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

infix math doesn't follow Python conventions #120

Open
6 of 11 tasks
luciansmith opened this issue Oct 18, 2022 · 1 comment
Open
6 of 11 tasks

infix math doesn't follow Python conventions #120

luciansmith opened this issue Oct 18, 2022 · 1 comment

Comments

@luciansmith
Copy link
Contributor

luciansmith commented Oct 18, 2022

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:

  • 'true' -> 'True'
  • 'false' -> 'False'
  • 'avogadro' -> '6.02214179e23'
  • 'delay' -> error
  • 'rateOf' -> error
  • 'piecewise' -> write your own function (or find it somewhere?)
  • 'plus', 'minus', and 'times' with zero or one argument (I think you can collapse some of this with an appropriate argument to 'formulaToL3String')
  • 'exp' -> something (exp(x) == e to the power of x)
  • 'ln', 'log', and 'log10' -> You can set the formulaToL3String to convert these differently, but need to import the functions from somwehre
  • All the trig functions need to be imported
  • All the units need to be removed

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
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant