Skip to content

Commit f110d5a

Browse files
committed
floordiv
1 parent 5e16b86 commit f110d5a

File tree

13 files changed

+1023
-331
lines changed

13 files changed

+1023
-331
lines changed

pandas-stubs/core/base.pyi

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ from pandas._libs.tslibs.timedeltas import Timedelta
2929
from pandas._typing import (
3030
S1,
3131
S2,
32+
S3,
3233
AxisIndex,
3334
DropKeep,
3435
DTypeLike,
@@ -280,7 +281,7 @@ class ElementOpsMixin(Generic[S2]):
280281
) -> ElementOpsMixin[complex]: ...
281282
@overload
282283
def _proto_truediv(
283-
self: ElementOpsMixin[Timedelta], other: timedelta | Timedelta | np.timedelta64
284+
self: ElementOpsMixin[Timedelta], other: timedelta | np.timedelta64 | Timedelta
284285
) -> ElementOpsMixin[float]: ...
285286
@overload
286287
def _proto_rtruediv(
@@ -296,8 +297,56 @@ class ElementOpsMixin(Generic[S2]):
296297
) -> ElementOpsMixin[complex]: ...
297298
@overload
298299
def _proto_rtruediv(
299-
self: ElementOpsMixin[Timedelta], other: timedelta | Timedelta | np.timedelta64
300+
self: ElementOpsMixin[Timedelta], other: timedelta | np.timedelta64 | Timedelta
300301
) -> ElementOpsMixin[float]: ...
302+
@overload
303+
def _proto_floordiv(
304+
self: ElementOpsMixin[int], other: int | np.integer
305+
) -> ElementOpsMixin[int]: ...
306+
@overload
307+
def _proto_floordiv(
308+
self: ElementOpsMixin[float], other: float | np.floating
309+
) -> ElementOpsMixin[float]: ...
310+
@overload
311+
def _proto_floordiv(
312+
self: ElementOpsMixin[Timedelta], other: timedelta | np.timedelta64 | Timedelta
313+
) -> ElementOpsMixin[int]: ...
314+
@overload
315+
def _proto_rfloordiv(
316+
self: ElementOpsMixin[int], other: int | np.integer
317+
) -> ElementOpsMixin[int]: ...
318+
@overload
319+
def _proto_rfloordiv(
320+
self: ElementOpsMixin[float], other: float | np.floating
321+
) -> ElementOpsMixin[float]: ...
322+
@overload
323+
def _proto_rfloordiv(
324+
self: ElementOpsMixin[Timedelta], other: timedelta | np.timedelta64 | Timedelta
325+
) -> ElementOpsMixin[int]: ...
326+
@overload
327+
def _proto_mod(
328+
self: ElementOpsMixin[int], other: int | np.integer
329+
) -> ElementOpsMixin[int]: ...
330+
@overload
331+
def _proto_mod(
332+
self: ElementOpsMixin[float], other: float | np.floating
333+
) -> ElementOpsMixin[float]: ...
334+
@overload
335+
def _proto_mod(
336+
self: ElementOpsMixin[Timedelta], other: timedelta | np.timedelta64 | Timedelta
337+
) -> ElementOpsMixin[Timedelta]: ...
338+
@overload
339+
def _proto_rmod(
340+
self: ElementOpsMixin[int], other: int | np.integer
341+
) -> ElementOpsMixin[int]: ...
342+
@overload
343+
def _proto_rmod(
344+
self: ElementOpsMixin[float], other: float | np.floating
345+
) -> ElementOpsMixin[float]: ...
346+
@overload
347+
def _proto_rmod(
348+
self: ElementOpsMixin[Timedelta], other: timedelta | np.timedelta64 | Timedelta
349+
) -> ElementOpsMixin[Timedelta]: ...
301350

