Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions dpnp/dpnp_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
/,
Expand Down
5 changes: 5 additions & 0 deletions dpnp/tests/test_ndarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need some validation the strides really changed



@testing.parameterize(*testing.product({"xp": [dpnp, numpy]}))
class TestContains:
Expand Down
Loading