Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
RohitSgh committed Sep 9, 2023
1 parent ba9712f commit 8c53c42
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,28 @@ def _nextafter(
return ivy.nextafter(x1, x2, out=out)


@handle_numpy_out
@handle_numpy_dtype
@to_ivy_arrays_and_back
@handle_numpy_casting
@from_zero_dim_arrays_to_scalar
def _signbit(
x,
/,
out=None,
*,
where=True,
casting="same_kind",
order="K",
dtype=None,
subok=True,
):
if dtype is None:
dtype = ivy.dtype(x)
zero = ivy.zeros_like(x, dtype=dtype)
return ivy.less(x, zero)


@handle_numpy_out
@handle_numpy_dtype
@to_ivy_arrays_and_back
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,54 @@ def test_numpy_nextafter(
)


# signbit
@handle_frontend_test(
fn_tree="numpy.signbit",
dtypes_values_casting=np_frontend_helpers.dtypes_values_casting_dtype(
arr_func=[
lambda: helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("float"),
num_arrays=1,
)
],
),
where=np_frontend_helpers.where(),
number_positional_args=np_frontend_helpers.get_num_positional_args_ufunc(
fn_name="signbit"
),
)
def test_numpy_signbit(
dtypes_values_casting,
where,
frontend,
test_flags,
backend_fw,
fn_tree,
on_device,
):
input_dtypes, xs, casting, dtype = dtypes_values_casting
where, input_dtypes, test_flags = np_frontend_helpers.handle_where_and_array_bools(
where=where,
input_dtype=input_dtypes,
test_flags=test_flags,
)
np_frontend_helpers.test_frontend_function(
input_dtypes=input_dtypes,
frontend=frontend,
test_flags=test_flags,
backend_to_test=backend_fw,
fn_tree=fn_tree,
on_device=on_device,
x=xs[0],
out=None,
where=where,
casting=casting,
order="K",
dtype=dtype,
subok=True,
)


# spacing
@handle_frontend_test(
fn_tree="numpy.spacing",
Expand Down

0 comments on commit 8c53c42

Please sign in to comment.