From 9bf1b1dcd5e7762231c9e710a80eaccbe3e6a9ee Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Tue, 20 Jan 2026 08:49:03 -0800 Subject: [PATCH 1/2] Deprecate setting the strides of dpnp array --- dpnp/dpnp_array.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dpnp/dpnp_array.py b/dpnp/dpnp_array.py index 6a2b2fd1977..e06e8a0e530 100644 --- a/dpnp/dpnp_array.py +++ b/dpnp/dpnp_array.py @@ -1866,6 +1866,16 @@ def strides(self): return self._array_obj.strides + @strides.setter + def strides(self, _value): + warnings.warn( + "Setting the strides attribute is deprecated. " + "As an alternative, you can create a new view (no copy) via " + "the dpnp.ndarray constructor (``buffer`` is the original array).", + DeprecationWarning, + stacklevel=2, + ) + def sum( self, /, From 5630096b7565736f5c2483de1a03c3fa7a5fd453 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Tue, 20 Jan 2026 08:50:02 -0800 Subject: [PATCH 2/2] Add test_set_strides_deprecated --- dpnp/tests/test_ndarray.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dpnp/tests/test_ndarray.py b/dpnp/tests/test_ndarray.py index c58c26fdf97..b36d09f5996 100644 --- a/dpnp/tests/test_ndarray.py +++ b/dpnp/tests/test_ndarray.py @@ -75,6 +75,11 @@ def test_attributes(self): assert_equal(self.two.nbytes, 20 * num) assert_equal(self.two.itemsize, self.two.dtype.itemsize) + def test_set_strides_deprecated(self): + x = dpnp.eye(2) + with pytest.warns(DeprecationWarning, match="Setting the strides"): + setattr(x, "strides", x.strides) + @testing.parameterize(*testing.product({"xp": [dpnp, numpy]})) class TestContains: