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, /, 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: