Skip to content

Commit e4f2b1d

Browse files
committed
Add a note stating that iteration is defined for 1-D arrays not other arrays
Fixes #818.
1 parent 122c99a commit e4f2b1d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/array_api_stubs/_draft/array_object.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,10 @@ def __getitem__(
629629
-------
630630
out: array
631631
an array containing the accessed value(s). The returned array must have the same data type as ``self``.
632+
633+
.. note::
634+
When ``__getitem__`` is defined on an object, Python will automatically define iteration (i.e., the behavior from ``iter(x)``) as ``x[0]``, ``x[1]``, .... This can also be implemented directly by defining ``__iter__``. Therefore, for 1-D arrays, iteration should produce the sequence ``x[0]``, ``x[1]``, ... of 0-D arrays. Iteration behavior for arrays with more than one dimension is unspecified and thus implementation-defined.
635+
632636
"""
633637

634638
def __gt__(self: array, other: Union[int, float, array], /) -> array:

0 commit comments

Comments
 (0)