serialization#
import ampform_dpd.io.serialization
Amplitude model serialization
See Model serialization for more information and https://rub-ep1.github.io/amplitude-serialization for more information.
Warning
This module is in preview, see ComPWA/ampform-dpd#133 for updates.
- class ChecksumResult(target: str, point_name: str, point: Mapping[str, float | complex], reference: float | complex | None, value: float | complex | None, difference: float, passed: bool, diagnostic: str | None = None)[source]#
Bases:
objectStructured result of evaluating one serialized checksum.
A failed result has a diagnostic explaining the failure. Its
valueisNoneif evaluation did not complete, and itsreferenceisNoneif the serialized reference could not be converted to a number.
- class CompiledWorkspace(workspace: Workspace, backend: str, functions: Mapping[str, Function], coordinate_maps: Mapping[str, Mapping[str, Function]], coordinates: Mapping[str, tuple[str, str]])[source]#
Bases:
objectNumerical callables compiled from a symbolic serialization workspace.
- class Workspace(definition: Mapping[str, Any], decays: Mapping[str, ThreeBodyDecay], distributions: Mapping[str, AmplitudeModel], functions: Mapping[str, DefinedExpression], kinematics: Mapping[str, Any], reference_points: tuple[Mapping[str, Any], ...], checksums: tuple[Mapping[str, Any], ...])[source]#
Bases:
objectBackend-independent formulation of a serialized amplitude model.
- decays: Mapping[str, ThreeBodyDecay][source]#
- distributions: Mapping[str, AmplitudeModel][source]#
- functions: Mapping[str, DefinedExpression][source]#
- compile_workspace(workspace: Workspace, *, backend: str, targets: Iterable[str] | None = None, coordinates: Iterable[str] | None = None, parameter_overrides: Mapping[Basic, Any] | None = None) CompiledWorkspace[source]#
Compile selected targets through TensorWaves.
The
coordinatesoption selects two independent Mandelstam invariants for distributions. By default, they are inferred from the serialized coordinate metadata.parameter_overridesare applied without mutating the symbolic workspace.
- formulate_kinematic_map(workspace: Workspace, distribution: str | None = None) Mapping[Symbol, Expr][source]#
Map a serialized isobar mass and helicity angle to all invariants.
The serialized angle \(\theta_{ij}\) is measured between particle \(i\) and spectator \(k\) in the rest frame of the \((ij)\) isobar. Its ordered pair must follow the cyclic convention
(1, 2),(2, 3), or(3, 1).
- load_workspace(source: str | Path | Mapping[str, Any], *, builders: Mapping[str, PropagatorDynamicsBuilder] | None = None, to_latex: Callable[[str], str] | None = None) Workspace[source]#
Load and formulate every distribution in a serialized model.
- validate_checksums(workspace_or_compiled: Workspace | CompiledWorkspace, *, backend: str = 'jax', atol: float = 1e-10, rtol: float = 1e-07) tuple[ChecksumResult, ...][source]#
Evaluate serialized checksums without aborting on individual failures.
A checksum passes when
abs(value - reference) <= atol + rtol * abs(reference). Compilation, point conversion, evaluation, and non-finite output failures are returned as failed records with diagnostics.- Parameters:
workspace_or_compiled – Symbolic workspace to compile on demand, or a previously compiled workspace.
backend – Numerical backend used when compiling a symbolic workspace.
atol – Absolute tolerance for the checksum comparison.
rtol – Relative tolerance, scaled by the absolute reference value.
- Returns:
An immutable result tuple in serialized checksum order.
Submodules and Subpackages
- amplitude
- compiler
- decay
- dynamics
- format
ModelDefinitionDistributionDecayDescriptionTopologyDecayChainPropagatorHelicityVertexParityVertexLSVertexVertexNodeKinematicsDefinitionStateDefinitionFunctionDefinitionBlattWeisskopfDefinitionBreitWignerDefinitionGenericFunctionDefinitionPolynomialDefinitionMomentumPowerDefinitionMultichannelBreitWignerDefinitionChannelParametersget_decay_chains()get_distribution_def()get_function_definition()get_reference_topology()is_decay_node()is_production_node()as_final_state_pair()is_isobar()
- kinematics
- validation
- workspace