gEconpy.model.compile.compile_function#

gEconpy.model.compile.compile_function(inputs, outputs, cache=None, stack_return=False, pop_return=False, return_symbolic=False, **kwargs)#

Compile a sympy function to a pytensor function.

Parameters:
inputs: list[sp.Symbol]

The inputs to the function.

outputs: list[Union[sp.Symbol, sp.Expr]]

The outputs of the function.

cache: dict, optional

A dictionary mapping from pytensor symbols to sympy expressions. Used to prevent duplicate mappings from sympy symbol to pytensor symbol from being created. Default is an empty dictionary.

stack_return: bool, optional

If True, the function will return a single numpy array with all outputs stacked. Default is False.

pop_return: bool, optional

If True, the function will return only the 0th element of the output. Default is False.

return_symbolic: bool, default False

If True, return a symbolic pytensor computation graph instead of a compiled function.

Returns:
f: Callable

A python function that computes the outputs from the inputs.

cache: dict

A dictionary mapping from sympy symbols to pytensor symbols.