ENH: Add aliases for commonly used dtype-like objects #18236
Merged
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.
This PR adds (invariant) aliases for commonly used dtype-like objects, similar to what #18050 has done for array-likes.
Note that the aliases introduced herein are currently unused (beyond their introduction).
This will change once we start adding dtype-support to the ufuncs, something that's on
the to-do list for after the ufunc-based
ndarray
magic methods have been wrapped up (xref #18128 and #18228).Secondly, it performs a small follow-up on #13578, i.e. objects with the
.dtype
attribute arenow only considered dtype-like if aforementioned attribute returns a
np.dtype
instance.Examples
Example usage of the new
_DTypeLike<x>
aliases in annotating a simplified version ofnp.bitwise_or
.