You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 x is supposed to be x2, and
it looks like N is not supposed to be the N defined later as the "number of elements in x1".
Also, it looks like these conditions don't cover the edge cases where either
side='left' and v exceeds all elements of x1 or
side='right' and v is less than all elements of x1:
importarray_api_strictasxpx1=xp.asarray([1, 2, 3])
# `side='left'` and `v` exceeds all elements of `x1` orx2=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].
The text was updated successfully, but these errors were encountered:
The "index conditions" of
searchsorted
, which are documented in the description of theside
argument, are:In "Let
x
be an array of rankN
":x
is supposed to bex2
, andN
is not supposed to be theN
defined later as the "number of elements inx1
".Also, it looks like these conditions don't cover the edge cases where either
side='left'
andv
exceeds all elements ofx1
orside='right'
andv
is less than all elements ofx1
:I think complete index conditions, which describe the
out
mathematically, would be helpful! Then, perhaps the details of theside
argument could be restricted to what happens whenv
"lands exactly on an edge", which I interpret to mean "is equal to an element ofx1
": Ifside == 'left'
, thenv = x1[i]
; ifside == 'right'
, thenv = x1[i-1]
.The text was updated successfully, but these errors were encountered: