Skip to content

Trigonometry Testing #44

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

Merged
merged 2 commits into from
Mar 26, 2024
Merged
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
31 changes: 15 additions & 16 deletions tests/test_trig.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

import arrayfire_wrapper.dtypes as dtype
import arrayfire_wrapper.lib as wrapper

from . import utility_functions as util
from tests.utility_functions import check_type_supported, get_all_types, get_float_types


@pytest.mark.parametrize(
Expand All @@ -18,10 +17,10 @@
(random.randint(1, 10), random.randint(1, 10), random.randint(1, 10), random.randint(1, 10)),
],
)
@pytest.mark.parametrize("dtype_name", util.get_all_types())
@pytest.mark.parametrize("dtype_name", get_all_types())
def test_asin_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
"""Test inverse sine operation across all supported data types."""
util.check_type_supported(dtype_name)
check_type_supported(dtype_name)
values = wrapper.randu(shape, dtype_name)
result = wrapper.asin(values)
assert wrapper.get_dims(result)[0 : len(shape)] == shape, f"failed for shape: {shape}" # noqa
Expand All @@ -37,10 +36,10 @@ def test_asin_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
(random.randint(1, 10), random.randint(1, 10), random.randint(1, 10), random.randint(1, 10)),
],
)
@pytest.mark.parametrize("dtype_name", util.get_all_types())
@pytest.mark.parametrize("dtype_name", get_all_types())
def test_acos_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
"""Test inverse cosine operation across all supported data types."""
util.check_type_supported(dtype_name)
check_type_supported(dtype_name)
values = wrapper.randu(shape, dtype_name)
result = wrapper.acos(values)
assert wrapper.get_dims(result)[0 : len(shape)] == shape, f"failed for shape: {shape}" # noqa
Expand All @@ -56,10 +55,10 @@ def test_acos_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
(random.randint(1, 10), random.randint(1, 10), random.randint(1, 10), random.randint(1, 10)),
],
)
@pytest.mark.parametrize("dtype_name", util.get_all_types())
@pytest.mark.parametrize("dtype_name", get_all_types())
def test_atan_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
"""Test inverse tan operation across all supported data types."""
util.check_type_supported(dtype_name)
check_type_supported(dtype_name)
values = wrapper.randu(shape, dtype_name)
result = wrapper.atan(values)
assert wrapper.get_dims(result)[0 : len(shape)] == shape, f"failed for shape: {shape}" # noqa
Expand All @@ -75,10 +74,10 @@ def test_atan_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
(random.randint(1, 10), random.randint(1, 10), random.randint(1, 10), random.randint(1, 10)),
],
)
@pytest.mark.parametrize("dtype_name", util.get_float_types())
@pytest.mark.parametrize("dtype_name", get_float_types())
def test_atan2_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
"""Test inverse tan operation across all supported data types."""
util.check_type_supported(dtype_name)
check_type_supported(dtype_name)
if dtype_name == dtype.f16:
pytest.skip()
lhs = wrapper.randu(shape, dtype_name)
Expand Down Expand Up @@ -110,10 +109,10 @@ def test_atan2_unsupported_dtypes(invdtypes: dtype.Dtype) -> None:
(random.randint(1, 10), random.randint(1, 10), random.randint(1, 10), random.randint(1, 10)),
],
)
@pytest.mark.parametrize("dtype_name", util.get_all_types())
@pytest.mark.parametrize("dtype_name", get_all_types())
def test_cos_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
"""Test cosine operation across all supported data types."""
util.check_type_supported(dtype_name)
check_type_supported(dtype_name)
values = wrapper.randu(shape, dtype_name)
result = wrapper.cos(values)
assert wrapper.get_dims(result)[0 : len(shape)] == shape, f"failed for shape: {shape}" # noqa
Expand All @@ -129,10 +128,10 @@ def test_cos_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
(random.randint(1, 10), random.randint(1, 10), random.randint(1, 10), random.randint(1, 10)),
],
)
@pytest.mark.parametrize("dtype_name", util.get_all_types())
@pytest.mark.parametrize("dtype_name", get_all_types())
def test_sin_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
"""Test sin operation across all supported data types."""
util.check_type_supported(dtype_name)
check_type_supported(dtype_name)
values = wrapper.randu(shape, dtype_name)
result = wrapper.sin(values)
assert wrapper.get_dims(result)[0 : len(shape)] == shape, f"failed for shape: {shape}" # noqa
Expand All @@ -148,10 +147,10 @@ def test_sin_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
(random.randint(1, 10), random.randint(1, 10), random.randint(1, 10), random.randint(1, 10)),
],
)
@pytest.mark.parametrize("dtype_name", util.get_all_types())
@pytest.mark.parametrize("dtype_name", get_all_types())
def test_tan_shape_dtypes(shape: tuple, dtype_name: dtype.Dtype) -> None:
"""Test tan operation across all supported data types."""
util.check_type_supported(dtype_name)
check_type_supported(dtype_name)
values = wrapper.randu(shape, dtype_name)
result = wrapper.tan(values)
assert wrapper.get_dims(result)[0 : len(shape)] == shape, f"failed for shape: {shape}" # noqa
Loading