This repository has been archived by the owner on Jun 10, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 32
Conversation
This file contains 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 adds basic type hints for `np.ufunc` and types all ufuncs in the top-level namespace as `np.ufunc`. Ufuncs are highly dynamic, e.g. - Their call signatures can vary - The `reduce`/`accumulate`/`reduceat`/`outer`/`at` methods may or may not always raise so it is difficult to have precise types. A path forward would be writing a mypy plugin to get more precise typing.
person142
commented
Mar 22, 2020
import numpy as np | ||
|
||
|
||
def main(): |
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.
This is the script I used to generate the big list of ufuncs. Could ultimately be done as part of a build step.
person142
commented
Mar 23, 2020
# int, an int, and a callable, but there's no way to express | ||
# that. | ||
extobj: List[Union[int, Callable]] = ..., | ||
) -> Union[ndarray, generic]: ... |
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 think that after a mypy upgrade to resolve python/typing#253 the union can be removed and replaced with two overloads (one for all scalars and one for array like). On the pinned version of mypy that doesn't work because the signatures have overlapping input types.
person142
added a commit
to person142/numpy-stubs
that referenced
this pull request
Mar 26, 2020
The most significant benefit is changes to `@overload` around what counts as overlapping signatures that could unlock some functionality; see e.g. - numpy#44 (comment) - numpy#44 (comment)
person142
added a commit
to person142/numpy-stubs
that referenced
this pull request
Mar 26, 2020
The most significant benefit is changes to `@overload` around what counts as overlapping signatures that could unlock some functionality; see e.g. - numpy#44 (comment) - numpy#11 (comment)
rgommers
pushed a commit
that referenced
this pull request
Mar 29, 2020
The most significant benefit is changes to `@overload` around what counts as overlapping signatures that could unlock some functionality; see e.g. - #44 (comment) - #11 (comment)
7 tasks
Thanks! |
person142
added a commit
to person142/numpy-stubs
that referenced
this pull request
Apr 17, 2020
Follow up to numpy#44. SciPy actually uses `__name__`, so add it.
rgommers
pushed a commit
that referenced
this pull request
Apr 17, 2020
Follow up to #44. SciPy actually uses `__name__`, so add it.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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 adds basic type hints for
np.ufunc
and types all ufuncs in thetop-level namespace as
np.ufunc
. Ufuncs are highly dynamic, e.g.reduce
/accumulate
/reduceat
/outer
/at
methods may or maynot always raise
so it is difficult to have precise types. A path forward would be
writing a mypy plugin to get more precise typing.