sbmlmath.mathml_printer¶
Convenience functions for libsbml core
Classes
|
MathML code printer. |
- class sbmlmath.mathml_printer.SBMLMathMLPrinter(*args, literals_dimensionless=True, sbml_level=3, sbml_version=2, **kwargs)[source]¶
Bases:
MathMLContentPrinterMathML code printer.
This printer converts SymPy expressions to MathML code that can be used in SBML models.
Note:
assumes all constants are dimensionless
- doprint(expr, with_prolog=True, with_math=True)[source]¶
Convert SymPy expression to MathML string.
- Parameters:
expr – The SymPy expression to be converted.
with_prolog – Whether to include the XML prolog.
with_math – Whether to include the <math> tags.
- Return type:
>>> SBMLMathMLPrinter().doprint(sp.sympify("3 * a")) '<?xml version="1.0" encoding="UTF-8"?>\n<math xmlns="http://www.w3.org/1998/Math/MathML" xmlns:sbml="http://www.sbml.org/sbml/level3/version2/core">\n<apply><times/><cn type="integer" sbml:units="dimensionless">3</cn><ci>a</ci></apply></math>'
>>> SBMLMathMLPrinter().doprint(sp.sympify("cbrt(3)"), with_math=False, with_prolog=False) '<apply><root/><degree><cn>3</cn></degree><cn type="integer" sbml:units="dimensionless">3</cn></apply>'