From a48e4b00ee7dd079697e64ca343f40e15af14c5f Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Thu, 26 Nov 2026 15:22:04 +0100 Subject: [PATCH 1/6] Sync third-party tests for Python integers outside the int64 range CuPy now handles a Python integer that int64 cannot hold as NumPy does: combined with a boolean array it raises `OverflowError` instead of being taken as `uint64`. This mirrors its test changes: - `test_binary_array_pyscalar_int_and_bool` compares with NumPy for both operand orders, accepting `OverflowError`. dpnp already matches NumPy there, so the test is no longer skipped. - `TestUfunc::test_add_large_python_int_cache` is new. It adds two Python integers, which dpnp does not support, so it is skipped. --- .../cupy/logic_tests/test_comparison.py | 17 ++++++----------- .../cupy/math_tests/test_arithmetic.py | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/dpnp/tests/third_party/cupy/logic_tests/test_comparison.py b/dpnp/tests/third_party/cupy/logic_tests/test_comparison.py index 8928f356ef77..0463563dde3a 100644 --- a/dpnp/tests/third_party/cupy/logic_tests/test_comparison.py +++ b/dpnp/tests/third_party/cupy/logic_tests/test_comparison.py @@ -107,18 +107,13 @@ def test_binary_array_pyscalar_int_and_float(self, xp, scalar, op, dtype): b = scalar return [op(a, b), op(b, a)] - @pytest.mark.skip("dpnp follows NumPy") - @pytest.mark.parametrize( - "scalar,safe_scalar", - [(2**63, 2), (2**63 + 100, 2), (-(2**63), -1)], - ) + @pytest.mark.parametrize("scalar", [2**63, 2**63 + 100, -(2**63)]) @pytest.mark.parametrize("op", operators) - def test_binary_array_pyscalar_int_and_bool(self, scalar, safe_scalar, op): - # As of 2.5, NumPy uses the default integer and fails for very large - # Python scalars. But CuPy uses uint64 and succeeds. - a = cupy.array([True, False]) - testing.assert_array_equal(op(a, scalar), op(a, safe_scalar)) - testing.assert_array_equal(op(scalar, a), op(safe_scalar, a)) + @pytest.mark.parametrize("reverse", [False, True]) + @testing.numpy_cupy_array_equal(accept_error=OverflowError) + def test_binary_array_pyscalar_int_and_bool(self, xp, scalar, op, reverse): + a = xp.array([True, False]) + return op(scalar, a) if reverse else op(a, scalar) class TestArrayEqual(unittest.TestCase): diff --git a/dpnp/tests/third_party/cupy/math_tests/test_arithmetic.py b/dpnp/tests/third_party/cupy/math_tests/test_arithmetic.py index 02ebae462398..5bf80e33d2c9 100644 --- a/dpnp/tests/third_party/cupy/math_tests/test_arithmetic.py +++ b/dpnp/tests/third_party/cupy/math_tests/test_arithmetic.py @@ -584,6 +584,24 @@ def check_casting_dtype_unsafe_ignore_warnings( class TestUfunc(UfuncTestBase): + @pytest.mark.skip("both scalar inputs is not supported") + @pytest.mark.parametrize( + "a,b", + [ + # try similar ones again to test caching behavior + (2, 2**63), + (2**63, 2), + (2, 2**63), + (2**63, 2), + (1, 1), + ], + ) + @testing.numpy_cupy_allclose( + accept_error=OverflowError, type_check=has_support_aspect64() + ) + def test_add_large_python_int_cache(self, a, b, xp): + return xp.add(a, b) + @pytest.mark.parametrize( "casting", [ From 65ab984bc8f4d502f26d3049dd7cc1dd887e648b Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Thu, 26 Nov 2026 17:41:39 +0100 Subject: [PATCH 2/6] Sync third-party tests for max, min and ptp with an out array CuPy fixed `ndarray.min` and `ptp` passing `out` and `dtype` in swapped order to its CUB reduction, and added tests that `max`, `min` and `ptp` with `out=` return `out` itself for each axis. dpnp has no such accelerator path and passes them unchanged, so they are mirrored without skips. --- .../cupy/core_tests/test_ndarray_reduction.py | 18 ++++++++++++++++++ .../cupy/statistics_tests/test_order.py | 17 +++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/dpnp/tests/third_party/cupy/core_tests/test_ndarray_reduction.py b/dpnp/tests/third_party/cupy/core_tests/test_ndarray_reduction.py index bf5cb8de56db..8e3aaf729312 100644 --- a/dpnp/tests/third_party/cupy/core_tests/test_ndarray_reduction.py +++ b/dpnp/tests/third_party/cupy/core_tests/test_ndarray_reduction.py @@ -188,6 +188,24 @@ def test_min_inf(self, exclude_cutensor, xp, dtype, order): a = xp.array([float("inf"), float("inf")], dtype, order=order) return a.min() + @pytest.mark.parametrize("has_out", [False, True]) + @pytest.mark.parametrize( + "axis,out_shape", + [(None, ()), (0, (3, 4)), (1, (2, 4)), (2, (2, 3)), ((1, 2), (2,))], + ) + @pytest.mark.parametrize("func", ["max", "min"]) + @testing.for_all_dtypes() + @testing.numpy_cupy_allclose(contiguous_check=False) + def test_minmax_out(self, xp, dtype, order, func, axis, out_shape, has_out): + # See gh-9032 + a = testing.shaped_random((2, 3, 4), xp, dtype, order=order) + if not has_out: + return getattr(a, func)(axis=axis) + out = xp.zeros(out_shape, dtype=dtype) + ret = getattr(a, func)(axis=axis, out=out) + assert ret is out + return out + @testing.for_all_dtypes() @testing.numpy_cupy_allclose(contiguous_check=False) def test_argmax_all(self, xp, dtype, order): diff --git a/dpnp/tests/third_party/cupy/statistics_tests/test_order.py b/dpnp/tests/third_party/cupy/statistics_tests/test_order.py index 2f438cf95f89..1c88b6ea36b0 100644 --- a/dpnp/tests/third_party/cupy/statistics_tests/test_order.py +++ b/dpnp/tests/third_party/cupy/statistics_tests/test_order.py @@ -455,6 +455,23 @@ def test_ptp_axis2(self, xp, dtype): a = testing.shaped_random((2, 3, 4), xp, dtype) return xp.ptp(a, axis=2) + @pytest.mark.parametrize("has_out", [False, True]) + @pytest.mark.parametrize( + "axis,out_shape", + [(None, ()), (0, (3, 4)), (1, (2, 4)), (2, (2, 3)), ((1, 2), (2,))], + ) + @testing.for_all_dtypes(no_bool=True) + @testing.numpy_cupy_allclose() + def test_ptp_out(self, xp, dtype, axis, out_shape, has_out): + # See gh-9032 + a = testing.shaped_random((2, 3, 4), xp, dtype) + if not has_out: + return xp.ptp(a, axis=axis) + out = xp.zeros(out_shape, dtype=dtype) + ret = xp.ptp(a, axis=axis, out=out) + assert ret is out + return out + @testing.for_float_dtypes() @testing.numpy_cupy_allclose() def test_ptp_nan(self, xp, dtype): From 0a1681c83e3cfa20be75a48a935673029c94f823 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Thu, 26 Nov 2026 17:55:22 +0100 Subject: [PATCH 3/6] Sync third-party tests for the CUDA kernel cache keys of xsf headers CuPy now hashes its `xsf` headers into a separate cache key, used only by kernels that include them, and drops the HIP extra-source workaround from its compile helpers. This mirrors its test changes in modules dpnp skips as a whole, so no test runs differently: - `test_function.py`: `_compile_func` calls `_compile_module_with_cache` without `extra_source`. - `test_raw.py`: `test_dynamical_parallelism` and `test_jitify5` take the `allow_full_header_cache` fixture and a `thread_unsafe` mark. - `test_compiler_cache.py`: new `test_hash_hexdigest_chunks` for `_hash_hexdigest` with several chunks. --- dpnp/tests/third_party/cupy/core_tests/test_function.py | 6 +----- dpnp/tests/third_party/cupy/core_tests/test_raw.py | 8 ++++++-- .../third_party/cupy/cuda_tests/test_compiler_cache.py | 7 +++++++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/dpnp/tests/third_party/cupy/core_tests/test_function.py b/dpnp/tests/third_party/cupy/core_tests/test_function.py index 1fa4fdbac46a..23d0074fe88f 100644 --- a/dpnp/tests/third_party/cupy/core_tests/test_function.py +++ b/dpnp/tests/third_party/cupy/core_tests/test_function.py @@ -5,9 +5,7 @@ import dpnp as cupy -# from cupy._core import core # from cupy.cuda import compiler -# from cupy.cuda import runtime from dpnp.tests.third_party.cupy import testing pytest.skip( @@ -16,9 +14,7 @@ def _compile_func(kernel_name, code): - # workaround for hipRTC - extra_source = core._get_header_source() if runtime.is_hip else None - mod = compiler._compile_module_with_cache(code, extra_source=extra_source) + mod = compiler._compile_module_with_cache(code) return mod.get_function(kernel_name) diff --git a/dpnp/tests/third_party/cupy/core_tests/test_raw.py b/dpnp/tests/third_party/cupy/core_tests/test_raw.py index 1561a534d9b9..8b1ff99362d6 100644 --- a/dpnp/tests/third_party/cupy/core_tests/test_raw.py +++ b/dpnp/tests/third_party/cupy/core_tests/test_raw.py @@ -773,7 +773,10 @@ def test_get_function_failure(self, configure): cupy.cuda.runtime.is_hip, reason="ROCm/HIP does not support dynamic parallelism", ) - def test_dynamical_parallelism(self, backend, jitify): + @pytest.mark.thread_unsafe(reason="Changes header-cache policy") + def test_dynamical_parallelism( + self, backend, jitify, allow_full_header_cache + ): self._check_ptx_loadable("nvrtc") ker = cupy.RawKernel( _test_source4, @@ -1553,7 +1556,8 @@ def test_jitify4(self, jitify): # if Jitify could redirect its output, we would be able to check # the error log here as well (NVIDIA/jitify#79) - def test_jitify5(self, configure, jitify): + @pytest.mark.thread_unsafe(reason="Changes strict header-cache checking") + def test_jitify5(self, configure, jitify, allow_full_header_cache): temp_dir = configure # If including a header that does not exist, Jitify would attempt to # comment it out and proceed. If this header is actually unused, then diff --git a/dpnp/tests/third_party/cupy/cuda_tests/test_compiler_cache.py b/dpnp/tests/third_party/cupy/cuda_tests/test_compiler_cache.py index a95a496ec10f..e7a1902278c6 100644 --- a/dpnp/tests/third_party/cupy/cuda_tests/test_compiler_cache.py +++ b/dpnp/tests/third_party/cupy/cuda_tests/test_compiler_cache.py @@ -15,9 +15,16 @@ # DiskKernelCacheBackend, # _hash_length, # _default_cache_dir, +# _hash_hexdigest, # ) +def test_hash_hexdigest_chunks(): + chunks = ("", b"a", "\u03b2", b"", "c") + assert _hash_hexdigest(*chunks) == _hash_hexdigest(b"\0a\0\xce\xb2\0\0c") + assert _hash_hexdigest(*chunks, sep=None) == _hash_hexdigest(b"a\xce\xb2c") + + class TestDiskKernelCacheBackend: """Tests for DiskKernelCacheBackend implementation.""" From ac1792befe991a8c0798ca8c5b14fd29c2cee081 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Thu, 26 Nov 2026 18:09:35 +0100 Subject: [PATCH 4/6] Sync third-party tests for the deprecated cuFFT plans and multi-GPU FFT CuPy now deprecates creating `cupy.cuda.cufft.Plan1d` and `PlanNd` directly, and its multi-GPU FFT (`cupy.fft.config.use_multi_gpus` and `set_cufft_gpus`). This mirrors its test changes, all in tests dpnp skips, so no test runs differently: - `test_fft.py`: `multi_gpu_config` and `test_plan_nd_init_api` ignore the new deprecation warnings, and the new `test_multi_gpu_config_deprecated` is skipped since multi GPU is not supported. - `test_cache.py`: `test_LRU_cache7` ignores the multi-GPU deprecation warning. The other changed file, `cuda_tests/test_cufft.py`, has no dpnp copy. --- .../third_party/cupy/fft_tests/test_cache.py | 17 ++++++-- .../third_party/cupy/fft_tests/test_fft.py | 40 ++++++++++++++++--- 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/dpnp/tests/third_party/cupy/fft_tests/test_cache.py b/dpnp/tests/third_party/cupy/fft_tests/test_cache.py index 29e0a7724edf..3071c3b5ac32 100644 --- a/dpnp/tests/third_party/cupy/fft_tests/test_cache.py +++ b/dpnp/tests/third_party/cupy/fft_tests/test_cache.py @@ -5,6 +5,7 @@ import queue import threading import unittest +import warnings import pytest @@ -280,8 +281,12 @@ def test_LRU_cache7(self, gpus=None): assert cache1.get_curr_size() == 0 <= cache1.get_size() # do a multi-GPU FFT - config.use_multi_gpus = True - config.set_cufft_gpus([0, 1]) + with warnings.catch_warnings(): + warnings.filterwarnings( + "ignore", "Multi-GPU FFT is deprecated", DeprecationWarning + ) + config.use_multi_gpus = True + config.set_cufft_gpus([0, 1]) c = testing.shaped_random((128,), cupy, cupy.complex64) cupy.fft.fft(c) assert cache0.get_curr_size() == 2 <= cache0.get_size() @@ -309,8 +314,12 @@ def test_LRU_cache7(self, gpus=None): assert plan1 is not next(iter(cache1))[1].plan # now use it again to make it the most recent - config.use_multi_gpus = True - config.set_cufft_gpus([0, 1]) + with warnings.catch_warnings(): + warnings.filterwarnings( + "ignore", "Multi-GPU FFT is deprecated", DeprecationWarning + ) + config.use_multi_gpus = True + config.set_cufft_gpus([0, 1]) c = testing.shaped_random((128,), cupy, cupy.complex64) cupy.fft.fft(c) assert cache0.get_curr_size() == 2 <= cache0.get_size() diff --git a/dpnp/tests/third_party/cupy/fft_tests/test_fft.py b/dpnp/tests/third_party/cupy/fft_tests/test_fft.py index acb4867595e1..6a545b3be089 100644 --- a/dpnp/tests/third_party/cupy/fft_tests/test_fft.py +++ b/dpnp/tests/third_party/cupy/fft_tests/test_fft.py @@ -97,8 +97,14 @@ def test_func(self, *args, **kw): try: nGPUs = len(gpus) assert nGPUs >= 2, "Must use at least two gpus" - config.use_multi_gpus = True - config.set_cufft_gpus(gpus) + with warnings.catch_warnings(): + warnings.filterwarnings( + "ignore", + "Multi-GPU FFT is deprecated", + DeprecationWarning, + ) + config.use_multi_gpus = True + config.set_cufft_gpus(gpus) impl(self, *args, **kw) except Exception: @@ -113,6 +119,24 @@ def test_func(self, *args, **kw): return decorator +@pytest.mark.skip("multi GPU is not supported") +@pytest.mark.filterwarnings("ignore:.* is experimental:FutureWarning") +def test_multi_gpu_config_deprecated(): + use_multi_gpus = config._use_multi_gpus.get() + _devices = config._devices.get() + try: + with pytest.warns(DeprecationWarning, match="Multi-GPU FFT"): + config.use_multi_gpus = True + with pytest.warns(DeprecationWarning, match="Multi-GPU FFT"): + config.set_cufft_gpus([0, 1]) + with warnings.catch_warnings(): + warnings.simplefilter("error", DeprecationWarning) + config.use_multi_gpus = False + finally: + config._use_multi_gpus.set(use_multi_gpus) + config._devices.set(_devices) + + @testing.with_requires("numpy>=2.0") @pytest.mark.usefixtures("skip_forward_backward") @testing.parameterize( @@ -770,10 +794,14 @@ def test_plan_nd_init_api(api): a.shape, CUFFT_R2C, axes=axes, order="C", out_size=5 ) # But additionally pass order, last_axis, and last_size to test old API. - if api == "old": - plan = PlanNd(*relevant_args, "C", 2, 5) - else: - plan = PlanNd(*relevant_args) + with warnings.catch_warnings(): + warnings.filterwarnings( + "ignore", "Direct instantiation", DeprecationWarning + ) + if api == "old": + plan = PlanNd(*relevant_args, "C", 2, 5) + else: + plan = PlanNd(*relevant_args) # These are not relevant and could probably be removed: assert plan.order == ("C" if api == "old" else None) From ed38642c8867999beaf9a34a42285c0096b9d20e Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Thu, 26 Nov 2026 18:34:45 +0100 Subject: [PATCH 5/6] Sync third-party tests for the memory size of an imported DLPack tensor CuPy fixed the memory size of a tensor imported from DLPack, which added up the shape extents instead of multiplying them, and added a test for it. This mirrors the test in `core_tests/test_dlpack.py`. The new `TestDLTensorMemory::test_memory_size` checks `out.data.size`, since dpnp's `data` is the USM memory itself, against `max(nbytes, itemsize)`, since dpnp allocates at least one element for an empty array. dpnp multiplies the extents, but its empty case `(0, 3)` fails until #3203 is merged, because the import sized an empty tensor by its nonzero dimensions. --- dpnp/tests/third_party/cupy/core_tests/test_dlpack.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dpnp/tests/third_party/cupy/core_tests/test_dlpack.py b/dpnp/tests/third_party/cupy/core_tests/test_dlpack.py index 7c1fff434ed5..bb45328ed6e8 100644 --- a/dpnp/tests/third_party/cupy/core_tests/test_dlpack.py +++ b/dpnp/tests/third_party/cupy/core_tests/test_dlpack.py @@ -329,6 +329,13 @@ def pool(self): # cupy.cuda.set_allocator(old_pool.malloc) pass + @pytest.mark.parametrize("shape", [(), (5,), (3, 4), (2, 3, 4), (0, 3)]) + def test_memory_size(self, shape): + array = cupy.empty(shape, dtype=cupy.float32) + out = cupy.from_dlpack(array) + # dpnp allocates at least one element for an empty array + assert out.data.size == max(array.nbytes, array.itemsize) + @pytest.mark.parametrize("max_version", [None, (1, 0)]) # @pytest.mark.thread_unsafe(reason="modifies pool and tracks allocations") def test_deleter(self, pool, max_version): From bd5e5eecc0073d12914aa38e6afd3f50313ab9da Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Thu, 26 Nov 2026 18:54:28 +0100 Subject: [PATCH 6/6] Sync third-party tests for the NumPy 2.6 deprecations of dot, append and isfortran CuPy now gives the warnings NumPy 2.6 adds: a `DeprecationWarning` for `dot` with `a.ndim >= 2` and `b.ndim > 2` and for `isfortran`, and a `FutureWarning` for `append` with a Python scalar. It also accepts 0-D input in `poly` and `roots`, as NumPy 2.6 does. dpnp already gives all three warnings, so this mirrors CuPy's test changes: - `test_product.py`: `TestDot` and `test_transposed_dot_with_out_f_contiguous` ignore the `dot` warning, and `test_transposed_dot` and `test_transposed_dot_with_out` now check it, for NumPy >= 2.6 too. CuPy's filters replace dpnp's own `_ignore_dot_nd_deprecation` mark. - `test_type_test.py`: `TestIsFortran` checks the `dpnp.isfortran` warning and compares with `flags.fnc` of the NumPy input. - `test_add_remove.py`: `TestAppend` becomes a plain class, its Python scalar tests take CuPy's warning filter, and the new `test_scalar_futurewarning` is skipped since it also passes the scalar as `arr`, which dpnp does not support. dpnp's own `TestAppend` covers the warning for an array `arr`. - `test_polynomial.py`, which dpnp skips: `test_poly_zero_dim` and `test_roots_zero_dim` compare with NumPy instead of expecting a `TypeError`. The other changed file, the sparse `test_linalg.py`, only marks a LOBPCG test that dpnp's copy does not have. --- .../cupy/lib_tests/test_polynomial.py | 27 +++++++++------- .../cupy/linalg_tests/test_product.py | 31 ++++++++++++------- .../cupy/logic_tests/test_type_test.py | 13 ++++---- .../manipulation_tests/test_add_remove.py | 25 ++++++++++++--- 4 files changed, 62 insertions(+), 34 deletions(-) diff --git a/dpnp/tests/third_party/cupy/lib_tests/test_polynomial.py b/dpnp/tests/third_party/cupy/lib_tests/test_polynomial.py index 14752c45be22..be1855aed247 100644 --- a/dpnp/tests/third_party/cupy/lib_tests/test_polynomial.py +++ b/dpnp/tests/third_party/cupy/lib_tests/test_polynomial.py @@ -290,11 +290,14 @@ def test_poly_ndim(self, dtype): xp.poly(a) @testing.for_all_dtypes(no_bool=True) - def test_poly_zero_dim(self, dtype): - for xp in (numpy, cupy): - a = testing.shaped_arange((), xp, dtype) - with pytest.raises(TypeError): - numpy.poly(a) + @testing.numpy_cupy_array_equal() + def test_poly_zero_dim(self, xp, dtype): + # NumPy currently accepts 0-D inputs, although that is debatable. + a = testing.shaped_arange((), xp, dtype) + if xp is numpy and testing.installed("numpy<2.6.0.dev0"): + # NumPy < 2.6 rejects 0-D inputs in the dispatcher. + a = a.ravel() + return xp.poly(a) @testing.for_all_dtypes() @testing.numpy_cupy_equal() @@ -945,13 +948,15 @@ def test_roots_zero_sized(self, xp, dtype): a = xp.zeros((0,), dtype) return xp.roots(a) - @testing.with_requires("numpy>1.17") @testing.for_all_dtypes(no_bool=True) - def test_roots_zero_dim(self, dtype): - for xp in (numpy, cupy): - a = testing.shaped_random((), xp, dtype) - with pytest.raises(TypeError): - xp.roots(a) + @testing.numpy_cupy_array_equal() + def test_roots_zero_dim(self, xp, dtype): + # NumPy currently accepts 0-D inputs, although that is debatable. + a = testing.shaped_random((), xp, dtype) + if xp is numpy and testing.installed("numpy<2.6.0.dev0"): + # NumPy < 2.6 rejects 0-D inputs in the dispatcher. + a = a.ravel() + return xp.roots(a) @testing.for_all_dtypes(no_bool=True) def test_roots_ndim(self, dtype): 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 6093938d67c5..4518a20b88f7 100644 --- a/dpnp/tests/third_party/cupy/linalg_tests/test_product.py +++ b/dpnp/tests/third_party/cupy/linalg_tests/test_product.py @@ -13,11 +13,6 @@ from dpnp.tests.third_party.cupy import testing from dpnp.tests.third_party.cupy.testing._helper import skip_if_after_baseline -# both numpy.dot (NumPy 2.6+) and dpnp.dot warn for a.ndim >= 2 and b.ndim > 2 -_ignore_dot_nd_deprecation = pytest.mark.filterwarnings( - "ignore:.*dot received arrays with a.ndim >= 2:DeprecationWarning" -) - @testing.parameterize( *testing.product( @@ -50,9 +45,9 @@ class TestDot(unittest.TestCase): # no_int8=True is added to avoid overflow for shape=((2, 3, 4), (3, 4, 2)) # and ((2, 3), (3, 4)) cases on cpu - @_ignore_dot_nd_deprecation @testing.for_all_dtypes_combination(["dtype_a", "dtype_b"], no_int8=True) @testing.numpy_cupy_allclose(type_check=has_support_aspect64()) + @pytest.mark.filterwarnings("ignore:.*a.ndim.*b.ndim:DeprecationWarning") def test_dot(self, xp, dtype_a, dtype_b): shape_a, shape_b = self.shape if self.trans_a: @@ -65,11 +60,11 @@ def test_dot(self, xp, dtype_a, dtype_b): b = testing.shaped_arange(shape_b, xp, dtype_b) return xp.dot(a, b) - @_ignore_dot_nd_deprecation @testing.for_float_dtypes(name="dtype_a") @testing.for_float_dtypes(name="dtype_b") @testing.for_float_dtypes(name="dtype_c") @testing.numpy_cupy_allclose(accept_error=ValueError) + @pytest.mark.filterwarnings("ignore:.*a.ndim.*b.ndim:DeprecationWarning") def test_dot_with_out(self, xp, dtype_a, dtype_b, dtype_c): shape_a, shape_b = self.shape if self.trans_a: @@ -252,26 +247,38 @@ def test_dot_vec3(self, xp, dtype): b = testing.shaped_arange((2,), xp, dtype) return xp.dot(a, b) - @_ignore_dot_nd_deprecation @testing.for_all_dtypes(no_int8=True) @testing.numpy_cupy_allclose() def test_transposed_dot(self, xp, dtype): a = testing.shaped_arange((2, 3, 4), xp, dtype).transpose(1, 0, 2) b = testing.shaped_arange((2, 3, 4), xp, dtype).transpose(0, 2, 1) - return xp.dot(a, b) + if xp is numpy and testing.numpy_satisfies("<2.6"): + res = xp.dot(a, b) + else: + # NumPy 2.6 deprecated this pointing at tensordot, we do too + with pytest.warns(DeprecationWarning, match="a.ndim.*b.ndim"): + res = xp.dot(a, b) + + return res - @_ignore_dot_nd_deprecation @testing.for_all_dtypes(no_int8=True) @testing.numpy_cupy_allclose() def test_transposed_dot_with_out(self, xp, dtype): a = testing.shaped_arange((2, 3, 4), xp, dtype).transpose(1, 0, 2) b = testing.shaped_arange((4, 2, 3), xp, dtype).transpose(2, 0, 1) c = xp.ndarray((3, 2, 3, 2), dtype=dtype) - xp.dot(a, b, out=c) + if xp is numpy and testing.numpy_satisfies("<2.6"): + xp.dot(a, b, out=c) + else: + # NumPy 2.6 deprecated this pointing at tensordot, we do too + with pytest.warns(DeprecationWarning, match="a.ndim.*b.ndim"): + xp.dot(a, b, out=c) + return c - @_ignore_dot_nd_deprecation @testing.for_all_dtypes() + # Note that CuPy doesn't warn here (it errors first) + @pytest.mark.filterwarnings("ignore:.*a.ndim.*b.ndim:DeprecationWarning") def test_transposed_dot_with_out_f_contiguous(self, dtype): for xp in (numpy, cupy): a = testing.shaped_arange((2, 3, 4), xp, dtype).transpose(1, 0, 2) diff --git a/dpnp/tests/third_party/cupy/logic_tests/test_type_test.py b/dpnp/tests/third_party/cupy/logic_tests/test_type_test.py index 1254354d339f..0a7afa467314 100644 --- a/dpnp/tests/third_party/cupy/logic_tests/test_type_test.py +++ b/dpnp/tests/third_party/cupy/logic_tests/test_type_test.py @@ -5,6 +5,7 @@ import numpy import pytest +import dpnp as cupy from dpnp.tests.third_party.cupy import testing @@ -73,13 +74,11 @@ def setUp(self): ) class TestIsFortran(unittest.TestCase): - # both numpy.isfortran (NumPy 2.6+) and dpnp.isfortran are deprecated - @pytest.mark.filterwarnings( - "ignore:.*isfortran is deprecated:DeprecationWarning" - ) - @testing.numpy_cupy_equal() - def test(self, xp): - return xp.isfortran(xp.asarray(self.value)) + def test(self): + a = cupy.asarray(self.value) + with pytest.warns(DeprecationWarning, match="isfortran is deprecated"): + result = cupy.isfortran(a) + assert result == self.value.flags.fnc @testing.parameterize( diff --git a/dpnp/tests/third_party/cupy/manipulation_tests/test_add_remove.py b/dpnp/tests/third_party/cupy/manipulation_tests/test_add_remove.py index 22e2d54faefe..c145c8bbc238 100644 --- a/dpnp/tests/third_party/cupy/manipulation_tests/test_add_remove.py +++ b/dpnp/tests/third_party/cupy/manipulation_tests/test_add_remove.py @@ -103,7 +103,7 @@ def test_delete_obj_variants(self, xp, make_obj): return xp.delete(arr, make_obj(xp)) -class TestAppend(unittest.TestCase): +class TestAppend: @testing.for_all_dtypes_combination( names=["dtype1", "dtype2"], no_bool=True @@ -119,21 +119,38 @@ def test(self, xp, dtype1, dtype2): names=["dtype1", "dtype2"], no_bool=True ) @testing.numpy_cupy_array_equal() + @pytest.mark.filterwarnings("ignore:.*append.*scalar:FutureWarning") def test_scalar_lhs(self, xp, dtype1, dtype2): scalar = xp.dtype(dtype1).type(10).item() return xp.append(scalar, xp.arange(20, dtype=dtype2)) - @pytest.mark.filterwarnings( - "ignore:.*append converted Python numeric scalars:FutureWarning" - ) @testing.for_all_dtypes_combination( names=["dtype1", "dtype2"], no_bool=True ) @testing.numpy_cupy_array_equal(type_check=has_support_aspect64()) + @pytest.mark.filterwarnings("ignore:.*append.*scalar:FutureWarning") def test_scalar_rhs(self, xp, dtype1, dtype2): scalar = xp.dtype(dtype2).type(10).item() return xp.append(xp.arange(20, dtype=dtype1), scalar) + @pytest.mark.skip("Scalar input is not supported") + @pytest.mark.parametrize( + "val1,val2,expected_dtype", + # Cover (relevant) branches for the future warning that + # NumPy also gives since NumPy 2.6. (expedcted dtype is still old one) + [ + (cupy.ones(3, dtype="float32"), 1.0, "float64"), + (cupy.ones(3, dtype="uint8"), 200, "int64"), + (cupy.ones(3, dtype="float32"), 1j, "complex128"), + ], + ) + def test_scalar_futurewarning(self, val1, val2, expected_dtype): + # Note that the above tests, cover the actual result dtype. + with pytest.warns(FutureWarning, match="append.*scalar"): + assert cupy.append(val1, val2).dtype == cupy.dtype(expected_dtype) + with pytest.warns(FutureWarning, match="append.*scalar"): + assert cupy.append(val2, val1).dtype == cupy.dtype(expected_dtype) + @pytest.mark.skip("Scalar input is not supported") @testing.for_all_dtypes_combination( names=["dtype1", "dtype2"], no_bool=True