diff --git a/dpnp/tests/third_party/cupy/core_tests/test_nep50_examples.py b/dpnp/tests/third_party/cupy/core_tests/test_nep50_examples.py index 02390f7f373..44f5433281e 100644 --- a/dpnp/tests/third_party/cupy/core_tests/test_nep50_examples.py +++ b/dpnp/tests/third_party/cupy/core_tests/test_nep50_examples.py @@ -2,6 +2,7 @@ import pytest import dpnp as cp +from dpnp.tests.helper import has_support_aspect64 from dpnp.tests.third_party.cupy import testing # TODO: remove once all dtype aliases added @@ -15,8 +16,6 @@ "uint8(1) + 2", "array([1], uint8) + int64(1)", "array([1], uint8) + array(1, int64)", - "array([1.], float32) + float64(1.)", - "array([1.], float32) + array(1., float64)", "array([1], uint8) + 1", "array([1], uint8) + 200", "array([100], uint8) + 200", @@ -25,7 +24,6 @@ "uint8(100) + 200", "float32(1) + 3e100", "array([1.0], float32) + 1e-14 == 1.0", - "array([0.1], float32) == float64(0.1)", "array(1.0, float32) + 1e-14 == 1.0", "array([1.], float32) + 3", "array([1.], float32) + int64(3)", @@ -42,25 +40,34 @@ "1.0 + array([1, 2, 3], int8)", "array([1], float32) + 1j", ] +if has_support_aspect64(): + examples += [ + "array([1.], float32) + float64(1.)", + "array([1.], float32) + array(1., float64)", + "array([0.1], float32) == float64(0.1)", + ] @pytest.mark.filterwarnings("ignore::RuntimeWarning") @testing.with_requires("numpy>=2.0") @pytest.mark.parametrize("example", examples) -@testing.numpy_cupy_allclose(atol=1e-15, accept_error=OverflowError) +@testing.numpy_cupy_allclose( + atol=1e-15, accept_error=OverflowError, type_check=has_support_aspect64() +) def test_nep50_examples(xp, example): dct = { "array": xp.array, "uint8": xp.uint8, "int64": xp.int64, "float32": xp.float32, - "float64": xp.float64, "int16": xp.int16, "bool_": xp.bool_, "int32": xp.int32, "complex64": xp.complex64, "int8": xp.int8, } + if has_support_aspect64(): + dct["float64"] = xp.float64 if isinstance(example, tuple): example, mesg = example diff --git a/dpnp/tests/third_party/cupy/linalg_tests/test_product.py b/dpnp/tests/third_party/cupy/linalg_tests/test_product.py index a712c1cb032..d0e7a0f5f7e 100644 --- a/dpnp/tests/third_party/cupy/linalg_tests/test_product.py +++ b/dpnp/tests/third_party/cupy/linalg_tests/test_product.py @@ -172,7 +172,7 @@ class TestLinalgCrossProduct(unittest.TestCase): @testing.with_requires("numpy>=2.0") @testing.for_all_dtypes_combination(["dtype_a", "dtype_b"]) - @testing.numpy_cupy_allclose() + @testing.numpy_cupy_allclose(type_check=has_support_aspect64()) def test_cross(self, xp, dtype_a, dtype_b): if dtype_a == dtype_b == numpy.bool_: # cross does not support bool-bool inputs. diff --git a/dpnp/tests/third_party/cupy/math_tests/test_misc.py b/dpnp/tests/third_party/cupy/math_tests/test_misc.py index c2d7d5ed0c8..0fb2ee8fd7f 100644 --- a/dpnp/tests/third_party/cupy/math_tests/test_misc.py +++ b/dpnp/tests/third_party/cupy/math_tests/test_misc.py @@ -198,7 +198,7 @@ def test_fabs(self, xp, dtype): @testing.with_requires("numpy>=2.0") @testing.for_all_dtypes(no_complex=True) - @testing.numpy_cupy_allclose(atol=1e-5) + @testing.numpy_cupy_allclose(atol=1e-5, type_check=has_support_aspect64()) def test_fabs_negative(self, xp, dtype): if numpy.issubdtype(dtype, numpy.unsignedinteger): pytest.skip("trying to set negative value to unsigned integer") diff --git a/dpnp/tests/third_party/cupy/math_tests/test_sumprod.py b/dpnp/tests/third_party/cupy/math_tests/test_sumprod.py index 5817936784e..5125a6f9f3f 100644 --- a/dpnp/tests/third_party/cupy/math_tests/test_sumprod.py +++ b/dpnp/tests/third_party/cupy/math_tests/test_sumprod.py @@ -1162,51 +1162,75 @@ def test_ediff1d_ed2(self, xp, dtype): class TestTrapezoid: @testing.for_all_dtypes() - @testing.numpy_cupy_allclose(rtol={numpy.float16: 1e-1, "default": 1e-7}) + @testing.numpy_cupy_allclose( + rtol={numpy.float16: 1e-1, "default": 1e-7}, + type_check=has_support_aspect64(), + ) def test_trapz_1dim(self, xp, dtype): a = testing.shaped_arange((5,), xp, dtype) return xp.trapezoid(a) @testing.for_all_dtypes() - @testing.numpy_cupy_allclose(rtol={numpy.float16: 1e-1, "default": 1e-7}) + @testing.numpy_cupy_allclose( + rtol={numpy.float16: 1e-1, "default": 1e-7}, + type_check=has_support_aspect64(), + ) def test_trapz_1dim_with_x(self, xp, dtype): a = testing.shaped_arange((5,), xp, dtype) x = testing.shaped_arange((5,), xp, dtype) return xp.trapezoid(a, x=x) @testing.for_all_dtypes() - @testing.numpy_cupy_allclose(rtol={numpy.float16: 1e-1, "default": 1e-7}) + @testing.numpy_cupy_allclose( + rtol={numpy.float16: 1e-1, "default": 1e-7}, + type_check=has_support_aspect64(), + ) def test_trapz_1dim_with_dx(self, xp, dtype): a = testing.shaped_arange((5,), xp, dtype) return xp.trapezoid(a, dx=0.1) @testing.for_all_dtypes() - @testing.numpy_cupy_allclose(rtol={numpy.float16: 1e-1, "default": 1e-7}) + @testing.numpy_cupy_allclose( + rtol={numpy.float16: 1e-1, "default": 1e-7}, + type_check=has_support_aspect64(), + ) def test_trapz_2dim_without_axis(self, xp, dtype): a = testing.shaped_arange((4, 5), xp, dtype) return xp.trapezoid(a) @testing.for_all_dtypes() - @testing.numpy_cupy_allclose(rtol={numpy.float16: 1e-1, "default": 1e-7}) + @testing.numpy_cupy_allclose( + rtol={numpy.float16: 1e-1, "default": 1e-7}, + type_check=has_support_aspect64(), + ) def test_trapz_2dim_with_axis(self, xp, dtype): a = testing.shaped_arange((4, 5), xp, dtype) return xp.trapezoid(a, axis=-2) @testing.for_all_dtypes() - @testing.numpy_cupy_allclose(rtol={numpy.float16: 1e-1, "default": 1e-7}) + @testing.numpy_cupy_allclose( + rtol={numpy.float16: 1e-1, "default": 1e-7}, + type_check=has_support_aspect64(), + ) def test_trapz_2dim_with_x_and_axis(self, xp, dtype): a = testing.shaped_arange((4, 5), xp, dtype) x = testing.shaped_arange((5,), xp, dtype) return xp.trapezoid(a, x=x, axis=1) @testing.for_all_dtypes() - @testing.numpy_cupy_allclose(rtol={numpy.float16: 1e-1, "default": 1e-7}) + @testing.numpy_cupy_allclose( + rtol={numpy.float16: 1e-1, "default": 1e-7}, + type_check=has_support_aspect64(), + ) def test_trapz_2dim_with_dx_and_axis(self, xp, dtype): a = testing.shaped_arange((4, 5), xp, dtype) return xp.trapezoid(a, dx=0.1, axis=1) @testing.for_all_dtypes() - @testing.numpy_cupy_allclose(rtol={numpy.float16: 1e-1, "default": 1e-7}) + @testing.numpy_cupy_allclose( + rtol={numpy.float16: 1e-1, "default": 1e-7}, + type_check=has_support_aspect64(), + ) def test_trapz_1dim_with_x_and_dx(self, xp, dtype): a = testing.shaped_arange((5,), xp, dtype) x = testing.shaped_arange((5,), xp, dtype) diff --git a/dpnp/tests/third_party/cupy/testing/_loops.py b/dpnp/tests/third_party/cupy/testing/_loops.py index 901d1111b0b..c6884a555d6 100644 --- a/dpnp/tests/third_party/cupy/testing/_loops.py +++ b/dpnp/tests/third_party/cupy/testing/_loops.py @@ -583,12 +583,12 @@ def numpy_cupy_allclose( # When `type_check` is `False`, cupy result and numpy result may have # different dtypes so we can not determine the dtype to use from the # tolerance associations. - if not type_check: - if isinstance(rtol, dict) or isinstance(atol, dict): - raise TypeError( - "When `type_check` is `False`, `rtol` and `atol` " - "must be supplied as float." - ) + # if not type_check: + # if isinstance(rtol, dict) or isinstance(atol, dict): + # raise TypeError( + # "When `type_check` is `False`, `rtol` and `atol` " + # "must be supplied as float." + # ) def check_func(c, n): rtol1, atol1 = _resolve_tolerance(type_check, c, rtol, atol)