fix: convert integer-like objects to python integers in shapes#3662
Merged
ianna merged 4 commits intoscikit-hep:mainfrom Oct 17, 2025
Merged
fix: convert integer-like objects to python integers in shapes#3662ianna merged 4 commits intoscikit-hep:mainfrom
ianna merged 4 commits intoscikit-hep:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files
🚀 New features to boost your workflow:
|
|
The documentation preview is ready to be viewed at http://preview.awkward-array.org.s3-website.us-east-1.amazonaws.com/PR3662 |
pfackeldey
approved these changes
Oct 7, 2025
Collaborator
pfackeldey
left a comment
There was a problem hiding this comment.
We talked about it, and since NumPy always has python ints in the .shape we should do the same (and avoid e.g. numpy scalars).
So, LGTM 👍
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.
The shape of an array should always be composed of python integers in order to avoid problems in
shape_item_as_index.You can construct an array in numpy from numpy integers like
array=np.empty(shape=(np.int32(2), np.int32(3)))butarray.shapeis going to always give you python integers back.In awkward we can construct arrays with shapes that are numpy integers for example when we get the shape from the last element of the offsets like
offsets[-1]. That's going to be anp.integeras it is an element of an array. We should internally force the shapes to be python integers like numpy does when you do.shapeon an array.This PR solves a problem that I ran into from a very complicated dask-awkward workflow with
np.integerplaceholder shapes andshape_item_as_index: