# Sympy¶

Export and import of SymPy expressions

## Converting to and from SymPy¶

myokit.formats.sympy.write(e)

Converts the given Myokit expression to a SymPy expression.

myokit.formats.sympy.read(e, model=None)

Converts the given Sympy expression to a myokit one. Any variable names will be resolved against the given model.

## API¶

The standard interface for exporting and accessing expression writers is provided:

myokit.formats.sympy.ewriters()

Returns a dict of all expression writers available in this module.

class myokit.formats.sympy.SymPyExpressionWriter

This ExpressionWriter converts Myokit expressions to SymPy expressions.

The returned type is a SymPy object, not a string!

eq(eq)

Converts an equation to a sympy Eq object.

ex(e)

Converts an expression to a sympy Eq object.

set_lhs_function(f)
Sets a naming function, will be called to get the variable name from a
myokit.LhsExpression object.

The argument f should be a function that takes an LhsExpression as input and returns a string.

class myokit.formats.sympy.SymPyExpressionReader(model=None)

Converts Sympy expressions to Myokit expressions.

Any variable names will be resolved against the given model. If no model is given, string names will be used instead of myokit Variable objects.

ex(e)

Converts the Sympy expression e to a myokit.Expression.

set_model(model=None)

Changes the model used by this reader to resolve variable names.