Skip to content

Commit 953ee55

Browse files
committed
feat: add scalar argument support to searchsorted
1 parent a4c30eb commit 953ee55

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/array_api_stubs/_draft/searching_functions.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def nonzero(x: array, /) -> Tuple[array, ...]:
124124

125125
def searchsorted(
126126
x1: array,
127-
x2: array,
127+
x2: Union[array, int, float],
128128
/,
129129
*,
130130
side: Literal["left", "right"] = "left",
@@ -137,7 +137,7 @@ def searchsorted(
137137
----------
138138
x1: array
139139
input array. **Must** be a one-dimensional array. **Should** have a real-valued data type. If ``sorter`` is ``None``, **must** be sorted in ascending order; otherwise, ``sorter`` **must** be an array of indices that sort ``x1`` in ascending order.
140-
x2: array
140+
x2: Union[array, int, float]
141141
array containing search values. **Should** have a real-valued data type.
142142
side: Literal['left', 'right']
143143
argument controlling which index is returned if a value lands exactly on an edge.
@@ -163,6 +163,7 @@ def searchsorted(
163163
Notes
164164
-----
165165
166+
- If ``x2`` is a scalar value, ``x2`` should be treated as equivalent to a zero-dimensional array having a data type determined according to :ref:`mixing-scalars-and-arrays`.
166167
- For real-valued floating-point arrays, the sort order of NaNs and signed zeros is unspecified and thus implementation-dependent. Accordingly, when a real-valued floating-point array contains NaNs and signed zeros, what constitutes ascending order **may** vary among specification-conforming array libraries.
167168
- While behavior for arrays containing NaNs and signed zeros is implementation-dependent, specification-conforming libraries **should**, however, ensure consistency with ``sort`` and ``argsort`` (i.e., if a value in ``x2`` is inserted into ``x1`` according to the corresponding index in the output array and ``sort`` is invoked on the resultant array, the sorted result **should** be an array in the same order).
168169

0 commit comments

Comments
 (0)