improve `ndarray.__getitem__` with rank-typing
Open
@jorenham is already working on this.
Since May 15, 2025.
numpy.ndarray
stubs: Enhancement
topic: shape-typing
- Dominant language
- Python
- Stars
- 79
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Description
It's a very complicated method signature, e.g.
_[()]returnsSelfif 1d+, otherwise (if 0d) returns its scalar type_[int]returnsSelf[DTypeT, ShapeT[1:]]if 1d+, otherwise (if 0d) returns its scalar type_[int, int]returnsSelf[DTypeT, ShapeT[1:]]if 1d+, otherwise (if 0d) returns its scalar type- ...
_[None]returnsarray[DTypeT, (int, *ShapeT)]_[None, None]returnsarray[DTypeT, (int, int, *ShapeT)]- ...
_[slice | array-indexer]returnsSelffor 1d+, otherwise rejects_[slice | array-indexer, slice | array-indexer]returnsSelffor 2d+, otherwise rejects- ...
_[...]returnsSelffor 0d+
almost all possible combinations are also valid 😅
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.