ENH: Add annotations for remaining ndarray / generic non-magic methods#17372
Merged
charris merged 6 commits intonumpy:masterfrom Oct 5, 2020
Merged
ENH: Add annotations for remaining ndarray / generic non-magic methods#17372charris merged 6 commits intonumpy:masterfrom
ndarray / generic non-magic methods#17372charris merged 6 commits intonumpy:masterfrom
Conversation
added 4 commits
September 22, 2020 21:43
…ray` A number of methods require a >= 1D array or are completelly absent from `generic`. Move them to `ndarray`.
5 tasks
Member
Author
|
Any comments? |
Member
|
Thanks @BvB93 . No comments, but 12 days old, so in it goes. |
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 annotations for all remaining
ndarray/genericnon-magic methods.Fortunately, most of these methods were already typed in their function-based counterpart from
np.core.fromnumeric, so they could be copied over with minor alterations.A few notes and observations:
The annotations are mostly geared towards
ndarray. While they're not necessarily incorrect forgeneric, the signatures are generally speaking a bit too broad. Something to refine in a follow up.The overload pattern of
ndarray.all()is a very common one here:out is None,axis is Noneandkeepdims is False-> agenericis returned.out is Noneand(axis is not None or keepdims is True)-> agenericorndarrayis returned.out is not None->outis returned. One of the few cases where we can safelly use a typevar.A few annotations, that were recently moved to
np.core.fromnumeric(MAINT: Move thefromnumericannotations to their own stub file #17309), have beenmoved back to the main
__init__.pyifile, as they were needed for the newly annotated methods.A number of methods, that are either just plain unavailable to
genericor require a>=1Darray, havebeen moved from
_ArrayOrScalarCommontondarray.