gEconpy.model.compile.compile_to_pytensor_function#

gEconpy.model.compile.compile_to_pytensor_function(inputs, outputs, cache, stack_return, pop_return, return_symbolic, **kwargs)#

Convert a sympy function to a pytensor function using 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

Dictionary mapping sympy symbols to pytensor symbols. Used to maintain namespace scope between different compiled functions.

stack_return: bool

If True, the function will return a single numpy array with all outputs. Otherwise it will return a list of numpy arrays.

pop_return: bool

If True, the function will return only the 0th element of the output. Used to remove the list wrapper around single-output functions.

return_symbolic: bool

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

kwargs: dict

Additional keyword arguments to pass to pytensor.function(). Ignored if return_symbolic is True.

Returns:
f: Callable

The compiled function.

cache: dict

Pytensor caching information.