function#
import tensorwaves.function
Express mathematical expressions in terms of computational functions.
- class PositionalArgumentFunction(function: Callable[..., ndarray], argument_order: Iterable[str])[source]#
Bases:
Function[dict[str,ndarray],ndarray]Wrapper around a function with positional arguments.
This class provides a
__call__()that can take aDataSamplefor a function with positional arguments. Itsargument_orderredirect the keys in theDataSampleto the argument positions in its underlyingfunction.See also
- class ParametrizedBackendFunction(function: Callable[..., ndarray], argument_order: Iterable[str], parameters: Mapping[str, ParameterValue])[source]#
Bases:
ParametrizedFunction[dict[str,ndarray],ndarray]Implements
ParametrizedFunctionfor a specific computational back-end.See also
- property parameters: dict[str, TypeAliasForwardRef('tensorwaves.interface.ParameterValue')][source]#
Get
dictof 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.strip()) def _lambdifygenerated(x, y): return x**2 + y**2
Submodules and Subpackages