-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
MAINT: dtype.name works for NEP 42 dtypes #23047
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
We really should improve thi. Right now I have
type(dtype)._parametric
and_abstract
. I am thinking it might make sense to make these public and (maybe without the underscore).Could also add it to the dtype instances. I think we can consider these attributes stable API really (maybe even already with that underscore).
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.
Yeah, I think having a concrete and obvious way to signal that this is a new-style dtype would be great. I don't have a strong opinion about how that should be spelled.
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.
If not you, who then? :). More seriously though, we have to make these public in some form I think. And if we are unsure, a safe bet is to just keep it as is (with an underscore), but define it as stable API (and maybe document it).
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.
Is there a logical test on
dtype._parametric
anddtype._abstract
that can be used to get the same information as checkingdtype.kind == '\x00'
?Because there are legacy parametric and abstract dtypes I'm not sure there is, so making these attributes public is might be orthogonal to this discussion.
That said, I agree making them public would be useful.
Maybe just adding a new check in
arraydescr_isbuiltin_get
and allowdtype.isbuiltin
to be 3? If new public attributes on dtype instances are OK, it could also be a new attribute which is onlyTrue
for dtypes are created through the public dtype API. I guess naming is a tad awkward because of the existence of legacy user dtypes, but something likedtype.is_nonlegacy_custom
maybe?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.
Returning 3 there seems OK, the only danger is if someone out there did
dtype.isbuiltin != 2
or something crazy. But that seems unlikely?!dtype.iscustom
is maybe not so bad (I would just ignore the "legacy" part and assume legacy dtypes will die off eventually?)I do think we need this information also on the type probably in the long term. One other way to do this is always
isinstance/issubclass(..., np.UserDType)
. That would probably make Marten very happy I am sure ;). I do not see that such APIs as mutual exclusive, though.