diff --git a/ivy/functional/frontends/numpy/ndarray/ndarray.py b/ivy/functional/frontends/numpy/ndarray/ndarray.py index 4ef0ba6fc097a..9320ce4b6acbd 100644 --- a/ivy/functional/frontends/numpy/ndarray/ndarray.py +++ b/ivy/functional/frontends/numpy/ndarray/ndarray.py @@ -128,3 +128,6 @@ def ravel(self, order="C"): def repeat(self, repeats, axis=None): return np_frontend.repeat(self.data, repeats, axis=axis) + + def searchsorted(self, v, side='left', sorter=None): + return np_frontend.searchsorted(self.data, v, side=side, sorter=sorter) diff --git a/ivy_tests/test_ivy/test_frontends/test_numpy/test_ndarray/test_ndarray.py b/ivy_tests/test_ivy/test_frontends/test_numpy/test_ndarray/test_ndarray.py index 858b46e533045..4f609262362ba 100644 --- a/ivy_tests/test_ivy/test_frontends/test_numpy/test_ndarray/test_ndarray.py +++ b/ivy_tests/test_ivy/test_frontends/test_numpy/test_ndarray/test_ndarray.py @@ -799,3 +799,48 @@ def test_numpy_instance_repeat( class_name="ndarray", method_name="repeat", ) + + +@handle_cmd_line_args +@given( + dtype_x_v=helpers.dtype_and_values( + available_dtypes=helpers.get_dtypes("signed_integer"), + min_num_dims=1, + max_num_dims=1, + num_arrays=2, + ), + side=st.sampled_from(["left", "right"]), + num_positional_args_method=helpers.num_positional_args( + fn_name="ivy.functional.frontends.numpy.ndarray.searchsorted" + ), +) +def test_numpy_instance_searchsorted( + dtype_x_v, + side, + as_variable, + num_positional_args_method, + native_array, +): + input_dtype, xs = dtype_x_v + + helpers.test_frontend_method( + input_dtypes_init=input_dtype, + input_dtypes_method=input_dtype, + as_variable_flags_init=as_variable, + num_positional_args_init=1, + num_positional_args_method=num_positional_args_method, + native_array_flags_init=native_array, + as_variable_flags_method=as_variable, + native_array_flags_method=native_array, + all_as_kwargs_np_init={ + "data": xs[0], + }, + all_as_kwargs_np_method={ + "v": xs[1], + "side": side, + "sorter": np.argsort(xs[0]), + }, + frontend="numpy", + class_name="ndarray", + method_name="searchsorted", + )