-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: allow int as placeholder array index type #3341
Conversation
I think this would help for the errors seen in scikit-hep/uproot5#1349 and scikit-hep/coffea#1231 |
This is also maybe worth a discussion on what the policy should be here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this work if it returned
type(self)(self._nplike, (), self._dtype)
instead? That is, a zero-dimensional array, which is more like a scalar than a one-dimensional, length-one array.
Also, the shape
of a PlaceholderArray can be more than 1-dimensional, right? In that case, the return value wouldn't be scalar.
@pfackeldey my feeling here is that we shouldn't allow indexing on placeholders; they should only arise in contexts where indexing hasn't taken place. The motivating issue for this PR is that an operation that does not occur at typetrace time is being performed after typetracing, which therefore performs an operation that wasn't anticipated, and fails. My feeling is that we should watch the array repr to know about placeholders, instead! |
I agree, @agoose77! It would be preferable to just have a better repr. |
I agree! I was already a bit uncomfortable with this PR, my proposal would be to close this one and I'll look into having a better repr. |
FYI: This did solve the problems in scikit-hep/coffea#1231. Just mentioning it here for documentation purposes. |
@ikrommyd the fix for scikit-hep/coffea#1231 is something else I assume. I'll try to understand what goes on there in detail. This PR would allow you to run the reproducer in this issue, but the output array can not be trusted to be a valid array - it was not fixing the root cause of it. |
This PR allows integer indexing on Placeholder arrays, because we know that an int will return a
new_length
of 1. This is a typical operation that happens when calling repr of an awkward-array.This is useful, because instead the repr building for (usually broken) awkward-arrays that contain Placeholder arrays will currently generate a rather cryptic error:
where it's rather unclear what the underlying reason was.
With this PR, the repr can be built, and it shows the missing entries as
??
:which at least gives a better hint on which columns are still placeholders given that they have
??
as entry.This is a problem that typically occurs if the ak.Form of an array has entries without matching buffers.
cc @ikrommyd