ENH: Add aliases for common scalar unions#17096
Closed
BvB93 wants to merge 8 commits intonumpy:masterfrom
Closed
Conversation
added 6 commits
August 18, 2020 16:44
The `bound` parameter seems to be ignored (mypy bug) which is highly problematic
added 2 commits
August 18, 2020 23:43
…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.
Member
|
+1 this looks like a good idea to me. |
Qiyu8
reviewed
Aug 19, 2020
| # 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 |
Qiyu8
reviewed
Aug 19, 2020
eric-wieser
reviewed
Aug 19, 2020
| # 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] |
Member
There was a problem hiding this comment.
Suggested change
| _FloatLike = Union[float, np.floating, np.integer] | |
| _FloatLike = Union[float, np.floating, _IntLike] |
And same for the line below
Member
Author
|
Converting this into a draft for now as #17105 arguably has a more elegant solution for the same issue. |
Member
Author
Member
Author
|
Rebasing this is starting to getting kinda messy with the amount of changes in |
Member
Author
|
And here is the follow up: #17429 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 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
ArrayLikeis 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