interface

interface

Defines top-level interface of tensorwaves.

InputType

The argument type of a Function.__call__().

alias of TypeVar(‘InputType’)

OutputType

The return type of a Function.__call__().

alias of TypeVar(‘OutputType’)

class Function(*args, **kwds)[source]

Bases: ABC, Generic[InputType, OutputType]

Generic representation of a mathematical function.

Representation of a mathematical function that computes OutputType values (co-domain) for a given set of InputType values (domain). Examples of Function are ParametrizedFunction, Estimator and DataTransformer.

abstract __call__(data: InputType) OutputType[source]

Call self as a function.

DataSample

Mapping of variable names to a sequence of data points, used by Function.

alias of Dict[str, ndarray]

ParameterValue

Allowed types for parameter values.

alias of Union[complex, float]

class ParametrizedFunction(*args, **kwds)[source]

Bases: Function[Dict[str, ndarray], ndarray]

Interface of a callable function.

A ParametrizedFunction identifies certain variables in a mathematical expression as parameters. Remaining variables are considered domain variables. Domain variables are the argument of the evaluation (see __call__()), while the parameters are controlled via parameters (getter) and update_parameters() (setter). This mechanism is especially important for an Estimator.

abstract property parameters: Dict[str, Union[complex, float]]

Get dict of parameters.

abstract update_parameters(new_parameters: Mapping[str, Union[complex, float]]) None[source]

Update the collection of parameters.

class DataTransformer(*args, **kwds)[source]

Bases: Function[Dict[str, ndarray], Dict[str, ndarray]]

Transform one DataSample into another DataSample.

This changes the keys and values of the input DataSample to a specific output DataSample structure.

class Estimator(*args, **kwds)[source]

Bases: Function[Mapping[str, Union[complex, float]], float]

Estimator for discrepancy model and data.

See the estimator module for different implementations of this interface.

__call__(parameters: Mapping[str, Union[complex, float]]) float[source]

Compute estimator value for this combination of parameter values.

abstract gradient(parameters: Mapping[str, Union[complex, float]]) Dict[str, Union[complex, float]][source]

Calculate gradient for given parameter mapping.

class FitResult(minimum_valid: bool, execution_time: float, function_calls: int, estimator_value: float, parameter_values: Optional[Dict[str, Union[complex, float]]] = None, parameter_errors: Optional[Dict[str, Union[complex, float]]] = None, iterations: Optional[int] = None, specifics: Optional[Any] = None)[source]

Bases: object

minimum_valid: bool
execution_time: float
function_calls: int
estimator_value: float
parameter_values: Dict[str, Union[complex, float]]
parameter_errors: Optional[Dict[str, Union[complex, float]]]
iterations: Optional[int]
specifics: Optional[Any]

Any additional info provided by the specific optimizer.

An instance returned by one of the implemented optimizers under the optimizer module. Currently one of:

This way, you can for instance get the covariance matrix. See also Covariance matrix.

count_number_of_parameters(complex_twice: bool = False) int[source]

Compute the number of free parameters in a FitResult.

Parameters

complex_twice (bool) – Count complex-valued parameters twice.

__eq__(other)

Method generated by attrs for class FitResult.

class Optimizer[source]

Bases: ABC

Optimize a fit model to a data set.

See the optimizer module for different implementations of this interface.

abstract optimize(estimator: Estimator, initial_parameters: Mapping[str, Union[complex, float]]) FitResult[source]

Execute optimization.

class RealNumberGenerator[source]

Bases: ABC

Abstract class for generating real numbers within a certain range.

Implementations can be found in the tensorwaves.data module.

abstract __call__(size: int, min_value: float = 0.0, max_value: float = 1.0) ndarray[source]

Generate random floats in the range [min_value, max_value).

abstract property seed: Optional[float]

Get random seed. None if you want indeterministic behavior.

class DataGenerator[source]

Bases: ABC

Abstract class for generating a DataSample.

abstract generate(size: int, rng: RealNumberGenerator) Dict[str, ndarray][source]
class WeightedDataGenerator[source]

Bases: ABC

Abstract class for generating a DataSample with weights.

abstract generate(size: int, rng: RealNumberGenerator) Tuple[Dict[str, ndarray], ndarray][source]

Generate DataSample with weights.

Returns

A tuple of a DataSample with an array of weights.