Skip to content

Implement consistent __setitem__ between numpy/cupy.ndarrays and VirtualArrays #3444

Open
@ikrommyd

Description

@ikrommyd

Right now VirtualArray_instance[slice] = Other_VirtualArray_instance works but it's not clear to me why.
Also numpy.ndarray_instance[slice] = VirtualArray_instance works but not cupy.ndarray_instance[slice] = VirtualArray_instance. The latter fails with

File cupy/_core/core.pyx:1641, in cupy._core.core._ndarray_base.__setitem__()

File cupy/_core/_routines_indexing.pyx:51, in cupy._core._routines_indexing._ndarray_setitem()

File cupy/_core/_routines_indexing.pyx:1017, in cupy._core._routines_indexing._scatter_op()

File cupy/_core/core.pyx:789, in cupy._core.core._ndarray_base.fill()

File cupy/_core/core.pyx:1293, in cupy._core.core._ndarray_base.__nonzero__()

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

see cupy/cupy#9089.

All that should be made more consistent because it's used in the codebase like offsets[:-1] = starts for example and offsets and starts can be either np/cp.ndarray or VirtualArray in such cases.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions