sbmlsim.combine.mathml

Helper functions for evaluation of MathML expressions. Using sympy to evalutate the expressions.

Module Contents

Functions

formula_to_astnode(formula)

Parses astnode from formula

parse_mathml_str(mathml_str)

parse_formula(formula)

parse_astnode(astnode)

An AST node in libSBML is a recursive tree structure; each node has a type,

expr_from_formula(formula)

Parses sympy expression from given formula string.

evaluate(astnode, variables)

Evaluate the astnode with values

_get_variables(astnode, variables=None)

Adds variable names to the variables.

replace_piecewise(formula)

Replaces libsbml piecewise with sympy piecewise.

Attributes

expr

sbmlsim.combine.mathml.formula_to_astnode(formula)[source]

Parses astnode from formula

Parameters

formula (str) –

Return type

libsbml.ASTNode

sbmlsim.combine.mathml.parse_mathml_str(mathml_str)[source]
Parameters

mathml_str (str) –

sbmlsim.combine.mathml.parse_formula(formula)[source]
Parameters

formula (str) –

sbmlsim.combine.mathml.parse_astnode(astnode)[source]

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/libsbml-math.html

Parameters
  • mathml

  • astnode (libsbml.ASTNode) –

Returns

sbmlsim.combine.mathml.expr_from_formula(formula)[source]

Parses sympy expression from given formula string.

Parameters

formula (str) –

sbmlsim.combine.mathml.evaluate(astnode, variables)[source]

Evaluate the astnode with values

Parameters
  • astnode (libsbml.ASTNode) –

  • variables (Dict) –

sbmlsim.combine.mathml._get_variables(astnode, variables=None)[source]

Adds variable names to the variables.

Parameters

astnode (libsbml.ASTNode) –

Return type

Set[str]

sbmlsim.combine.mathml.replace_piecewise(formula)[source]

Replaces libsbml piecewise with sympy piecewise.

sbmlsim.combine.mathml.expr[source]