Skip to content

Commit cd531fe

Browse files
committed
docs: move notes below the fold and highlight RFC 2119 keywords
Ref: #397
1 parent 3267c18 commit cd531fe

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/array_api_stubs/_draft/indexing_functions.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,24 @@ def take(x: array, indices: array, /, *, axis: Optional[int] = None) -> array:
1010
Parameters
1111
----------
1212
x: array
13-
input array. Should have one or more dimensions (axes).
13+
input array. **Should** have one or more axes.
1414
indices: array
15-
array indices. The array must be one-dimensional and have an integer data type. If an index is negative, the function must determine the element to select along a specified axis (dimension) by counting from the last element (where ``-1`` refers to the last element).
15+
array indices. The array **must** be one-dimensional and have an integer data type. If an index is negative, the function **must** determine the element to select along a specified axis by counting from the last element (where ``-1`` refers to the last element).
1616
axis: Optional[int]
17-
axis over which to select values. If ``axis`` is negative, the function must determine the axis along which to select values by counting from the last dimension (where ``-1`` refers to the last dimension).
17+
axis over which to select values. If ``axis`` is negative, the function **must** determine the axis along which to select values by counting from the last axis (where ``-1`` refers to the last axis).
1818
19-
If ``x`` is a one-dimensional array, providing an ``axis`` is optional; however, if ``x`` has more than one dimension, providing an ``axis`` is required.
19+
If ``x`` is a one-dimensional array, providing an ``axis`` **must** be optional; however, if ``x`` has more than one axis, providing an ``axis`` **must** be required.
2020
2121
Returns
2222
-------
2323
out: array
24-
an array having the same data type as ``x``. The output array must have the same rank (i.e., number of dimensions) as ``x`` and must have the same shape as ``x``, except for the axis specified by ``axis`` whose size must equal the number of elements in ``indices``.
24+
an array having the same data type as ``x``. The output array **must** have the same number of axes as ``x`` and **must** have the same shape as ``x``, except for the axis specified by ``axis`` whose size **must** equal the number of elements in ``indices``.
2525
2626
Notes
2727
-----
2828
29-
- Conceptually, ``take(x, indices, axis=3)`` is equivalent to ``x[:,:,:,indices,...]``; however, explicit indexing via arrays of indices is not currently supported in this specification due to concerns regarding ``__setitem__`` and array mutation semantics.
30-
- This specification does not require bounds checking. The behavior for out-of-bounds indices is left unspecified.
29+
- This specification does not require bounds checking. The behavior for out-of-bounds indices is unspecified and thus implementation-defined.
30+
3131
- When ``x`` is a zero-dimensional array, behavior is unspecified and thus implementation-defined.
3232
3333
.. versionadded:: 2022.12
@@ -50,21 +50,21 @@ def take_along_axis(x: array, indices: array, /, *, axis: int = -1) -> array:
5050
Parameters
5151
----------
5252
x: array
53-
input array. Must be compatible with ``indices``, except for the axis (dimension) specified by ``axis`` (see :ref:`broadcasting`).
53+
input array. **Must** be compatible with ``indices``, except for the axis specified by ``axis`` (see :ref:`broadcasting`).
5454
indices: array
55-
array indices. Must have the same rank (i.e., number of dimensions) as ``x``. If an index is negative, the function must determine the element to select along a specified axis (dimension) by counting from the last element (where ``-1`` refers to the last element).
55+
array indices. **Must** have the same number of axes as ``x`` and **must** be compatible with ``x``, except for the axis specified by ``axis`` (see :ref:`broadcasting`). If an index is negative, the function **must** determine the element to select along a specified axis by counting from the last element (where ``-1`` refers to the last element).
5656
axis: int
57-
axis along which to select values. If ``axis`` is negative, the function must determine the axis along which to select values by counting from the last dimension (where ``-1`` refers to the last dimension). Default: ``-1``.
57+
axis along which to select values. A valid axis **must** be an integer on the interval ``[-N, N)``, where ``N`` is the number of axes in ``x``. If an axis is specified as a negative integer, the function **must** determine the axis along which to perform the operation by counting backward from the last axis (where ``-1`` refers to the last axis). If provided an invalid axis, the function **must** raise an exception. Default: ``-1``.
5858
5959
Returns
6060
-------
6161
out: array
62-
an array having the same data type as ``x``. Must have the same rank (i.e., number of dimensions) as ``x`` and must have a shape determined according to :ref:`broadcasting`, except for the axis (dimension) specified by ``axis`` whose size must equal the size of the corresponding axis (dimension) in ``indices``.
62+
an array containing elements from ``x``. The returned array **must** have the same data type as ``x``. The returned array **must** have the same number of axes as ``x`` and **must** have a shape determined according to :ref:`broadcasting`, except for the axis specified by ``axis`` whose size **must** equal the size of the corresponding axis in ``indices``.
6363
6464
Notes
6565
-----
6666
67-
- This specification does not require bounds checking. The behavior for out-of-bounds indices is left unspecified.
67+
- This specification does not require bounds checking. The behavior for out-of-bounds indices is unspecified and thus implementation-defined.
6868
6969
.. versionadded:: 2024.12
7070
"""

0 commit comments

Comments
 (0)