302351
@type_check_only
303352
class Supports_ProtoAdd(Protocol[_T_contra, S2]):
@@ -322,3 +371,29 @@ class Supports_ProtoTrueDiv(Protocol[_T_contra, S2]):
322371
@type_check_only
323372
class Supports_ProtoRTrueDiv(Protocol[_T_contra, S2]):
324373
def _proto_rtruediv(self, other: _T_contra, /) -> ElementOpsMixin[S2]: ...
374+
375+
@type_check_only
376+
class Supports_ProtoFloorDiv(Protocol[_T_contra, S2]):
377+
def _proto_floordiv(self, other: _T_contra, /) -> ElementOpsMixin[S2]: ...
378+
379+
@type_check_only
380+
class Supports_ProtoRFloorDiv(Protocol[_T_contra, S2]):
381+
def _proto_rfloordiv(self, other: _T_contra, /) -> ElementOpsMixin[S2]: ...
382+
383+
@type_check_only
384+
class Supports_ProtoMod(Protocol[_T_contra, S2]):
385+
def _proto_mod(self, other: _T_contra, /) -> ElementOpsMixin[S2]: ...
386+
387+
@type_check_only
388+
class Supports_ProtoRMod(Protocol[_T_contra, S2]):
389+
def _proto_rmod(self, other: _T_contra, /) -> ElementOpsMixin[S2]: ...
390+
391+
@type_check_only
392+
class Supports_ProtoDivMod(Protocol[_T_contra, S2, S3]):
393+
def _proto_floordiv(self, other: _T_contra, /) -> ElementOpsMixin[S2]: ...
394+
def _proto_mod(self, other: _T_contra, /) -> ElementOpsMixin[S3]: ...
395+
396+
@type_check_only
397+
class Supports_ProtoRDivMod(Protocol[_T_contra, S2, S3]):
398+
def _proto_rfloordiv(self, other: _T_contra, /) -> ElementOpsMixin[S2]: ...
399+
def _proto_rmod(self, other: _T_contra, /) -> ElementOpsMixin[S3]: ...

pandas-stubs/core/indexes/base.pyi

Lines changed: 107 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,36 +28,37 @@ from _typeshed import (
2828
_T_contra,
2929
)
3030
import numpy as np
31-
from pandas import (
32-
DataFrame,
33-
DatetimeIndex,
34-
Interval,
35-
IntervalIndex,
36-
MultiIndex,
37-
Period,
38-
PeriodDtype,
39-
PeriodIndex,
40-
Series,
41-
TimedeltaIndex,
42-
)
4331
from pandas.core.base import (
4432
ElementOpsMixin,
4533
IndexOpsMixin,
4634
Supports_ProtoAdd,
35+
Supports_ProtoFloorDiv,
4736
Supports_ProtoMul,
4837
Supports_ProtoRAdd,
38+
Supports_ProtoRFloorDiv,
4939
Supports_ProtoRMul,
5040
Supports_ProtoRTrueDiv,
5141
Supports_ProtoTrueDiv,
5242
)
43+
from pandas.core.frame import DataFrame
5344
from pandas.core.indexes.category import CategoricalIndex
45+
from pandas.core.indexes.datetimes import DatetimeIndex
46+
from pandas.core.indexes.interval import IntervalIndex
47+
from pandas.core.indexes.multi import MultiIndex
48+
from pandas.core.indexes.period import PeriodIndex
49+
from pandas.core.indexes.timedeltas import TimedeltaIndex
50+
from pandas.core.series import Series
5451
from pandas.core.strings.accessor import StringMethods
5552
from typing_extensions import (
5653
Never,
5754
Self,
5855
)
5956

