if the MathML for a computeChange contains a operator, the infix notation from returned by libsedml.formulaToL3String() represents the pow operator as '^', but the corresponding python syntax is '**'. During validation of a computed change, this infix representation (stored in change.math) is evaluated and fails if the operands are not compatible with bitwise XOR (e.g. if either operand is a float)
compile_math() function in Biosimulators_utils/sedml/math.py now replaces '^' with '**' in infix strings before python evaluation. It is assumed that SEDML MathML will not support the bitwise XOR operator.
Fixes the following bug
Adds Math infix notation support for power operator which currently fails SEDML validation (closes #118)
Testing
A new unit test was added to exercise all math infix string replacements (for AND, OR, POWER).
See MathTestCase.test_python_infix_operator_substitutions() in /tests/sedml/test_sedml_math.py.
fix SEDML validation error when model changes include power operator
see Issue 118: "infix math from libsedml uses '^' instead of '**' in python, validation fails
Background
if the MathML for a computeChange contains a operator, the infix notation from returned by libsedml.formulaToL3String() represents the pow operator as '^', but the corresponding python syntax is '**'. During validation of a computed change, this infix representation (stored in change.math) is evaluated and fails if the operands are not compatible with bitwise XOR (e.g. if either operand is a float)
compile_math() function in
Biosimulators_utils/sedml/math.py
now replaces '^' with '**' in infix strings before python evaluation. It is assumed that SEDML MathML will not support the bitwise XOR operator.Fixes the following bug
Testing
AND
,OR
,POWER
). SeeMathTestCase.test_python_infix_operator_substitutions()
in /tests/sedml/test_sedml_math.py.