Skip to content

Commit

Permalink
🤖 Lint code
Browse files Browse the repository at this point in the history
  • Loading branch information
ivy-branch committed Sep 27, 2023
1 parent 74c8239 commit 746e56f
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 50 deletions.
11 changes: 6 additions & 5 deletions ivy/functional/frontends/paddle/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,12 @@ def log(x, name=None):
return ivy.log(x)


@with_supported_dtypes({"2.5.1 and below": ("float32", "float64")}, "paddle")
@to_ivy_arrays_and_back
def log10(x, name=None):
return ivy.log10(x)


@with_supported_dtypes({"2.5.1 and below": ("float32", "float64")}, "paddle")
@to_ivy_arrays_and_back
def log1p(x, name=None):
Expand All @@ -368,11 +374,6 @@ def log1p(x, name=None):
def log2(x, name=None):
return ivy.log2(x)

@with_supported_dtypes({"2.5.1 and below": ("float32", "float64")}, "paddle")
@to_ivy_arrays_and_back
def log10(x, name=None):
return ivy.log10(x)


@with_unsupported_dtypes({"2.5.1 and below": ("float16", "bfloat16")}, "paddle")
@to_ivy_arrays_and_back
Expand Down
19 changes: 10 additions & 9 deletions ivy_tests/test_ivy/test_frontends/test_paddle/test_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -1465,15 +1465,13 @@ def test_paddle_log(
)


# log1p
@handle_frontend_test(
fn_tree="paddle.log1p",
fn_tree="paddle.log10",
dtype_and_x=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("valid"),
max_value=1e5,
),
)
def test_paddle_log1p(
def test_paddle_log10(
*,
dtype_and_x,
on_device,
Expand All @@ -1494,14 +1492,15 @@ def test_paddle_log1p(
)


# log2
# log1p
@handle_frontend_test(
fn_tree="paddle.log2",
fn_tree="paddle.log1p",
dtype_and_x=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("valid"),
max_value=1e5,
),
)
def test_paddle_log2(
def test_paddle_log1p(
*,
dtype_and_x,
on_device,
Expand All @@ -1521,13 +1520,15 @@ def test_paddle_log2(
x=x[0],
)


# log2
@handle_frontend_test(
fn_tree="paddle.log10",
fn_tree="paddle.log2",
dtype_and_x=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("valid"),
),
)
def test_paddle_log10(
def test_paddle_log2(
*,
dtype_and_x,
on_device,
Expand Down
80 changes: 44 additions & 36 deletions ivy_tests/test_ivy/test_frontends/test_torch/test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,50 @@
from ivy_tests.test_ivy.helpers import handle_frontend_test


# --- Helpers --- #
# --------------- #


@st.composite
def _elemwise_helper(draw):
value_strategy = st.one_of(
helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("valid"),
),
st.integers(min_value=-10000, max_value=10000),
st.floats(min_value=-10000, max_value=10000),
)

dtype_and_x1 = draw(value_strategy)
if isinstance(dtype_and_x1, tuple):
dtype1 = dtype_and_x1[0]
x1 = dtype_and_x1[1][0]
else:
dtype1 = []
x1 = dtype_and_x1

dtype_and_x2 = draw(value_strategy)
if isinstance(dtype_and_x2, tuple):
dtype2 = dtype_and_x2[0]
x2 = dtype_and_x2[1][0]
else:
dtype2 = []
x2 = dtype_and_x2

num_pos_args = None
if not dtype1 and not dtype2:
num_pos_args = 2
elif not dtype1:
x1, x2 = x2, x1
input_dtypes = dtype1 + dtype2

return x1, x2, input_dtypes, num_pos_args


# --- Main --- #
# ------------ #


# ToDo: Fix this test after torch overide of assert is implemented
# @handle_frontend_test(
# fn_tree="torch._assert",
Expand Down Expand Up @@ -74,42 +118,6 @@ def test_torch_bincount(
)


@st.composite
def _elemwise_helper(draw):
value_strategy = st.one_of(
helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("valid"),
),
st.integers(min_value=-10000, max_value=10000),
st.floats(min_value=-10000, max_value=10000),
)

dtype_and_x1 = draw(value_strategy)
if isinstance(dtype_and_x1, tuple):
dtype1 = dtype_and_x1[0]
x1 = dtype_and_x1[1][0]
else:
dtype1 = []
x1 = dtype_and_x1

dtype_and_x2 = draw(value_strategy)
if isinstance(dtype_and_x2, tuple):
dtype2 = dtype_and_x2[0]
x2 = dtype_and_x2[1][0]
else:
dtype2 = []
x2 = dtype_and_x2

num_pos_args = None
if not dtype1 and not dtype2:
num_pos_args = 2
elif not dtype1:
x1, x2 = x2, x1
input_dtypes = dtype1 + dtype2

return x1, x2, input_dtypes, num_pos_args


@handle_frontend_test(
fn_tree="torch.result_type",
dtypes_and_xs=_elemwise_helper(),
Expand Down

0 comments on commit 746e56f

Please sign in to comment.