Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

TYP: reject complex scalar types in ndarray.__ifloordiv__ #28958

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 28 additions & 24 deletions 52 numpy/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3342,6 +3342,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
@overload
def __iadd__(self: NDArray[object_], other: Any, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...

#
@overload
def __isub__(
self: NDArray[unsignedinteger],
Expand All @@ -3359,6 +3360,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
@overload
def __isub__(self: NDArray[object_], other: Any, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...

#
@overload
def __imul__(self: NDArray[np.bool], other: _ArrayLikeBool_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
@overload
Expand All @@ -3376,6 +3378,22 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
@overload
def __imul__(self: NDArray[object_], other: Any, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...

@overload
def __ipow__(
self: NDArray[unsignedinteger],
other: _ArrayLikeUInt_co | _IntLike_co,
/,
) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
@overload
def __ipow__(self: NDArray[signedinteger], other: _ArrayLikeInt_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
@overload
def __ipow__(self: NDArray[floating], other: _ArrayLikeFloat_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
@overload
def __ipow__(self: NDArray[complexfloating], other: _ArrayLikeComplex_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
@overload
def __ipow__(self: NDArray[object_], other: Any, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...

#
@overload
def __itruediv__(self: NDArray[floating], other: _ArrayLikeFloat_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
@overload
Expand All @@ -3385,44 +3403,23 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
@overload
def __itruediv__(self: NDArray[object_], other: Any, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...

# keep in sync with `__imod__`
@overload
def __ifloordiv__(
self: NDArray[unsignedinteger],
other: _ArrayLikeUInt_co | _IntLike_co,
/,
/
) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
@overload
def __ifloordiv__(self: NDArray[signedinteger], other: _ArrayLikeInt_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
@overload
def __ifloordiv__(self: NDArray[floating], other: _ArrayLikeFloat_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
@overload
def __ifloordiv__(self: NDArray[complex128], other: _ArrayLikeComplex_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
@overload
def __ifloordiv__(
self: NDArray[complexfloating],
other: _ArrayLikeComplex_co,
/,
) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
@overload
def __ifloordiv__(self: NDArray[timedelta64], other: _ArrayLikeInt, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
@overload
def __ifloordiv__(self: NDArray[object_], other: Any, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...

@overload
def __ipow__(
self: NDArray[unsignedinteger],
other: _ArrayLikeUInt_co | _IntLike_co,
/,
) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
@overload
def __ipow__(self: NDArray[signedinteger], other: _ArrayLikeInt_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
@overload
def __ipow__(self: NDArray[floating], other: _ArrayLikeFloat_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
@overload
def __ipow__(self: NDArray[complexfloating], other: _ArrayLikeComplex_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
@overload
def __ipow__(self: NDArray[object_], other: Any, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...

# keep in sync with `__ifloordiv__`
@overload
def __imod__(
self: NDArray[unsignedinteger],
Expand All @@ -3442,6 +3439,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
@overload
def __imod__(self: NDArray[object_], other: Any, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...

# keep in sync with `__irshift__`
@overload
def __ilshift__(
self: NDArray[unsignedinteger],
Expand All @@ -3453,6 +3451,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
@overload
def __ilshift__(self: NDArray[object_], other: Any, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...

# keep in sync with `__ilshift__`
@overload
def __irshift__(
self: NDArray[unsignedinteger],
Expand All @@ -3464,6 +3463,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
@overload
def __irshift__(self: NDArray[object_], other: Any, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...

# keep in sync with `__ixor__` and `__ior__`
@overload
def __iand__(self: NDArray[np.bool], other: _ArrayLikeBool_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
@overload
Expand All @@ -3477,6 +3477,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
@overload
def __iand__(self: NDArray[object_], other: Any, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...

# keep in sync with `__iand__` and `__ior__`
@overload
def __ixor__(self: NDArray[np.bool], other: _ArrayLikeBool_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
@overload
Expand All @@ -3490,6 +3491,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
@overload
def __ixor__(self: NDArray[object_], other: Any, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...

# keep in sync with `__iand__` and `__ixor__`
@overload
def __ior__(self: NDArray[np.bool], other: _ArrayLikeBool_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
@overload
Expand All @@ -3503,6 +3505,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
@overload
def __ior__(self: NDArray[object_], other: Any, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...

#
@overload
def __imatmul__(self: NDArray[np.bool], other: _ArrayLikeBool_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
@overload
Expand All @@ -3516,6 +3519,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
@overload
def __imatmul__(self: NDArray[object_], other: Any, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...

#
def __dlpack__(
self: NDArray[number],
/,
Expand Down
5 changes: 5 additions & 0 deletions 5 numpy/typing/tests/data/fail/arithmetic.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ AR_i // AR_LIKE_m # type: ignore[operator]
AR_f // AR_LIKE_m # type: ignore[operator]
AR_c // AR_LIKE_m # type: ignore[operator]

# regression tests for https://github.com/numpy/numpy/issues/28957
AR_c // 2 # type: ignore[operator]
AR_c // AR_i # type: ignore[operator]
AR_c // AR_c # type: ignore[operator]

# Array multiplication

AR_b *= AR_LIKE_u # type: ignore[arg-type]
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.