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:
PrinterConverts Sympy expressions to strings of Python code.
To use, create a
Printerinstance, and call its methoddoprint()with a Sympy expression as argument.To extend this to other languages, create a
Printersubclass, and override_function_names,_literal_names, or any of the_print_Xmethods as necessary.- Parameters:
symbol_function – A function that converts
sympy.Symbolsto strings (variable names).derivative_function – A function that converts derivatives to strings.