- 
                Notifications
    You must be signed in to change notification settings 
- Fork 6
Description
What happened?
When a HelicityModel is pickled and then loaded again, the kinematic_variables are incorrect and cannot be used e.g. to create a SympyDataTransformer. For the model I tested this with, a difference occurs in the angles "phi_1^12" and "theta_1^12".
The entry "phi_1^12" in the kinematic_variables before the pickling is:
Phi(ArrayMultiplication(BoostZMatrix(EuclideanNorm(ThreeMomentum(p1 + p2))/Energy(p1 + p2), ArraySize(p0)), RotationYMatrix(-Theta(p1 + p2), ArraySize(p0)), RotationZMatrix(-Phi(p1 + p2), ArraySize(p0)), p1)))
After the pickling this becomes:
Phi(ArrayMultiplication(BoostZMatrix(EuclideanNorm((p1 + p2,))/Energy(p1 + p2), (p0,)), RotationYMatrix(-Theta(p1 + p2), (p0,)), RotationZMatrix(-Phi(p1 + p2), (p0,)), p1)))
Relevant log output
Is it possible to reproduce the bug with a small code snippet?
from tensorwaves.data import (SympyDataTransformer)
import qrules
import ampform
import pickle
from ampform.helicity import HelicityModel
reaction = qrules.generate_transitions(
    initial_state=("J/psi(1S)", [-1, +1]),
    final_state=["gamma", "pi0", "pi0"],
    allowed_intermediate_particles=["f(0)(980)", "f(0)(1500)"],
    allowed_interaction_types=["strong", "EM"],
    formalism="canonical-helicity",
)
model_builder = ampform.get_builder(reaction)
model = model_builder.formulate()
helicity_transformer = SympyDataTransformer.from_sympy(
    model.kinematic_variables, backend="jax"
)
with open("test.pickle", "wb") as stream:
    pickle.dump(model, stream)
with open("test.pickle", "rb") as stream:
    loaded_model: HelicityModel = pickle.load(stream)
print(loaded_model.kinematic_variables)
model.kinematic_variablesAdditional steps to reproduce the bug
No response
Which Python version were you using?
Python 3.10
Python dependencies