Code generation¶
Sympy expressions can be converted to code strings using a cellmlmanip.printer.Printer
.
-
class
cellmlmanip.printer.
Printer
(symbol_function=None, derivative_function=None)[source]¶ Bases:
sympy.printing.printer.Printer
Converts Sympy expressions to strings of Python code.
To use, create a
Printer
instance, and call its methoddoprint()
with a Sympy expression as argument.To extend this to other languages, create a
Printer
subclass, and override_function_names
,_literal_names
, or any of the_print_X
methods as necessary.- Parameters
symbol_function – A function that converts
sympy.Symbols
to strings (variable names).derivative_function – A function that converts derivatives to strings.