Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork11k
TYP: TypeMaskedArray.__{iadd,isub,imul,itruediv,ifloordiv,ipow}__
#28986
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
9 commits Select commitHold shift + click to select a range
71b1258
TYP: Type ``MaskedArray.__{iadd,isub,imul,itruediv,ifloordiv,pow}__``
MarcoGorelli3c9cd7e
Merge remote-tracking branch 'upstream/main' into ma-inplace-ops
MarcoGorelli69f6d7e
add str/bytes overloads + tests
MarcoGorellied8bf04
better align
MarcoGorellic4be2d9
:fire: remove outdated variable
MarcoGorelli518c71c
fixup
MarcoGorellif86a120
Merge remote-tracking branch 'upstream/main' into ma-inplace-ops
MarcoGorelli75dfcd2
dtype -> np.dtype
MarcoGorelli9d77a03
combine float and timedelta overloads
MarcoGorelliFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
179 changes: 173 additions & 6 deletionsnumpy/ma/core.pyi
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -17,22 +17,40 @@ from numpy import ( | ||
amax, | ||
amin, | ||
bool_, | ||
bytes_, | ||
character, | ||
complexfloating, | ||
datetime64, | ||
dtype, | ||
dtypes, | ||
expand_dims, | ||
float64, | ||
floating, | ||
generic, | ||
int_, | ||
intp, | ||
ndarray, | ||
object_, | ||
signedinteger, | ||
str_, | ||
timedelta64, | ||
unsignedinteger, | ||
) | ||
from numpy._globals import _NoValueType | ||
from numpy._typing import ( | ||
ArrayLike, | ||
NDArray, | ||
_ArrayLike, | ||
_ArrayLikeBool_co, | ||
_ArrayLikeBytes_co, | ||
_ArrayLikeComplex_co, | ||
_ArrayLikeFloat_co, | ||
_ArrayLikeInt, | ||
_ArrayLikeInt_co, | ||
_ArrayLikeStr_co, | ||
_ArrayLikeString_co, | ||
_ArrayLikeTD64_co, | ||
_ArrayLikeUInt_co, | ||
_DTypeLikeBool, | ||
_IntLike_co, | ||
_ScalarLike_co, | ||
@@ -456,12 +474,161 @@ class MaskedArray(ndarray[_ShapeT_co, _DTypeT_co]): | ||
def __rfloordiv__(self, other): ... | ||
def __pow__(self, other, mod: None = None, /): ... | ||
def __rpow__(self, other, mod: None = None, /): ... | ||
# Keep in sync with `ndarray.__iadd__`, except that `_MaskedArray[unsignedinteger]` does not accept | ||
# _IntLike_co for `other`. | ||
@overload | ||
def __iadd__( | ||
self: _MaskedArray[np.bool], other: _ArrayLikeBool_co, / | ||
) -> MaskedArray[_ShapeT_co, _DTypeT_co]: ... | ||
@overload | ||
def __iadd__( | ||
self: _MaskedArray[unsignedinteger], other: _ArrayLikeUInt_co, / | ||
) -> MaskedArray[_ShapeT_co, _DTypeT_co]: ... | ||
@overload | ||
def __iadd__( | ||
self: _MaskedArray[signedinteger], other: _ArrayLikeInt_co, / | ||
) -> MaskedArray[_ShapeT_co, _DTypeT_co]: ... | ||
@overload | ||
def __iadd__( | ||
self: _MaskedArray[floating], other: _ArrayLikeFloat_co, / | ||
) -> MaskedArray[_ShapeT_co, _DTypeT_co]: ... | ||
@overload | ||
def __iadd__( | ||
self: _MaskedArray[complexfloating], other: _ArrayLikeComplex_co, / | ||
) -> MaskedArray[_ShapeT_co, _DTypeT_co]: ... | ||
@overload | ||
def __iadd__( | ||
self: _MaskedArray[timedelta64 | datetime64], other: _ArrayLikeTD64_co, / | ||
) -> MaskedArray[_ShapeT_co, _DTypeT_co]: ... | ||
@overload | ||
def __iadd__(self: _MaskedArray[bytes_], other: _ArrayLikeBytes_co, /) -> MaskedArray[_ShapeT_co, _DTypeT_co]: ... | ||
@overload | ||
def __iadd__( | ||
self: MaskedArray[Any, dtype[str_] | dtypes.StringDType], | ||
other: _ArrayLikeStr_co | _ArrayLikeString_co, | ||
/, | ||
) -> MaskedArray[_ShapeT_co, _DTypeT_co]: ... | ||
@overload | ||
def __iadd__( | ||
self: _MaskedArray[object_], other: Any, / | ||
) -> MaskedArray[_ShapeT_co, _DTypeT_co]: ... | ||
# Keep in sync with `ndarray.__isub__`, except that `_MaskedArray[unsignedinteger]` does not accept | ||
# _IntLike_co for `other`. | ||
@overload | ||
def __isub__( | ||
self: _MaskedArray[unsignedinteger], other: _ArrayLikeUInt_co, / | ||
) -> MaskedArray[_ShapeT_co, _DTypeT_co]: ... | ||
@overload | ||
def __isub__( | ||
self: _MaskedArray[signedinteger], other: _ArrayLikeInt_co, / | ||
) -> MaskedArray[_ShapeT_co, _DTypeT_co]: ... | ||
@overload | ||
def __isub__( | ||
self: _MaskedArray[floating], other: _ArrayLikeFloat_co, / | ||
) -> MaskedArray[_ShapeT_co, _DTypeT_co]: ... | ||
@overload | ||
def __isub__( | ||
self: _MaskedArray[complexfloating], other: _ArrayLikeComplex_co, / | ||
) -> MaskedArray[_ShapeT_co, _DTypeT_co]: ... | ||
@overload | ||
def __isub__( | ||
self: _MaskedArray[timedelta64 | datetime64], other: _ArrayLikeTD64_co, / | ||
) -> MaskedArray[_ShapeT_co, _DTypeT_co]: ... | ||
@overload | ||
def __isub__( | ||
self: _MaskedArray[object_], other: Any, / | ||
) -> MaskedArray[_ShapeT_co, _DTypeT_co]: ... | ||
# Keep in sync with `ndarray.__imul__`, except that `_MaskedArray[unsignedinteger]` does not accept | ||
# _IntLike_co for `other`. | ||
@overload | ||
def __imul__( | ||
self: _MaskedArray[np.bool], other: _ArrayLikeBool_co, / | ||
) -> MaskedArray[_ShapeT_co, _DTypeT_co]: ... | ||
@overload | ||
def __imul__( | ||
self: _MaskedArray[unsignedinteger], other: _ArrayLikeUInt_co, / | ||
) -> MaskedArray[_ShapeT_co, _DTypeT_co]: ... | ||
@overload | ||
def __imul__( | ||
self: MaskedArray[Any, dtype[signedinteger] | dtype[character] | dtypes.StringDType], | ||
other: _ArrayLikeInt_co, / | ||
) -> MaskedArray[_ShapeT_co, _DTypeT_co]: ... | ||
@overload | ||
def __imul__( | ||
self: _MaskedArray[floating | timedelta64], other: _ArrayLikeFloat_co, / | ||
) -> MaskedArray[_ShapeT_co, _DTypeT_co]: ... | ||
@overload | ||
def __imul__( | ||
self: _MaskedArray[complexfloating], other: _ArrayLikeComplex_co, / | ||
) -> MaskedArray[_ShapeT_co, _DTypeT_co]: ... | ||
@overload | ||
def __imul__( | ||
self: _MaskedArray[object_], other: Any, / | ||
) -> MaskedArray[_ShapeT_co, _DTypeT_co]: ... | ||
# Keep in sync with `ndarray.__ifloordiv__`, except that `_MaskedArray[unsignedinteger]` does not accept | ||
# _IntLike_co for `other`. | ||
@overload | ||
def __ifloordiv__( | ||
self: _MaskedArray[unsignedinteger], other: _ArrayLikeUInt_co, / | ||
) -> MaskedArray[_ShapeT_co, _DTypeT_co]: ... | ||
@overload | ||
def __ifloordiv__( | ||
self: _MaskedArray[signedinteger], other: _ArrayLikeInt_co, / | ||
) -> MaskedArray[_ShapeT_co, _DTypeT_co]: ... | ||
@overload | ||
def __ifloordiv__( | ||
self: _MaskedArray[floating | timedelta64], other: _ArrayLikeFloat_co, / | ||
) -> MaskedArray[_ShapeT_co, _DTypeT_co]: ... | ||
@overload | ||
def __ifloordiv__( | ||
self: _MaskedArray[object_], other: Any, / | ||
) -> MaskedArray[_ShapeT_co, _DTypeT_co]: ... | ||
# Keep in sync with `ndarray.__itruediv__`, except that `_MaskedArray[unsignedinteger]` does not accept | ||
# _IntLike_co for `other`. | ||
@overload | ||
def __itruediv__( | ||
self: _MaskedArray[floating | timedelta64], other: _ArrayLikeFloat_co, / | ||
) -> MaskedArray[_ShapeT_co, _DTypeT_co]: ... | ||
@overload | ||
def __itruediv__( | ||
self: _MaskedArray[complexfloating], | ||
other: _ArrayLikeComplex_co, | ||
/, | ||
) -> MaskedArray[_ShapeT_co, _DTypeT_co]: ... | ||
@overload | ||
def __itruediv__( | ||
self: _MaskedArray[object_], other: Any, / | ||
) -> MaskedArray[_ShapeT_co, _DTypeT_co]: ... | ||
# Keep in sync with `ndarray.__ipow__`, except that `_MaskedArray[unsignedinteger]` does not accept | ||
# _IntLike_co for `other`. | ||
@overload | ||
def __ipow__( | ||
self: _MaskedArray[unsignedinteger], other: _ArrayLikeUInt_co, / | ||
) -> MaskedArray[_ShapeT_co, _DTypeT_co]: ... | ||
@overload | ||
def __ipow__( | ||
self: _MaskedArray[signedinteger], other: _ArrayLikeInt_co, / | ||
) -> MaskedArray[_ShapeT_co, _DTypeT_co]: ... | ||
@overload | ||
def __ipow__( | ||
self: _MaskedArray[floating], other: _ArrayLikeFloat_co, / | ||
) -> MaskedArray[_ShapeT_co, _DTypeT_co]: ... | ||
@overload | ||
def __ipow__( | ||
self: _MaskedArray[complexfloating], other: _ArrayLikeComplex_co, / | ||
) -> MaskedArray[_ShapeT_co, _DTypeT_co]: ... | ||
@overload | ||
def __ipow__( | ||
self: _MaskedArray[object_], other: Any, / | ||
) -> MaskedArray[_ShapeT_co, _DTypeT_co]: ... | ||
jorenham marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
# | ||
@property # type: ignore[misc] | ||
def imag(self: _HasDTypeWithRealAndImag[object, _ScalarT], /) -> MaskedArray[_ShapeT_co, dtype[_ScalarT]]: ... | ||
get_imag: Any | ||
13 changes: 13 additions & 0 deletionsnumpy/typing/tests/data/fail/ma.pyi
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
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
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.