8000 fix: address incorrect boundary conditions in `searchsorted` by kgryte · Pull Request #898 · data-apis/array-api · GitHub
[go: up one dir, main page]

Skip to content

fix: address incorrect boundary conditions in searchsorted #898

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 17, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Matt Haberland <mhaberla@calpoly.edu>
  • Loading branch information
kgryte and mdhaber authored Feb 17, 2025
commit fc4e01d85fec23625afaa40037398c7f489d7a54
10 changes: 6 additions & 4 deletions src/array_api_stubs/_2023_12/searching_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,13 @@ def searchsorted(
side: Literal['left', 'right']
argument controlling which index is returned if a value lands exactly on an edge.

Let ``x2`` be an array of rank ``N`` where ``v`` is an individual element given by ``v = x2[n,m,...,j]``.
Let ``v`` be an element of ``x2`` given by ``v = x2[j]``, where ``j`` refers to a valid scalar or tuple index.

- 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]``.
- If ``v`` is less than all elements in ``x1``, then ``out[j]`` must be ``0``.
- If ``v`` is greater than all elements in ``x1``, then ``out[j]`` must be ``M``, where ``M`` is the number of elements in ``x1``.
- Otherwise, each returned index ``i = out[j]`` must satisfy an index condition:
- If ``side == 'left'``, then ``x1[i-1] < v <= x1[i]``.
- If ``side == 'right'``, then ``x1[i-1] <= v < x1[i]``.

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