-
-
Notifications
You must be signed in to change notification settings - Fork 11.4k
DEP: Deprecate setting the dtype of an numpy.ndarray #29575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Sebastian Berg <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you looked at all at how noisy this is downstream? It's a little hard to search for but I suspect this pattern is used quite a bit. It would probably help us to understand what downstream usage looks like to try running some downstream test suites with a patched numpy to see how noisy it is.
SciPy is probably a good choice, maybe astropy too because they implement an ndarray subclass. I'd skip pandas because its test suite takes a very long time to run outside of github actions.
Astropy indeed uses setting the dtype and shape. I created a ticket and a PR astropy/astropy#18562. Lets see how this is picked up before merging this PR. |
In astropy the only deprecated cases left are cases where we expect to use the new Alternatively, we split this PR to first merge the |
Since there is a PR ready to go, I don't think it is worth the effort to split this. Grepping around in pandas, it seems the only uses are in |
Partly addresses #28800. A continuation of #28901 and #29244.
We deprecate setting the dtype of an numpy arrays. For masked and record arrays no warnings are generated, as the dtype usage is a bit more complex (in a followup PR we can enable deprecation warnings by modifying the dtype setter logic). We skip warnings for pypy as we cannot rely on reference counting to avoid warnings when the dtype is changed via
array.view(new_dtype)
.