Skip to content

RFC: assignment via integer array indexing #864

Description

@crusaderky

[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 data-apis/array-api-compat#205 (comment)

NOTE: the much more complicated case of multiple fancy indices, e.g. a[[0, 1], [1, 2]] is out of scope for this issue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFCRequest for comments. Feature requests and proposed changes.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions