From 7691cf611ab2961888dbf4142f6c65314b55e156 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Wed, 7 Oct 2026 12:38:12 +0200 Subject: [PATCH] Add third-party test for cumsum with axis=None and out Backport test_cumsum_no_axis to cover cumsum on a 2-D input with axis=None and a 1-D out array in C and F order, and check that the input array is not modified. --- .../third_party/cupy/math_tests/test_sumprod.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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 4be70c0c54d9..c0cce93be8e2 100644 --- a/dpnp/tests/third_party/cupy/math_tests/test_sumprod.py +++ b/dpnp/tests/third_party/cupy/math_tests/test_sumprod.py @@ -784,6 +784,23 @@ def test_cumsum_axis(self, xp, dtype, axis): a = testing.shaped_arange(tuple(range(4, 4 + n)), xp, dtype) return self._cumsum(xp, a, axis=axis) + @testing.for_all_dtypes() + @testing.numpy_cupy_allclose(contiguous_check=False) + @pytest.mark.parametrize("order", ["C", "F"]) + def test_cumsum_no_axis(self, xp, dtype, order): + a = testing.shaped_arange((4, 3), xp, dtype) + out = xp.empty((12,), dtype=dtype) + + if order in ("c", "C"): + out = xp.ascontiguousarray(out) + elif order in ("f", "F"): + out = xp.asfortranarray(out) + + b = a.copy() + xp.cumsum(a, out=out, dtype=dtype) + testing.assert_array_equal(a, b) # Check if input array is overwritten + return out + @pytest.mark.parametrize("axis", axes) @testing.for_all_dtypes() @testing.numpy_cupy_allclose()