Skip to content

Clarify that boolean array indexing requirements #164

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

Merged

Conversation

asmeurer
Copy link
Member

We only require that boolean array indexing be supported when the array is the
sole index. The previous text was ambiguous, and could be read as supporting
boolean arrays plus other non-array indices as part of a larger
multidimensional index. However, this is complicated in general, as it can
lead to some corner cases. See the discussion in #84.

With that being said, it is still an open discussion whether we should allow
some subset of boolean array indices along with other non-array indices in the
same index. I believe regardless, what we do not want to allow is:

  • multiple boolean arrays (this requires broadcasting semantics, which are
    confusing for boolean arrays)
  • boolean arrays and integers separated by a non-integer index (for example
    a[b, :, 0] where b is a boolean array). This is the corner case currently
    implemented by NumPy which we want to avoid for the standard.

We only require that boolean array indexing be supported when the array is the
sole index. The previous text was ambiguous, and could be read as supporting
boolean arrays plus other non-array indices as part of a larger
multidimensional index. However, this is complicated in general, as it can
lead to some corner cases. See the discussion in data-apis#84.

With that being said, it is still an open discussion whether we should allow
some subset of boolean array indices along with other non-array indices in the
same index. I believe regardless, what we do not want to allow is:

- multiple boolean arrays (this requires broadcasting semantics, which are
  confusing for boolean arrays)
- boolean arrays and integers separated by a non-integer index (for example
  a[b, :, 0] where b is a boolean array). This is the corner case currently
  implemented by NumPy which we want to avoid for the standard.
Copy link
Contributor

@kgryte kgryte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks, @asmeurer!

Copy link
Member

@rgommers rgommers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a useful textual clarification for what the current version of the text aims to express, so let's merge it.

With that being said, it is still an open discussion whether we should allow
some subset of boolean array indices along with other non-array indices in the
same index. I believe regardless, what we do not want to allow is:

Agreed. Let's continue that conversation on gh-84.

@rgommers rgommers merged commit 38a2478 into data-apis:main Apr 19, 2021
@rgommers
Copy link
Member

Thanks @asmeurer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Maintenance Bug fix, typo fix, or general maintenance. Narrative Content Narrative documentation content.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants