@@ -149,6 +149,24 @@ def meshgrid(*arrays: Array, indexing: Literal['xy', 'ij'] = 'xy') -> tuple[Arra
149149 return tuple (cp .meshgrid (* arrays , indexing = indexing ))
150150
151151
152+ # Match https://github.com/cupy/cupy/pull/9512/ until cupy v14 is the minimum
153+ # supported version
154+ def searchsorted (
155+ x1 : Array ,
156+ x2 : Array | int | float ,
157+ / ,
158+ * ,
159+ side : Literal ['left' , 'right' ] = 'left' ,
160+ sorter : Array | None = None
161+ ) -> Array :
162+ if not isinstance (x2 , cp .ndarray ):
163+ if not isinstance (x2 , int | float | complex ):
164+ raise NotImplementedError (
165+ 'Only python scalars or ndarrays are supported for x2' )
166+ x2 = cp .asarray (x2 )
167+ return cp .searchsorted (x1 , x2 , side , sorter )
168+
169+
152170# These functions are completely new here. If the library already has them
153171# (i.e., numpy 2.0), use the library version instead of our wrapper.
154172if hasattr (cp , 'vecdot' ):
@@ -172,7 +190,9 @@ def meshgrid(*arrays: Array, indexing: Literal['xy', 'ij'] = 'xy') -> tuple[Arra
172190 'bitwise_invert' , 'bitwise_right_shift' ,
173191 'bool' , 'concat' , 'count_nonzero' , 'pow' , 'sign' ,
174192 'ceil' , 'floor' , 'trunc' , 'take_along_axis' ,
175- 'broadcast_arrays' , 'meshgrid' ]
193+ 'broadcast_arrays' , 'meshgrid' ,
194+ 'searchsorted' ,
195+ ]
176196
177197
178198def __dir__ () -> list [str ]:
0 commit comments