wholecell.utils.build_ode

Utilities to compile functions, esp. from Sympy-constructed Matrix math.

wholecell.utils.build_ode._matrix_to_array(matrix)[source]

Convert a sympy Matrix expression to a function body.

Parameters:

matrix (sympy.Matrix) –

Return type:

str

wholecell.utils.build_ode.build_functions(arguments, expression)[source]

Build a function from its arguments and source code expression. (This USED TO return a second function that had Numba set up to JIT-compile the code on demand, but the compiled code time savings don’t pay back the compilation time in Python 3.9+.)

This still returns two functions so the JIT compiler could be restored someday.

Parameters:
  • arguments (str) – comma-separated lambda argument names

  • expression (str) – expression to compile

Returns:

a function(arguments), the same function(arguments) [was a JIT-enabled version]

Return type:

Tuple[Callable, Callable]

wholecell.utils.build_ode.derivatives(matrix)[source]

Build an optimized derivatives ODE function(y, t).

Parameters:

matrix (sympy.Matrix) –

Return type:

Tuple[Callable, Callable]

wholecell.utils.build_ode.derivatives_jacobian(jacobian_matrix)[source]

Build an optimized derivatives ODE Jacobian function(y, t).

Parameters:

jacobian_matrix (sympy.Matrix) –

Return type:

Tuple[Callable, Callable]

wholecell.utils.build_ode.rates(matrix)[source]

Build an optimized rates function(t, y, kf, kr).

Parameters:

matrix (sympy.Matrix) –

Return type:

Tuple[Callable, Callable]

wholecell.utils.build_ode.rates_jacobian(jacobian_matrix)[source]

Build an optimized rates Jacobian function(t, y, kf, kr).

Parameters:

jacobian_matrix (sympy.Matrix) –

Return type:

Tuple[Callable, Callable]