8000 improve `ndarray.__getitem__` with rank-typing · Issue #557 · numpy/numtype · GitHub
[go: up one dir, main page]

Skip to content

improve ndarray.__getitem__ with rank-typing #557

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

Open
jorenham opened this issue May 15, 2025 · 0 comments
Open

improve ndarray.__getitem__ with rank-typing #557

jorenham opened this issue May 15, 2025 · 0 comments

Comments

@jorenham
Copy link
Member
jorenham commented May 15, 2025

It's a very complicated method signature, e.g.

  • _[()] returns Self if 1d+, otherwise (if 0d) returns its scalar type
  • _[int] returns Self[DTypeT, ShapeT[1:]] if 1d+, otherwise (if 0d) returns its scalar type
  • _[int, int] returns Self[DTypeT, ShapeT[1:]] if 1d+, otherwise (if 0d) returns its scalar type
  • ...
  • _[None] returns array[DTypeT, (int, *ShapeT)]
  • _[None, None] returns array[DTypeT, (int, int, *ShapeT)]
  • ...
  • _[slice | array-indexer] returns Self for 1d+, otherwise rejects
  • _[slice | array-indexer, slice | array-indexer] returns Self for 2d+, otherwise rejects
  • ...
  • _[...] returns Self for 0d+

almost all possible combinations are also valid 😅

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
0