Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add angle function to NumPy Frontend #12552

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
)


@to_ivy_arrays_and_back
def angle(z, deg=False):
angle = ivy.angle(z, deg=deg)
if deg and len(z.shape) == 0:
angle = ivy.astype(angle, ivy.float64)
return angle


@to_ivy_arrays_and_back
def _imag(val):
return ivy.imag(val)
Expand Down
4 changes: 2 additions & 2 deletions ivy/functional/ivy/experimental/elementwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,8 +676,8 @@ def angle(
-------
ret
Returns an array of angles for each complex number in the input.
If def is False(default), angle is calculated in radian and if
def is True, then angle is calculated in degrees.
If deg is False(default), angle is calculated in radian and if
deg is True, then angle is calculated in degrees.

Examples
--------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,34 @@
from ivy_tests.test_ivy.helpers import handle_frontend_test


# angle
@handle_frontend_test(
fn_tree="numpy.angle",
dtype_and_x=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("complex")
),
deg=st.booleans(),
)
def test_numpy_angle(
dtype_and_x,
frontend,
test_flags,
fn_tree,
on_device,
deg,
):
input_dtypes, x = dtype_and_x
helpers.test_frontend_function(
input_dtypes=input_dtypes,
frontend=frontend,
test_flags=test_flags,
fn_tree=fn_tree,
on_device=on_device,
z=x[0],
deg=deg,
)


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