Express mathematical expressions in terms of computational functions.

class PositionalArgumentFunction(function: Callable[..., ndarray], argument_order: Iterable[str])[source]#

Bases: Function

Wrapper around a function with positional arguments.

This class provides a __call__() that can take a DataSample for a function with positional arguments. Its argument_order redirect the keys in the DataSample to the argument positions in its underlying function.

function: Callable[..., ndarray]#

A function with positional arguments only.

argument_order: tuple[str, ...]#

Ordered labels for each positional argument.

class ParametrizedBackendFunction(function: Callable[..., ndarray], argument_order: Iterable[str], parameters: Mapping[str, ParameterValue])[source]#

Bases: ParametrizedFunction

Implements ParametrizedFunction for a specific computational back-end.

property function: Callable[..., ndarray]#
property argument_order: tuple[str, ...]#
property parameters: dict[str, ParameterValue]#

Get dict of parameters.

update_parameters(new_parameters: Mapping[str, ParameterValue]) None[source]#

Update the collection of parameters.

get_source_code(function: Function) str[source]#

Get the backend source code used to compile this function.

>>> import sympy as sp
>>> from tensorwaves.function.sympy import create_function
>>> x, y = sp.symbols("x y")
>>> expr = x**2 + y**2
>>> func = create_function(expr, backend="jax", use_cse=False)
>>> src = get_source_code(func)
>>> print(src)
def _lambdifygenerated(x, y):
    return x**2 + y**2

Submodules and Subpackages