Skip to content
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

Boolean filters with axes labels which are a subset of array axes labels is silently broken #1085

Open
gdementen opened this issue Oct 11, 2023 · 0 comments

Comments

@gdementen
Copy link
Contributor

>>> arr = ndtest((2, 4))
>>> f = arr > 2
a\b     b0     b1     b2    b3
 a0  False  False  False  True
 a1   True   True   True  True
>>> arr[f]
a_b  a0_b3  a1_b0  a1_b1  a1_b2  a1_b3
         3      4      5      6      7
>>> f2 = f['b0,b2,b3']
>>> f2
a\b     b0     b2    b3
 a0  False  False  True
 a1   True   True  True
>>> arr[f2]
a_b\b  b3  b0  b2  b3
a0_b3   3   0   2   3
a1_b0   7   4   6   7
a1_b2   7   4   6   7
a1_b3   7   4   6   7

This is complete junk.

I see three options going forward:

  1. raise an error when common axes between filter.axes and array.axes are not equal
  2. behave as if the filter was False where not present (possibly check that filter.axes are subsets of array.axes). I think that numpy previously had the equivalent of this behavior but no longer support this.
  3. align filter.axes with array.axes, so that if filter.axes has more axes (unsure what happens in this case currently) or more labels on common axes, the result has more labels too.

Currently, I think it would be best to implement 1, until we implement align by default for all operations, in which case 3. would make more sense. I might revise my judgment on option 2 if it turns out absolutely necessary to solve #1084.

FWIW, I don't think this is worth blocker priority even though this is a "silent" failure because the extra "combined" axis would be very quickly spotted by users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant