Skip to content

Deprecate setting the shape attribute of dpnp.ndarray and dpnp.tensor.usm_ndarray#2967

Open
antonwolfy wants to merge 12 commits into
masterfrom
deprecate-shape-setter
Open

Deprecate setting the shape attribute of dpnp.ndarray and dpnp.tensor.usm_ndarray#2967
antonwolfy wants to merge 12 commits into
masterfrom
deprecate-shape-setter

Conversation

@antonwolfy

@antonwolfy antonwolfy commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Setting the array shape in place via the shape attribute (a.shape = ...) is now deprecated for both dpnp.ndarray and dpnp.tensor.usm_ndarray. Assigning to .shape emits a DeprecationWarning while preserving the existing behavior for now.

This aligns dpnp with NumPy 2.5, which deprecated the same in-place shape assignment.

Users should reshape arrays with dpnp.reshape / dpnp.tensor.reshape (or the reshape method) instead:

# Deprecated
a.shape = (3, 8)

# Preferred
a = dpnp.reshape(a, (3, 8))
  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • Have you added documentation for your changes, if necessary?
  • Have you added your changes to the changelog?

@antonwolfy antonwolfy added this to the 0.21.0 release milestone Jun 23, 2026
@antonwolfy antonwolfy self-assigned this Jun 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

View rendered docs @ https://intelpython.github.io/dpnp/pull/2967/index.html

@coveralls

coveralls commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 78.069%. remained the same — deprecate-shape-setter into master

@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Array API standard conformance tests for dpnp=0.21.0dev1=py313h509198e_33 ran successfully.
Passed: 1356
Failed: 4
Skipped: 16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants