particle v1 changed the type of charge values from float to fractions.Fraction. QRules currently assumes that item.charge behaves like a float and calls item.charge.is_integer() while loading the PDG particle definitions.
|
and item.charge.is_integer() # remove quarks |
Also, the spin J of the particle is now sometimes None, which is a problem here:
|
spin=float(pdg_particle.J), |
This came up while updating the dependency lock file to particle v1 in #333.
How to reproduce?
Use Python 3.10 for the reproducer, because newer Python versions can mask this via Fraction.is_integer().
This works on main with particle==0.26.2:
uv run --python 3.10 --with particle==0.26.2 python - <<'PY'
from importlib.metadata import version
from qrules.particle import load_pdg
print(f"particle {version('particle')}")
print(len(load_pdg()))
PY
Expected output:
This crashes on main with particle==1.0.0:
uv run --python 3.10 --with particle==1.0.0 python - <<'PY'
from importlib.metadata import version
from qrules.particle import load_pdg
print(f"particle {version('particle')}")
print(len(load_pdg()))
PY
Expected failure:
particle 1.0.0
AttributeError: 'Fraction' object has no attribute 'is_integer'
particlev1 changed the type of charge values fromfloattofractions.Fraction. QRules currently assumes thatitem.chargebehaves like a float and callsitem.charge.is_integer()while loading the PDG particle definitions.qrules/src/qrules/particle.py
Line 507 in f3f25b2
Also, the spin
Jof the particle is now sometimesNone, which is a problem here:qrules/src/qrules/particle.py
Line 559 in f3f25b2
This came up while updating the dependency lock file to
particlev1 in #333.How to reproduce?
Use Python 3.10 for the reproducer, because newer Python versions can mask this via
Fraction.is_integer().This works on
mainwithparticle==0.26.2:Expected output:
This crashes on
mainwithparticle==1.0.0:Expected failure: