Repository navigation
feat: implement to_2D/3D/4D, momentum conversions, and like in numba object backend (#750) - #756
Open
sumitsaraswat362 wants to merge 1 commit into
Conversation
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.
Fixes #750.
Description
In the Numba Object backend, several coordinate conversions and helper methods available on the Python Vector objects were missing corresponding
@numba.extending.overload_methodregistrations, causing Numba JIT typing failures.This PR implements the missing overload dispatchers in
src/vector/backends/_numba_object.py:to_2D,to_3D,to_4D):@numba.extending.overload_methodforto_2D,to_3D, andto_4Ddirectly acrossVectorObject2DType,VectorObject3DType, andVectorObject4DType, mapping to the correspondingto_Vector*Dhandlers.add_coordinate_change, registered the corresponding momentum method name alongside the generic method name (e.g.to_pxpy,to_ptphi,to_pxpypz,to_pxpypzenergy,to_ptphietamass, etc.), reusing the exact coordinate transformation closure.like(other)dispatch:@numba.extending.overload_methodforlikeon 2D, 3D, and 4D vector types with typing-time inspection onother:VectorObject2DType-> dispatches tov.to_Vector2D()VectorObject3DType-> dispatches tov.to_Vector3D()VectorObject4DType-> dispatches tov.to_Vector4D()numba.core.errors.TypingErrorat typing time.Testing
tests/backends/test_numba_object.pycovering:to_2D,to_3D,to_4Ddimension changes inside JIT functions.like()conversions matching 2D, 3D, and 4D vector targets.numba.core.errors.TypingError.ruff.