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: object

Structured result of evaluating one serialized checksum.

A failed result has a diagnostic explaining the failure. Its value is None if evaluation did not complete, and its reference is None if the serialized reference could not be converted to a number.

target: str[source]#
point_name: str[source]#
point: Mapping[str, float | complex][source]#
reference: float | complex | None[source]#
value: float | complex | None[source]#
difference: float[source]#
passed: bool[source]#
diagnostic: str | None = None[source]#
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: object

Numerical callables compiled from a symbolic serialization workspace.

workspace: Workspace[source]#
backend: str[source]#
functions: Mapping[str, Function][source]#
coordinate_maps: Mapping[str, Mapping[str, Function]][source]#
coordinates: Mapping[str, tuple[str, str]][source]#
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: object

Backend-independent formulation of a serialized amplitude model.

definition: Mapping[str, Any][source]#
decays: Mapping[str, ThreeBodyDecay][source]#
distributions: Mapping[str, AmplitudeModel][source]#
functions: Mapping[str, DefinedExpression][source]#
kinematics: Mapping[str, Any][source]#
reference_points: tuple[Mapping[str, Any], ...][source]#
checksums: tuple[Mapping[str, Any], ...][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 coordinates option selects two independent Mandelstam invariants for distributions. By default, they are inferred from the serialized coordinate metadata. parameter_overrides are 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