pystencils.AssignmentCollection.lambdify

pystencils.AssignmentCollection.lambdify#

AssignmentCollection.lambdify(symbols, fixed_symbols=None, module=None)#

Returns a python function to evaluate this equation collection.

Parameters:
  • symbols (Sequence[Symbol]) – symbol(s) which are the parameter for the created function

  • fixed_symbols (Optional[Dict[Symbol, Any]]) – dictionary with substitutions, that are applied before sympy’s lambdify

  • module – same as sympy.lambdify parameter. Defines which module to use e.g. ‘numpy’

Examples

>>> a, b, c, d = sp.symbols("a b c d")
>>> ac = AssignmentCollection([Assignment(c, a + b), Assignment(d, a**2 + b)],
...                           subexpressions=[Assignment(b, a + b / 2)])
>>> python_function = ac.lambdify([a], fixed_symbols={b: 2})
>>> python_function(4)
{c: 6, d: 18}