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 numpy.real to Numpy frontend #10483

Merged
merged 14 commits into from
Feb 23, 2023
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
2 changes: 2 additions & 0 deletions ivy/functional/frontends/numpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ def promote_types_of_numpy_inputs(

from ivy.functional.frontends.numpy.mathematical_functions.handling_complex_numbers import (
_imag,
_real,
)

from ivy.functional.frontends.numpy.mathematical_functions.hyperbolic_functions import (
Expand Down Expand Up @@ -663,3 +664,4 @@ def promote_types_of_numpy_inputs(
matmul = ufunc("_matmul")
maximum = ufunc("_maximum")
minimum = ufunc("_minimum")
real = ufunc("_real")
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@
@to_ivy_arrays_and_back
def _imag(val):
return ivy.imag(val)


@to_ivy_arrays_and_back
def _real(val):
return ivy.real(val)
3 changes: 3 additions & 0 deletions ivy/functional/frontends/numpy/ufunc/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
"greater_equal",
"heaviside",
"hypot",
"imag",
"invert",
"imag" "invert",
"isfinite",
"isinf",
Expand Down Expand Up @@ -83,6 +85,7 @@
"power",
"rad2deg",
"radians",
"real",
"reciprocal",
"remainder",
"right_shift",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,27 @@ def test_numpy_imag(
on_device=on_device,
val=x[0],
)


# real
@handle_frontend_test(
fn_tree="numpy.real",
dtype_and_x=helpers.dtype_and_values(available_dtypes=helpers.get_dtypes("valid")),
test_with_out=st.just(False),
)
def test_numpy_real(
dtype_and_x,
frontend,
test_flags,
fn_tree,
on_device,
):
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,
val=x[0],
)