Skip to content

Remove in-place modification of shape attribute for numpy.ndarray#2958

Open
antonwolfy wants to merge 3 commits into
masterfrom
remove-in-place-modification-for-numpy.ndarray.shape
Open

Remove in-place modification of shape attribute for numpy.ndarray#2958
antonwolfy wants to merge 3 commits into
masterfrom
remove-in-place-modification-for-numpy.ndarray.shape

Conversation

@antonwolfy

@antonwolfy antonwolfy commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

NumPy 2.5 is going to deprecate in-place assignment to ndarray.shape.

Previously _as_zero_dim_ndarray in dpnp.tensor relied on this pattern (view.shape = tuple()) to turn a size-1 host buffer into a 0-dim array before extracting a Python scalar.

This PR replaces it with reshape(()), which is the recommended non-deprecated alternative and returns a true
0-dim array.

  • 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 18, 2026
@antonwolfy antonwolfy self-assigned this Jun 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

@antonwolfy antonwolfy force-pushed the remove-in-place-modification-for-numpy.ndarray.shape branch from 7a733de to 18d76c2 Compare June 18, 2026 14:25
@coveralls

coveralls commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 78.091%. remained the same — remove-in-place-modification-for-numpy.ndarray.shape into master

@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Array API standard conformance tests for dpnp=0.21.0dev1=py313h509198e_15 ran successfully.
Passed: 1357
Failed: 3
Skipped: 16

@antonwolfy antonwolfy marked this pull request as ready for review June 18, 2026 17:13
@antonwolfy antonwolfy force-pushed the remove-in-place-modification-for-numpy.ndarray.shape branch from f02e5cd to b3887f1 Compare June 18, 2026 17:14
@antonwolfy antonwolfy force-pushed the remove-in-place-modification-for-numpy.ndarray.shape branch from b3887f1 to 411bee7 Compare June 18, 2026 17:26
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