Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions src/array_api_stubs/_2023_12/searching_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,11 @@ def searchsorted(
side: Literal['left', 'right']
argument controlling which index is returned if a value lands exactly on an edge.

Let ``x`` be an array of rank ``N`` where ``v`` is an individual element given by ``v = x2[n,m,...,j]``.
Let ``x2`` be an array of rank ``N`` where ``v`` is an individual element given by ``v = x2[n,m,...,j]``.

If ``side == 'left'``, then

- each returned index ``i`` must satisfy the index condition ``x1[i-1] < v <= x1[i]``.
- if no index satisfies the index condition, then the returned index for that element must be ``0``.

Otherwise, if ``side == 'right'``, then

- each returned index ``i`` must satisfy the index condition ``x1[i-1] <= v < x1[i]``.
- if no index satisfies the index condition, then the returned index for that element must be ``N``, where ``N`` is the number of elements in ``x1``.
- If ``v`` is less than all elements in ``x1``, then the returned index for that element must be ``0``.
- If ``v`` is greater than all elements in ``x1``, then the returned index for that element must be ``M``, where ``M`` is the number of elements in ``x1``.
- Otherwise, if ``side == 'left'``, then each returned index ``i`` must satisfy the index condition ``x1[i-1] < v <= x1[i]``. If ``side == 'right'``, then each returned index ``i`` must satisfy the index condition ``x1[i-1] <= v < x1[i]``.

Default: ``'left'``.
sorter: Optional[array]
Expand Down
14 changes: 4 additions & 10 deletions src/array_api_stubs/_draft/searching_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,11 @@ def searchsorted(
side: Literal['left', 'right']
argument controlling which index is returned if a value lands exactly on an edge.

Let ``x`` be an array of rank ``N`` where ``v`` is an individual element given by ``v = x2[n,m,...,j]``.
Let ``x2`` be an array of rank ``N`` where ``v`` is an individual element given by ``v = x2[n,m,...,j]``.

If ``side == 'left'``, then

- each returned index ``i`` must satisfy the index condition ``x1[i-1] < v <= x1[i]``.
- if no index satisfies the index condition, then the returned index for that element must be ``0``.

Otherwise, if ``side == 'right'``, then

- each returned index ``i`` must satisfy the index condition ``x1[i-1] <= v < x1[i]``.
- if no index satisfies the index condition, then the returned index for that element must be ``N``, where ``N`` is the number of elements in ``x1``.
- If ``v`` is less than all elements in ``x1``, then the returned index for that element must be ``0``.
- If ``v`` is greater than all elements in ``x1``, then the returned index for that element must be ``M``, where ``M`` is the number of elements in ``x1``.
- Otherwise, if ``side == 'left'``, then each returned index ``i`` must satisfy the index condition ``x1[i-1] < v <= x1[i]``. If ``side == 'right'``, then each returned index ``i`` must satisfy the index condition ``x1[i-1] <= v < x1[i]``.

Default: ``'left'``.
sorter: Optional[array]
Expand Down