At-rest theta conversions return NaN energy or mass
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 76/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Python
- Star
- 102
- Fork
- 45
- Merge trung bình
- 4 giờ 11 phút
- Pull request đã merge (30 ngày)
- 6
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của scikit-hep/vector
-
Numba object backend: missing to_2D/to_3D/to_4D, momentum-named conversions, and like()Có thể đã có người làm @Thanatos9404 đã nhận 9 ngày trước. Đang mởfeature
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
scikit-hep/vector#750 · 1 bình luận ·
-
Add ability to somehow map field names to coordinate axis names that vector expectsCó thể làm lại được @hjaat đã nhận 90 ngày trước và không có pull request nào đang mở. Đang mởfeature
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
scikit-hep/vector#732 · 3 bình luận ·
-
feature
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 45/100
scikit-hep/vector#731 · 1 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
scikit-hep/vector#711 · 1 bình luận ·
-
Pyright showing errorsĐang mởbug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
scikit-hep/vector#654 ·
Tất cả issue của scikit-hep/vector
Issue tương tự
-
Project submission:Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
slavakurilyak/awesome-ai-agents#845 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
tests: pin that the atomic writers in utils/paths.py stage the temporary file in the target's directoryCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởdifficulty:2 enhancement good first issue
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 92/100
MakazhanAlpamys/Soup#2178 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] dcg.waggr permutation p-values are folded twice, so near-zero scores get the smallest p-valuesĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
scverse/rapids-singlecell#854 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Slang input: int8_t4_packed and uint8_t4_packed are copied into CrossGLCó thể đã có người làm @ninglinLiu đã nhận hôm nay. Đang mởarea:frontend backend:slang bug direction:input
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
random_elements(unique=True) on an OrderedDict: ZeroDivisionError once only zero weights remain, AssertionError with use_weighting=FalseCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 13 ngày