interfaces¶
import tensorwaves.interfaces
Defines top-level interfaces of tensorwaves.
-
class
DataTransformer
[source]¶ Bases:
abc.ABC
Interface of a data converter.
-
abstract
transform
(dataset: Mapping[str, numpy.ndarray]) → Mapping[str, numpy.ndarray][source]¶ Transform a dataset into another dataset.
This changes the keys and values of the input
DataSample
to a specific outputDataSample
structure.
-
abstract
-
class
Estimator
[source]¶ Bases:
abc.ABC
Estimator for discrepancy model and data.
-
class
FitResult
(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]]] = None, iterations: Optional[int] = None, specifics: Optional[Any] = None)[source]¶ Bases:
object
-
__eq__
(other)¶ Method generated by attrs for class FitResult.
-
specifics
: Optional[Any]¶ Any additional info provided by the specific optimizer.
-
-
class
Function
[source]¶ Bases:
abc.ABC
Interface of a callable function.
The parameters of the model are separated from the domain variables. This follows the mathematical definition, in which a function defines its domain and parameters. However specific points in the domain are not relevant. Hence while the domain variables are the argument of the evaluation (see
__call__()
), the parameters are controlled via a getter and setter (seeparameters()
). The reason for this separation is to facilitate the events when parameters have changed.-
abstract
__call__
(dataset: Mapping[str, numpy.ndarray]) → numpy.ndarray[source]¶ Evaluate the function.
- Parameters
dataset – a
dict
with domain variable names as keys.- Returns
Result of the function evaluation. Type depends on the input type.
-
abstract
-
class
Model
[source]¶ Bases:
abc.ABC
Interface of a model which can be lambdified into a callable.
-
property
argument_order
¶ Order of arguments of lambdified function signature.
-
abstract
lambdify
(backend: Union[str, tuple, dict]) → Callable[source]¶ Lambdify the model into a Callable.
- Parameters
backend – Choice of backend for fast evaluations.
The arguments of the Callable are union of the variables and parameters. The return value of the Callable is Any. In theory the return type should be a value type depending on the model. Currently, there no typing support is implemented for this.
-
abstract property
parameters
¶ Get mapping of parameters to suggested initial values.
-
abstract
performance_optimize
(fix_inputs: Mapping[str, numpy.ndarray]) → tensorwaves.interfaces.Model[source]¶ Create a performance optimized model, based on fixed inputs.
-
abstract property
variables
¶ Expected input variable names.
-
property
-
class
Optimizer
[source]¶ Bases:
abc.ABC
Optimize a fit model to a data set.
-
abstract
optimize
(estimator: tensorwaves.interfaces.Estimator, initial_parameters: Mapping[str, Union[complex, float]]) → tensorwaves.interfaces.FitResult[source]¶ Execute optimization.
-
abstract
-
class
PhaseSpaceGenerator
[source]¶ Bases:
abc.ABC
Abstract class for generating phase space samples.
-
abstract
generate
(size: int, rng: tensorwaves.interfaces.UniformRealNumberGenerator) → Tuple[Mapping[int, Sequence[Tuple[float, float, float, float]]], numpy.ndarray][source]¶ Generate phase space sample.
Returns a
tuple
of a mapping of final state IDs tonumpy.array
s with four-momentum tuples.
-
abstract
setup
(reaction_info: ampform.kinematics.ReactionInfo) → None[source]¶ Hook for initialization of the PhaseSpaceGenerator.
Called before any generate calls.
-
abstract