@@ -232,9 +232,61 @@ def searchsorted(a, v, side="left", sorter=None):
232232
233233 For full documentation refer to :obj:`numpy.searchsorted`.
234234
235+ Parameters
236+ ----------
237+ a : {dpnp.ndarray, usm_ndarray}
238+ Input 1-D array. If `sorter` is ``None``, then it must be sorted in
239+ ascending order, otherwise `sorter` must be an array of indices that
240+ sort it.
241+ v : {dpnp.ndarray, usm_ndarray, scalar}
242+ Values to insert into `a`.
243+ side : {'left', 'right'}, optional
244+ If ``'left'``, the index of the first suitable location found is given.
245+ If ``'right'``, return the last such index. If there is no suitable
246+ index, return either 0 or N (where N is the length of `a`).
247+ Default is ``'left'``.
248+ sorter : {dpnp.ndarray, usm_ndarray}, optional
249+ Optional 1-D array of integer indices that sort array a into ascending
250+ order. They are typically the result of argsort.
251+ Out of bound index values of `sorter` array are treated using `"wrap"`
252+ mode documented in :py:func:`dpnp.take`.
253+ Default is ``None``.
254+
255+ Returns
256+ -------
257+ indices : dpnp.ndarray
258+ Array of insertion points with the same shape as `v`,
259+ or 0-D array if `v` is a scalar.
260+
261+ See Also
262+ --------
263+ :obj:`dpnp.sort` : Return a sorted copy of an array.
264+ :obj:`dpnp.histogram` : Produce histogram from 1-D data.
265+
266+ Examples
267+ --------
268+ >>> import dpnp as np
269+ >>> a = np.array([11,12,13,14,15])
270+ >>> np.searchsorted(a, 13)
271+ array(2)
272+ >>> np.searchsorted(a, 13, side='right')
273+ array(3)
274+ >>> v = np.array([-10, 20, 12, 13])
275+ >>> np.searchsorted(a, v)
276+ array([0, 5, 1, 2])
277+
235278 """
236279
237- return call_origin (numpy .where , a , v , side , sorter )
280+ usm_a = dpnp .get_usm_ndarray (a )
281+ if dpnp .isscalar (v ):
282+ usm_v = dpt .asarray (v , sycl_queue = a .sycl_queue , usm_type = a .usm_type )
283+ else :
284+ usm_v = dpnp .get_usm_ndarray (v )
285+
286+ usm_sorter = None if sorter is None else dpnp .get_usm_ndarray (sorter )
287+ return dpnp_array ._create_from_usm_ndarray (
288+ dpt .searchsorted (usm_a , usm_v , side = side , sorter = usm_sorter )
289+ )
238290
239291
240292def where (condition , x = None , y = None , / ):
0 commit comments