60-
from pandas._libs.interval import _OrderableT
57+
from pandas._libs.interval import (
58+
Interval,
59+
_OrderableT,
60+
)
61+
from pandas._libs.tslibs.period import Period
6162
from pandas._libs.tslibs.timedeltas import Timedelta
6263
from pandas._typing import (
6364
C2,
@@ -92,6 +93,7 @@ from pandas._typing import (
9293
TimedeltaDtypeArg,
9394
TimestampDtypeArg,
9495
np_1darray,
96+
np_ndarray,
9597
np_ndarray_anyint,
9698
np_ndarray_bool,
9799
np_ndarray_complex,
@@ -102,6 +104,8 @@ from pandas._typing import (
102104
type_t,
103105
)
104106

107+
from pandas.core.dtypes.dtypes import PeriodDtype
108+
105109
class InvalidIndexError(Exception): ...
106110

107111
class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
@@ -894,14 +898,17 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
894898
@overload
895899
def __truediv__(self: Index[bool], other: np_ndarray_bool) -> Never: ...
896900
@overload
901+
def __truediv__(self, other: np_ndarray_dt) -> Never: ...
902+
@overload
903+
def __truediv__(self: Index[T_COMPLEX], other: np_ndarray_td) -> Never: ...
904+
@overload
897905
def __truediv__(
898906
self: Supports_ProtoTrueDiv[_T_contra, S2],
899907
other: _T_contra | Sequence[_T_contra],
900908
) -> Index[S2]: ...
901909
@overload
902910
def __truediv__(
903-
self: Index[int],
904-
other: np_ndarray_bool | Index[bool],
911+
self: Index[int], other: np_ndarray_bool | Index[bool]
905912
) -> Index[float]: ...
906913
@overload
907914
def __truediv__(
@@ -945,10 +952,12 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
945952
self: Index[Never], other: complex | ArrayLike | SequenceNotStr[S1] | Index
946953
) -> Index: ...
947954
@overload
948-
def __rtruediv__(self, other: Index[Never]) -> Index: ...
955+
def __rtruediv__(self, other: Index[Never]) -> Index: ... # type: ignore[overload-overlap]
949956
@overload
950957
def __rtruediv__(self: Index[bool], other: np_ndarray_bool) -> Never: ...
951958
@overload
959+
def __rtruediv__(self, other: np_ndarray_dt) -> Never: ...
960+
@overload
952961
def __rtruediv__(
953962
self: Supports_ProtoRTrueDiv[_T_contra, S2],
954963
other: _T_contra | Sequence[_T_contra],
@@ -993,13 +1002,91 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
9931002
),
9941003
) -> Index[complex]: ...
9951004
@overload
1005+
def __rtruediv__(
1006+
self: Index[int] | Index[float],
1007+
other: timedelta | np.timedelta64 | np_ndarray_td | TimedeltaIndex,
1008+
) -> TimedeltaIndex: ...
1009+
@overload
9961010
def __rtruediv__(self, other: Path) -> Index: ...
1011+
@overload
1012+
def __floordiv__(self, other: Index[Never]) -> Index: ...
1013+
@overload
9971014
def __floordiv__(
998-
self, other: float | Sequence[float] | Index[int] | Index[float]
999-
) -> Self: ...
1015+
self: Index[int] | Index[float],
1016+
other: np_ndarray_complex | np_ndarray_dt | np_ndarray_td,
1017+
) -> Never: ...
1018+
@overload
1019+
def __floordiv__(
1020+
self: Index[bool] | Index[complex], other: np_ndarray
1021+
) -> Never: ...
1022+
@overload
1023+
def __floordiv__(
1024+
self: Supports_ProtoFloorDiv[_T_contra, S2],
1025+
other: _T_contra | Sequence[_T_contra],
1026+
) -> Index[S2]: ...
1027+
@overload
1028+
def __floordiv__(
1029+
self: Index[int], other: np_ndarray_bool | Index[bool]
1030+
) -> Index[int]: ...
1031+
@overload
1032+
def __floordiv__(
1033+
self: Index[float], other: np_ndarray_bool | Index[bool]
1034+
) -> Index[float]: ...
1035+
@overload
1036+
def __floordiv__(
1037+
self: Index[bool] | Index[int], other: np_ndarray_anyint | Index[int]
1038+
) -> Index[int]: ...
1039+
@overload
1040+
def __floordiv__(
1041+
self: Index[float], other: np_ndarray_anyint | Index[int]
1042+
) -> Index[float]: ...
1043+
@overload
1044+
def __floordiv__(
1045+
self: Index[int] | Index[float],
1046+
other: float | Sequence[float] | np_ndarray_float | Index[float],
1047+
) -> Index[float]: ...
1048+
@overload
1049+
def __rfloordiv__(self, other: Index[Never]) -> Index: ... # type: ignore[overload-overlap]
1050+
@overload
10001051
def __rfloordiv__(
1001-
self, other: float | Sequence[float] | Index[int] | Index[float]
1002-
) -> Self: ...
1052+
self: Index[int] | Index[float],
1053+
other: np_ndarray_complex | np_ndarray_dt | np_ndarray_td,
1054+
) -> Never: ...
1055+
@overload
1056+
def __rfloordiv__(
1057+
self: Index[bool] | Index[complex], other: np_ndarray
1058+
) -> Never: ...
1059+
@overload
1060+
def __rfloordiv__(
1061+
self: Supports_ProtoRFloorDiv[_T_contra, S2],
1062+
other: _T_contra | Sequence[_T_contra],
1063+
) -> Index[S2]: ...
1064+
@overload
1065+
def __rfloordiv__(
1066+
self: Index[int], other: np_ndarray_bool | Index[bool]
1067+
) -> Index[int]: ...
1068+
@overload
1069+
def __rfloordiv__(
1070+
self: Index[float], other: np_ndarray_bool | Index[bool]
1071+
) -> Index[float]: ...
1072+
@overload
1073+
def __rfloordiv__(
1074+
self: Index[bool] | Index[int], other: np_ndarray_anyint | Index[int]
1075+
) -> Index[int]: ...
1076+
@overload
1077+
def __rfloordiv__(
1078+
self: Index[float], other: np_ndarray_anyint | Index[int]
1079+
) -> Index[float]: ...
1080+
@overload
1081+
def __rfloordiv__(
1082+
self: Index[int] | Index[float],
1083+
other: float | Sequence[float] | np_ndarray_float | Index[float],
1084+
) -> Index[float]: ...
1085+
@overload
1086+
def __rfloordiv__(
1087+
self: Index[int] | Index[float],
1088+
other: timedelta | np_ndarray_td | TimedeltaIndex,
1089+
) -> TimedeltaIndex: ...
10031090
def infer_objects(self, copy: bool = True) -> Self: ...
10041091

10051092
@type_check_only

0 commit comments

Comments
 (0)