-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
API: Remove ptp
, itemset
and newbyteorder
from np.ndarray
class
#24682
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
Conversation
06a34b2
to
80cbd85
Compare
80cbd85
to
65bb8dd
Compare
Searching on github, there seems to be a lot of usage of
usage of From that, I think we definitely at least need an |
As a replacement I'm using: arr.view(arr.dtype.newbytorder(new_order)) as |
numpy/__init__.pyi
Outdated
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.
FYI the ndarray.itemset
type annotations still persist as of the moment and will have to be removed as well.
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.
Thanks for pointing out! I removed them.
ca8425f
to
1b24963
Compare
Let me know if you need a hand setting up the |
c217775
to
0d4887d
Compare
@ngoldbaum Right, I forgot to add them. I pushed new changes - now in |
xref numpy/numpy#24682 Only a handful of lines, and _mostly_ in tests/relatively unused utility functions like rgb_to_hsv, but still something that should be addressed.
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.
It looks like matplotlib is ready. Are there any other downstream libraries we need to wait on PRs for?
Just one minor nit on the error message otherwise I think this is ready so long as downstream is ready as far as we're aware.
numpy/core/src/multiarray/getset.c
Outdated
array_ptp(PyArrayObject *self, void *NPY_UNUSED(ignored)) | ||
{ | ||
PyErr_SetString(PyExc_AttributeError, | ||
"`ptp` has been removed from ndarray class. " |
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.
Minor nit, here and in the other messages I'd say "was removed from the ndarray class in NumPy 2.0".
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.
Sure! I updated them.
I checked other libraries and opened four PRs that reflect changes introduced there:
Then we're good to go. |
Both
results in:
The
results in
So the normal indexing is even faster than a direct @mtsokol The title of the PR contains |
ptp
, setitem
and newbyteorder
from np.ndarray
classptp
, itemset
and newbyteorder
from np.ndarray
class
@eendebakpt Ah yes, I did a typo - fixed. |
All the downstream PRs are merged so let's pull this one in. Thanks @mtsokol. As always, if you're reading this because of CI breakage and you think we made a mistake in this PR and the migrations we've offered aren't sufficient, please open an issue. |
Were there deprecation warnings added to NumPy 1 for these removals somewhere? |
Given that it's a major version bump we decided to do a few API cleanups without any deprecation, including these. If that proves to be too disruptive, we're open to re-adding with deprecation warnings. |
We just ran into it when testing between NumPy 1 & 2 I don't think we need to readd them as there is a path to using the functions instead of the methods Though it might be worth adding a deprecation warning in the next NumPy 1 release just so users know this is coming |
cc @grlee77 (who ran into this; in case you have more thoughts here) |
Hi @rgommers @ngoldbaum,
This PR contains the first batch of cleanup changes for
numpy.ndarray
class described in NEP 52 section. It covers removal ofptp
,setitem
andnewbyteorder
methods fromndarray
. Should I add deprecation message or are these too niche to mention that?Please note that I left
np.matrix
andnp.ma.MaskedArray
classes intact as they are already legacy. (masked array has its own implementation and matrix class usesnp.ptp
)