-
-
Notifications
You must be signed in to change notification settings - Fork 11k
DEP: Deprecate setting the dtype of an exact numpy.ndarray #29244
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
3ad7ba0
to
401cbca
Compare
.. code-block:: python | ||
< 8000 td class="blob-num blob-num-deletion empty-cell"> |
|
|
>>> x = np.array([1, 2]) | ||
>>> x.dtype = np.bool |
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.
@jorenham This line gave an error in the CI because it emits a warning with this PR. Since changing the dtype is deprecated, I removed the example altogether.
Let me know if you want to keep it, I will then look for a way to suppress the warning.
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.
I'm fine with removing this now that in-place dtype modifications are officially discouraged in general :)
Partly addresses #28800. A continuation of #28901.
We only deprecate setting the dtype of an exact array. For masked and record arrays it will take some more refactoring to avoid setting the dtype. 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)
.