At-rest theta conversions return NaN energy or mass
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 76/100
Direzione di ricerca
Start with the theta branches in src/vector/_compute/spatial/mag2.py and src/vector/_compute/spatial/mag.py, which the issue identifies as dividing zero by zero at the origin. Reproduce the failure with the supplied script across object and NumPy backends, then inspect the coordinate conversion paths that use these calculations. Done means all eight conversions return energy or mass 5 without NaN.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Converting a finite particle at rest to theta coordinates gives NaN energy or mass instead of 5.
Vector Version
Version: 1.9.1.dev4+gcaf34cddf from source at caf34cddf9fa2cebc4d9c8c7ed090006ed4687cc, NumPy 2.5.4 and 1.26.4, SymPy 1.14.0
Python Version
Python 3.12.3.
OS / Environment
Linux x86_64.
Describe the bug
Save the script below as repro.py and run:
git clone https://github.com/scikit-hep/vector.git vector
git -C vector checkout --detach caf34cddf9fa2cebc4d9c8c7ed090006ed4687cc
python3 -m venv venv
venv/bin/python -m pip install --only-binary=:all: numpy==2.5.4 sympy==1.14.0 mpmath==1.3.0
venv/bin/python -m pip install -e ./vector
venv/bin/python repro.py
The old NumPy stack fails the same way:
python3 -m venv venv-old
venv-old/bin/python -m pip install --only-binary=:all: numpy==1.26.4 sympy==1.14.0 mpmath==1.3.0
venv-old/bin/python -m pip install -e ./vector
venv-old/bin/python repro.py
Reproducer: CC0.
"""A finite particle at rest acquires NaN energy after coordinate conversion."""
import numpy as np
import sympy as sp
import vector
mass = sp.Integer(5)
momentum2 = sp.Integer(0)**2 + sp.Integer(0)**2 + sp.Integer(0)**2
energy = sp.sqrt(mass**2 + momentum2)
expected_energy = float(energy)
expected_mass = float(sp.sqrt(energy**2 - momentum2))
failures = []
for backend in ("object", "numpy"):
for temporal, value in (("mass", float(mass)), ("E", expected_energy)):
coordinates = dict(px=0.0, py=0.0, pz=0.0, **{temporal: value})
original = (vector.obj(**coordinates) if backend == "object" else
vector.array({k: [v] for k, v in coordinates.items()}))
assert np.allclose(original.E, expected_energy)
assert np.allclose(original.mass, expected_mass)
for method in (("to_pxpythetamass", "to_ptphithetamass") if temporal == "mass"
else ("to_pxpythetaenergy", "to_ptphithetaenergy")):
converted = getattr(original, method)()
actual = float(np.asarray(converted.E if temporal == "mass"
else converted.mass).reshape(-1)[0])
expected = expected_energy if temporal == "mass" else expected_mass
print(f"{backend} {method}: expected {expected}, actual {actual}")
if not np.isclose(actual, expected):
failures.append((backend, method, actual))
assert not failures, f"{len(failures)} coordinate conversions corrupt energy or mass"
All eight conversions should return 5, since the temporal contract says “If t is derived from τ, it is not allowed to be NaN.” Instead every mass layout returns NaN energy, every energy layout returns NaN mass, and the script exits 1.
The theta branches of mag2.py and mag.py divide zero by zero at the theta=0 the conversion generates for the origin.
Any additional but relevant log output
Both backends print this:
to_pxpythetamass: expected 5.0, actual nan
to_ptphithetamass: expected 5.0, actual nan
to_pxpythetaenergy: expected 5.0, actual nan
to_ptphithetaenergy: expected 5.0, actual nan
AssertionError: 8 coordinate conversions corrupt energy or mass
— ChipLab
- Lingua principale
- Python
- Stelle
- 101
- Fork
- 43
- Merge medio
- 4h 11m
- PR unite (30g)
- 6
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di scikit-hep/vector
-
Numba object backend: missing to_2D/to_3D/to_4D, momentum-named conversions, and like()Forse già presa @Thanatos9404 l’ha presa 6 giorni fa. Apertafeature
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
scikit-hep/vector#750 ·
-
Add ability to somehow map field names to coordinate axis names that vector expectsForse di nuovo libera @hjaat l’ha presa 87 giorni fa e non c’è nessuna pull request aperta. Apertafeature
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
scikit-hep/vector#732 · 3 commenti ·
-
feature
Difficoltà 5/5 Più di una settimana Idoneità per principianti 45/100
scikit-hep/vector#731 · 1 commento ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
scikit-hep/vector#711 · 1 commento ·
-
Pyright showing errorsApertabug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
scikit-hep/vector#654 ·
Tutte le issue di scikit-hep/vector
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
zach-blumenfeld/aip#13 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
nathanmarlor/foxess_modbus#1287 ·
I maintainer di solito rispondono entro 4 giorni
-
bug good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
OpenLakeForge/openlakeforge#498 ·
I maintainer di solito rispondono entro 1 giorno
-
good first issue hacktoberfest help wanted python
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 69/100
pollen-robotics/reachy_mini#1493 ·
I maintainer di solito rispondono entro 1 giorno