You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
sbml_math_to_sympy fails on powers with a dimensionless numeric base and a symbolic exponent #50
sbml_math_to_sympy cannot parse <power/> with a numeric base that has sbml:units and a non-numeric exponent. set_math (with the default literals_dimensionless=True) writes exactly such MathML for, e.g., 10**x, so the output of set_math cannot be read back:
File ".../sbmlmath/mathml_parser.py", line 54, in _pow
...
File ".../pint/util.py", line 650, in __pow__
TypeError: Cannot power UnitsContainer by <class 'sympy.core.symbol.Symbol'>
The same happens for 2.5**x. x**2 (units on the exponent) works.
The base is converted to a pint quantity, and pint can't raise units to a symbolic power. For a dimensionless base, the result is dimensionless, so the units could be dropped (or the magnitude used) before taking the power. For a base with other units and a non-numeric exponent, the units of the result are not defined; this could raise a clear error, or drop the units with a warning.
Workaround: write the MathML with SBMLMathMLPrinter(literals_dimensionless=False).
Activity