Skip to content

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

Merged
antonwolfy merged 14 commits into
masterfrom
deprecate-shape-setter
Jun 26, 2026
Merged

Deprecate setting the shape attribute of dpnp.ndarray and dpnp.tensor.usm_ndarray#2967
antonwolfy merged 14 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.07% (-0.001%) from 78.071% — 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_40 ran successfully.
Passed: 1357
Failed: 3
Skipped: 16

Comment thread dpnp/dpnp_iface_arraycreation.py Outdated
Co-authored-by: vlad-perevezentsev <vladislav.perevezentsev@intel.com>
@vlad-perevezentsev vlad-perevezentsev self-requested a review June 26, 2026 09:51

@vlad-perevezentsev vlad-perevezentsev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM
Thank you @antonwolfy !

@antonwolfy antonwolfy merged commit f79adfd into master Jun 26, 2026
81 of 86 checks passed
@antonwolfy antonwolfy deleted the deprecate-shape-setter branch June 26, 2026 12:20
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.

3 participants