RFC: assignment via integer array indexing
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 30/100
Research direction
Start with the array-api-compat discussion linked in the issue and review the existing array indexing requirements across the named implementations. Define the common assignment semantics for one integer or boolean array index, including the proposed xp.put or equivalent surface; multiple fancy indices remain out of scope. Done means the standard resolves the listed compatibility differences with an agreed specification.
Written by the indexing model from the issue text.
Description
[EDIT] this issue is about the lack of xp.put or equivalent __setitem_ semantics for integar array indices. Read comments below.
[original post]
The current situation when an index is an array of ints or bools is very messy:
- numpy blindly passes every unexpected object it finds to np.asarray, which makes it accept np.ndarray, lists, tuples, but also memoryviews and anything with an
__array__interface - Sparse accepts lists, tuples, or numpy arrays; other sparse arrays don't work
- PyTorch won't accept numpy arrays of unsigned integers
- PyTorch won't accept PyTorch arrays of integers with dtype other than the native int
- JAX won't accept lists or tuples
- dask won't accept tuples
I think the array API standard should define a reasonable common surface.
xref https://github.com/data-apis/array-api-compat/pull/205#discussion_r1861288136
NOTE: the much more complicated case of multiple fancy indices, e.g. a[[0, 1], [1, 2]] is out of scope for this issue.
- 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