Skip to content

Commit c2d5e00

Browse files
authored
Merge pull request numpy#28994 from jorenham/typing/ndarray-timedelta64-idiv
TYP: allow inplace division of ``NDArray[timedelta64]`` by floats
2 parents 3c76265 + 4125f0a commit c2d5e00

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

numpy/__init__.pyi

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3443,27 +3443,23 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
34433443

34443444
#
34453445
@overload
3446-
def __itruediv__(self: NDArray[floating], other: _ArrayLikeFloat_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
3446+
def __itruediv__(self: NDArray[floating | timedelta64], other: _ArrayLikeFloat_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
34473447
@overload
34483448
def __itruediv__(self: NDArray[complexfloating], other: _ArrayLikeComplex_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
34493449
@overload
3450-
def __itruediv__(self: NDArray[timedelta64], other: _ArrayLikeInt, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
3451-
@overload
34523450
def __itruediv__(self: NDArray[object_], other: Any, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
34533451

34543452
# keep in sync with `__imod__`
34553453
@overload
34563454
def __ifloordiv__(
34573455
self: NDArray[unsignedinteger],
34583456
other: _ArrayLikeUInt_co | _IntLike_co,
3459-
/
3457+
/,
34603458
) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
34613459
@overload
34623460
def __ifloordiv__(self: NDArray[signedinteger], other: _ArrayLikeInt_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
34633461
@overload
3464-
def __ifloordiv__(self: NDArray[floating], other: _ArrayLikeFloat_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
3465-
@overload
3466-
def __ifloordiv__(self: NDArray[timedelta64], other: _ArrayLikeInt, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
3462+
def __ifloordiv__(self: NDArray[floating | timedelta64], other: _ArrayLikeFloat_co, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
34673463
@overload
34683464
def __ifloordiv__(self: NDArray[object_], other: Any, /) -> ndarray[_ShapeT_co, _DTypeT_co]: ...
34693465

numpy/typing/tests/data/pass/arithmetic.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,13 @@ def __rpow__(self, value: Any) -> Object:
252252

253253
AR_LIKE_m // AR_m
254254

255+
AR_m /= f
256+
AR_m //= f
257+
AR_m /= AR_f
258+
AR_m /= AR_LIKE_f
259+
AR_m //= AR_f
260+
AR_m //= AR_LIKE_f
261+
255262
AR_O // AR_LIKE_b
256263
AR_O // AR_LIKE_u
257264
AR_O // AR_LIKE_i

0 commit comments

Comments
 (0)