Skip to content

combine.mathml

Helper functions for evaluation of MathML expressions.

Using sympy to evaluate the expressions.

formula_to_astnode

formula_to_astnode(formula)

Parse ASTNode from formula.

astnode_to_formula

astnode_to_formula(astnode)

Write ASTNode as formula.

parse_mathml_str

parse_mathml_str(mathml_str)

Parse MathML string.

parse_formula

parse_formula(formula)

Parse formula to ASTNode.

parse_astnode

parse_astnode(astnode)

Parse ASTNode.

An AST node in libSBML is a recursive tree structure; each node has a type, a pointer to a value, and a list of children nodes. Each ASTNode node may have none, one, two, or more children depending on its type. There are node types to represent numbers (with subtypes to distinguish integer, real, and rational numbers), names (e.g., constants or variables), simple mathematical operators, logical or relational operators and functions.

see also: http://sbml.org/Software/libSBML/docs/python-api/libsedml-math.html

:param mathml: :return:

expr_from_formula

expr_from_formula(formula)

Parse sympy expression from given formula string.

evaluate

evaluate(astnode, variables)

Evaluate the astnode with values.

replace_piecewise

replace_piecewise(formula)

Replace libsedml piecewise with sympy piecewise.