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 29, 2023
1 parent 5a984cd commit ec4ba9b
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 56 deletions.
4 changes: 2 additions & 2 deletions docs/overview/contributing/error_handling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ This section, "Error Handling" aims to assist you in navigating through some com
**Solution:**
As we are explicitly passing in a `dtype` which is not supported in the torch framework itself so torch backend fails here, a possible fix is adding the dtype in the unsupported dtype decoartor which would look something like this.
As we are explicitly passing in a `dtype` which is not supported in the torch framework itself so torch backend fails here, a possible fix is adding the dtype in the unsupported dtype decoartor which would look something like this.
.. code-block:: python
Expand Down Expand Up @@ -77,7 +77,7 @@ This section, "Error Handling" aims to assist you in navigating through some com
**Solution:**

As both the results are pretty close to each others in this case, adding an `rtol = 10^-3` and `atol = 10^-3` would fix the failing tests here.
As both the results are pretty close to each others in this case, adding an `rtol = 10^-3` and `atol = 10^-3` would fix the failing tests here.

.. code-block:: python
Expand Down
11 changes: 6 additions & 5 deletions ivy/functional/frontends/paddle/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,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 @@ -349,11 +355,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
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
from ivy.functional.frontends.torch.func_wrapper import to_ivy_arrays_and_back


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


@to_ivy_arrays_and_back
def celu(input, alpha=1.0, inplace=False):
prod = ivy.multiply(
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 @@ -1413,15 +1413,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 @@ -1442,14 +1440,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 @@ -1469,13 +1468,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 ec4ba9b

Please sign in to comment.