Skip to content

numpy: setting an ndarray shape is deprecated since 2.5.0#4604

Open
woutdenolf wants to merge 4 commits into
mainfrom
4602-numpy-246---250rc1-setting-array-shape-is-deprecated
Open

numpy: setting an ndarray shape is deprecated since 2.5.0#4604
woutdenolf wants to merge 4 commits into
mainfrom
4602-numpy-246---250rc1-setting-array-shape-is-deprecated

Conversation

@woutdenolf

@woutdenolf woutdenolf commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

PR summary

AI Disclosure

  • No AI used

For reference: #4602 (comment)

@woutdenolf woutdenolf linked an issue Jun 6, 2026 that may be closed by this pull request
Comment thread src/silx/gui/data/ArrayTableModel.py Outdated
@woutdenolf

woutdenolf commented Jun 6, 2026

Copy link
Copy Markdown
Contributor Author

Needs the equivalent fix in fabio: silx-kit/fabio#641. Or we could ignore the fabio warnings.

@loichuder loichuder left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks okay to me.

Do you think we should put copy=False everywhere to be sure that no copy is done?

@woutdenolf

woutdenolf commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

Do you think we should put copy=False everywhere to be sure that no copy is done?

I was thinking about that but decided not to in the end.

I doubt the array.shape = ... pattern was actually used to ensure data did not get copied. We want to reshape the array and if the array happens to be non-contiguous or has an incompatible stride pattern/view that leads to copying, we still want to reshape. There are many other numpy operations that could lead to copying or not depending on the array/view. We rely on numpy to not copy when not needed.

I always hated the array.shape = ... pattern, it smells and I never used it. Seems like the numpy developers agree.

@loichuder

Copy link
Copy Markdown
Member

We want to reshape the array and if the array happens to be non-contiguous or has an incompatible stride pattern/view that leads to copying, we still want to reshape.

Yeah, ok, I do agree.

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.

numpy 2.4.6 -> 2.5.0rc1: setting array shape is deprecated

3 participants