Repository navigation
Conversation
…sionError On the object backend, rapidity computed (t + z) / (t - z) with Python scalars, so E == pz raised ZeroDivisionError while the mirror case along -z returned -inf and the NumPy backend returned inf. Use lib.true_divide so all backends give +inf, and add true_divide to the SymPy lib shim (plain division, so the symbolic expression is unchanged).
Member
|
Hi @syahra712, thanks for opening the PR. Sorry, I will not get any time in the next couple of months to review this. We will finalize an AI_POLICY (#761) soon. Could you please add AI usage to the PR description. Another maintainer will take a look before me if they have spare time :) |
Author
|
Thanks @Saransh-cpp, no problem at all. I've added an "AI usage" section to the description, and I'll follow the AI_POLICY in #761 once it's finalised. |
4 of 6 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
On the object backend,
rapidityof a massless vector along the beam axis depends on its direction:_compute/lorentz/rapidity.pycomputes0.5 * lib.log((t + z) / (t - z)). With the object backend,tandzare plain Python numbers, soE == pzhits Python's float division and raises. With-z, the numerator is zero, so the division is fine andlib.log(0)gives-inf. NumPy arrays already returninf. This shows up with incoming beam particles in event records, which havepT = 0and|pz| = E.The fix uses
lib.true_divide(t + z, t - z), so every backend returns+infhere. It also addstrue_divideto the SymPy_libshim as plain division, so the symbolic expression is the same as before and the existing SymPy tests that compare exact expressions are unchanged.I added
test_massless_along_zintests/compute/lorentz/test_rapidity.py, covering both directions with int and floatpz. It fails onmainwithZeroDivisionErrorand passes with this change.Checklist
pytest tests: 4862 passed. The one failure,test_issue_463, also fails onmainin my environment because of floating-point precision. numba isn't available on my machine, so I also ran the numba-object and compute tests in a Linux container: 725 passed. Undernjit, rapidity now givesinf/-inf.)AI usage
This PR was prepared with Claude Code (Anthropic's Claude). It was used to trace the bug through
_compute/lorentz/rapidity.py, write the fix and the new test, and run the test suites listed in the checklist above. I directed the work and take responsibility for the change, and I'm happy to explain or rework any part of it.