Skip to content

Commit d64de1f

Browse files
committed
stubs: clarify that indexing/setitem is unspecified across devices
1 parent e531085 commit d64de1f

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/array_api_stubs/_draft/array_object.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,10 @@ def __getitem__(
669669
- See :ref:`indexing` for details on supported indexing semantics.
670670
- When ``__getitem__`` is defined on an object, Python will automatically define iteration (i.e., the behavior from ``iter(x)``) as ``x[0]``, ``x[1]``, ..., ``x[N-1]``. This can also be implemented directly by defining ``__iter__``. Therefore, for a one-dimensional array ``x``, iteration should produce a sequence of zero-dimensional arrays ``x[0]``, ``x[1]``, ..., ``x[N-1]``, where ``N`` is the number of elements in the array. Iteration behavior for arrays having zero dimensions or more than one dimension is unspecified and thus implementation-defined.
671671
672+
.. note::
673+
When ``key`` contains integer arrays on a device different from the device of ``self``, the
674+
behavior is unspecified and thus implementation-defined.
675+
672676
.. versionchanged:: 2024.12
673677
Clarified that iteration is defined for one-dimensional arrays.
674678
"""
@@ -1154,6 +1158,10 @@ def __setitem__(
11541158
.. note::
11551159
Indexing semantics when ``key`` is an integer array or a tuple of integers and integer arrays is currently unspecified and thus implementation-defined. This will be revisited in a future revision of this standard.
11561160
1161+
.. note::
1162+
When ``value`` is an array on a device different from the device of ``self``, the
1163+
behavior is unspecified and thus implementation-defined.
1164+
11571165
- Setting array values must not affect the data type of ``self``.
11581166
- ``value`` must be promoted to the data type of ``self`` according to :ref:`type-promotion`. If this is not supported according to :ref:`type-promotion`, behavior is unspecified and thus implementation-defined.
11591167

0 commit comments

Comments
 (0)