-
Notifications
You must be signed in to change notification settings - Fork 52
Closed
Labels
bugSomething isn't working.Something isn't working.
Milestone
Description
The "index conditions" of searchsorted, which are documented in the description of the side argument, are:
In "Let x be an array of rank N":
- I think
xis supposed to bex2, and - it looks like
Nis not supposed to be theNdefined later as the "number of elements inx1".
Also, it looks like these conditions don't cover the edge cases where either
side='left'andvexceeds all elements ofx1orside='right'andvis less than all elements ofx1:
import array_api_strict as xp
x1 = xp.asarray([1, 2, 3])
# `side='left'` and `v` exceeds all elements of `x1` or
x2 = xp.asarray(4)
i = xp.searchsorted(x1, x2, side='left')
x1[i] # IndexError: index 3 is out of bounds for axis 0 with size 3
# `side='right'` and `v` is less than all elements of `x1`:
x2 = xp.asarray(0)
i = xp.searchsorted(x1, x2, side='right')
x1[i-1] < x1[i]
# Array(False, dtype=array_api_strict.bool)I think complete index conditions, which describe the out mathematically, would be helpful! Then, perhaps the details of the side argument could be restricted to what happens when v "lands exactly on an edge", which I interpret to mean "is equal to an element of x1": If side == 'left', then v = x1[i]; if side == 'right', then v = x1[i-1].
Metadata
Metadata
Assignees
Labels
bugSomething isn't working.Something isn't working.
