-
-
Notifications
You must be signed in to change notification settings - Fork 11k
ENH: Add aliases for common scalar unions #17096
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
The `bound` parameter seems to be ignored (mypy bug) which is highly problematic
…r `_FloatLike` and `_ComplexLike` Mypy has special rules which ensures that `int` is treated as a `float` (and `complex`) superclass, however these rules do not apply to its `np.generic` counterparts. Solution: manually add them them to the unions.
+1 this looks like a good idea to me. |
# NOTE: mypy has special rules which ensures that `int` is treated as | ||
# a `float` (and `complex`) superclass, however these rules do not apply | ||
# to its `np.generic` counterparts. | ||
# Solution: manually add them them to the unions below |
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.
double them
# to its `np.generic` counterparts. | ||
# Solution: manually add them them to the unions below | ||
_IntLike = Union[int, np.integer] | ||
_FloatLike = Union[float, np.floating, np.integer] |
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.
_FloatLike = Union[float, np.floating, np.integer] | |
_FloatLike = Union[float, np.floating, _IntLike] |
And same for the line below
Converting this into a draft for now as #17105 arguably has a more elegant solution for the same issue. |
Rebasing this is starting to getting kinda messy with the amount of changes in |
And here is the follow up: #17429 |
This pull request adds a number of aliases for common scalar unions.
Numpy and builtin scalars can generally be used interchangeably, and this is reflected in the annotations of a number of functions (often when a plain
ArrayLike
is insufficiently descriptive).The goal of this pull request is to define such annotations for common scalar-like objects and store them in a centralized location.
Examples