Repository navigation
MAINT: Refine a number of np.generic annotations - #17673
Merged
Merged
Conversation
5 tasks done
Member
|
Needs rebase. |
BvB93
force-pushed
the
generic-specific
branch
from
November 14, 2020 18:58
f00b67d to
2ddc46c
Compare
Member
Author
|
Alright, the latest rebase seems to have fixed things. |
Member
|
Thanks Bas. |
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 PR moves a number of the
_ArrayOrScalarCommon(typing-only) superclass tondarrayand/orgeneric.The methods of
genericcan generally speaking be annotated more accurately (compared tondarray) due to their fixed size and dtype. This PR does exactly that: it takes a number ofmethods from
_ArrayOrScalarCommonand moves them tondarrayandgeneric.The latter case is herein accompanied by an update of the respective annotations; for example
def ndim(self) -> int: ...becomesdef ndim(self) -> Literal[0]: ...forgeneric.Below is an overview of all the
genericchanges w.r.t.ndarray:base: Always returnsNone.dtype: Now returns a parametrized dtype (w.r.t. itself) rather than just plaindtype[Any].size: Always returns1.ndim: Always returns0.shape&strides: Always returns().byteswap: Theinplaceparameter must always be set toFalse.item: The passed axis must always be0,()or(0,).squeeze: The passed axis must always be0or().transpose: The passed axis must always be().A few others were completelly removed from
generic. The respective methods (incorrectly)claim the modify the generic inplace, even though they might not necessarily raise an exception
during runtime:
fill: Silently fails.resize: Silently fails.itemset: Raises aValueError.