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

Allowing None for indexing to add an axis #360

Closed
jakirkham opened this issue Jan 6, 2022 · 3 comments · Fixed by #408
Closed

Allowing None for indexing to add an axis #360

jakirkham opened this issue Jan 6, 2022 · 3 comments · Fixed by #408
Labels
API extension Adds new functions or objects to the API. topic: Indexing Array indexing.

Comments

@jakirkham
Copy link
Member

In many array libraries today, one can use None when indexing to add a singleton dimension like np.newaxis. Would be good to support in the standard as well.

@rgommers
Copy link
Member

Thanks @jakirkham. I think this one fell through the cracks so far. x[:, None, :] is equivalent to expand_dims(x, axis=1), the latter is in the standard so at least there's an easy alternative.

I just tested and it looks like every library supports indexing with None with consistent behavior. So we should just add this I think.

@asmeurer
Copy link
Member

We should probably also add newaxis = None to the namespace.

@kgryte
Copy link
Contributor

kgryte commented Mar 24, 2022

I've opened #408 which adds support for expanding dimensions via None.

@kgryte kgryte added the API extension Adds new functions or objects to the API. label Mar 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API extension Adds new functions or objects to the API. topic: Indexing Array indexing.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants