Specify that dunder get/set item accepts `SupportsIndex`
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 45/100
- Issue type
- Documentation
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- python
- Domain
- documentation
Research direction
Start with the linked getitem() and setitem() signatures, then compare the index() and boolean array indexing sections. Update the signatures to include typing.SupportsIndex before array and add the proposed note describing which arrays are valid keys; done means the specification clearly documents both cases.
Written by the indexing model from the issue text.
Description
Currently __getitem__()/__setitem__() accept array as keys, which implicitly has to be boolean arrays, or 0d integer arrays i.e. has a working __index__(). The latter is not an obvious concept to grasp, and maybe not even quite specified anyway.
I propose we add the stdlib typing.SupportsIndex to the get/set item signatures, specifically before array. This does add support for any indexable type, but that seems okay, and was the intention anyway when __index__() was proposed in #231. I also think a note would be helpful in regards to what arrays are accepted, e.g.:
keycan only be anarrayif it is valid for boolean array indexing, or supports__index__()i.e. is a 0-dimensional integer array.
cc @kgryte @asmeurer
- Dominant language
- Python
- Stars
- 281
- Forks
- 52
- PR merge metrics
- No merged PRs in 30d
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.
More from data-apis/array-api
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
Maintenance
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
All issues in data-apis/array-api
Similar issues
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
simonw/sqlite-utils#872 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100