Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
NEP: add NEP on a Python API cleanup for NumPy 2.0 #23537
NEP: add NEP on a Python API cleanup for NumPy 2.0 #23537
Changes from all commits
8949403
6727199
71b2114
6ac2330
7bcf21a
e63d6e5
409a864
b91a0a1
b032b05
0687bf6
02e6615
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
What about moving
stride_tricks
tonumpy.stride_tricks
, and considering the rest ofnumpy.lib
legacy stuff?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.
That's a reasonable option; there's a few more public things in
numpy.lib
though:I think that's all, but hard to be 100% sure. It's hard to find good places for each of them, so I had in mind to keep
np.lib
as a grab bag of stuff that does not deserve its own namespace right below the main namespace.We can probably get rid of
Arrayterator
; I'm not sure about the rest.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've added the list above to the note. I'd like to resolve this later (post-merge of this NEP as Draft). Leaning towards keeping
numpy.lib
, but either way is not ideal.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.
Agreed, but it would help here to know where would things like
arraysetops
andnanfunctions
would live (I realize this is not so important from a user perspective, since the functions are in the top namespace, but it is probably also good to think from the developer perspective).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'd say that they have to move somewhere, which is a single
git mv
plus use ofgit-blame-ignore-revs
to not mess up the usefulness ofgit blame
. Where it ends up exactly is less important to me, at least from the perspective of this NEP. It could be:numpy/_lib/nanfunctions.py
numpy/lib/_nanfunctions.py
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've always disliked this mixing up of a data type with a scalar variable class of that data type. If we can rid of those... (and perhaps have definitions for the standard dtypes, i.e.,
f8 = np.dtype('f8')
? see below too)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'd like
__eq__
on dtypes to do the expected thing for Python objects indeed.Less sure about
f8 = np.dtype('f8')
- I dislike the character codes a lot, they're too obscure. Scalars will hopefully go away completely at some point (they're not necessary for anything, and everyone seems to be in favor of them being removed eventually, it's just too big a lift for 2.0 it looks like).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.
What I'd like is clear principles, like:
int32
,float64
- with canonical names likebool
,void
,object
added to thatshort
,int
,double
,clongdouble
, etc.np.dtype
directly as much as possible, it's typically an anti-patternThere 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.
Hmm, I'm super-used to using the string variants, but definitely can see your point. The annoyance is that
type(int32)
is not actually adtype
subclass. Anyway, that's for #23358; agreed here that a minimal set is a good idea.