|
1 | 1 | from typing import ( |
2 | 2 | Any, |
3 | 3 | Generic, |
| 4 | + Literal, |
4 | 5 | TypeVar, |
5 | 6 | overload, |
6 | 7 | ) |
7 | 8 |
|
8 | 9 | import numpy as np |
9 | 10 | from pandas import ( |
| 11 | + IntervalIndex, |
| 12 | + Series, |
10 | 13 | Timedelta, |
11 | 14 | Timestamp, |
12 | 15 | ) |
13 | 16 |
|
14 | 17 | from pandas._typing import ( |
15 | 18 | IntervalClosedType, |
| 19 | + IntervalT, |
| 20 | + np_ndarray_bool, |
16 | 21 | npt, |
17 | 22 | ) |
18 | 23 |
|
@@ -123,28 +128,73 @@ class Interval(IntervalMixin, Generic[_OrderableT]): |
123 | 128 | @overload |
124 | 129 | def __mul__(self: Interval[float], y: float) -> Interval[float]: ... |
125 | 130 | @overload |
| 131 | + def __mul__(self: Interval[Timedelta], y: float) -> Interval[Timedelta]: ... |
| 132 | + @overload |
126 | 133 | def __rmul__( |
127 | 134 | self: Interval[int], y: _OrderableScalarT |
128 | 135 | ) -> Interval[_OrderableScalarT]: ... |
129 | 136 | @overload |
130 | 137 | def __rmul__(self: Interval[float], y: float) -> Interval[float]: ... |
131 | 138 | @overload |
132 | | - def __truediv__( |
133 | | - self: Interval[int], y: _OrderableScalarT |
134 | | - ) -> Interval[_OrderableScalarT]: ... |
| 139 | + def __rmul__(self: Interval[Timedelta], y: float) -> Interval[Timedelta]: ... |
| 140 | + @overload |
| 141 | + def __truediv__(self: Interval[int], y: _OrderableScalarT) -> Interval[float]: ... |
135 | 142 | @overload |
136 | 143 | def __truediv__(self: Interval[float], y: float) -> Interval[float]: ... |
137 | 144 | @overload |
| 145 | + def __truediv__(self: Interval[Timedelta], y: float) -> Interval[Timedelta]: ... |
| 146 | + @overload |
138 | 147 | def __floordiv__( |
139 | 148 | self: Interval[int], y: _OrderableScalarT |
140 | 149 | ) -> Interval[_OrderableScalarT]: ... |
141 | 150 | @overload |
142 | 151 | def __floordiv__(self: Interval[float], y: float) -> Interval[float]: ... |
| 152 | + @overload |
| 153 | + def __floordiv__(self: Interval[Timedelta], y: float) -> Interval[Timedelta]: ... |
| 154 | + @overload |
143 | 155 | def overlaps(self: Interval[_OrderableT], other: Interval[_OrderableT]) -> bool: ... |
144 | | - |
145 | | -def intervals_to_interval_bounds( |
146 | | - intervals: np.ndarray, validate_closed: bool = ... |
147 | | -) -> tuple[np.ndarray, np.ndarray, str]: ... |
| 156 | + @overload |
| 157 | + def overlaps(self: Interval[int], other: Interval[float]) -> bool: ... |
| 158 | + @overload |
| 159 | + def overlaps(self: Interval[float], other: Interval[int]) -> bool: ... |
| 160 | + @overload |
| 161 | + def __gt__(self, other: Interval[_OrderableT]) -> bool: ... |
| 162 | + @overload |
| 163 | + def __gt__(self: IntervalT, other: IntervalIndex[IntervalT]) -> np_ndarray_bool: ... |
| 164 | + @overload |
| 165 | + def __gt__(self, other: Series[_OrderableT]) -> Series[bool]: ... |
| 166 | + @overload |
| 167 | + def __lt__(self, other: Interval[_OrderableT]) -> bool: ... |
| 168 | + @overload |
| 169 | + def __lt__(self: IntervalT, other: IntervalIndex[IntervalT]) -> np_ndarray_bool: ... |
| 170 | + @overload |
| 171 | + def __lt__(self, other: Series[_OrderableT]) -> Series[bool]: ... |
| 172 | + @overload |
| 173 | + def __ge__(self, other: Interval[_OrderableT]) -> bool: ... |
| 174 | + @overload |
| 175 | + def __ge__(self: IntervalT, other: IntervalIndex[IntervalT]) -> np_ndarray_bool: ... |
| 176 | + @overload |
| 177 | + def __ge__(self, other: Series[_OrderableT]) -> Series[bool]: ... |
| 178 | + @overload |
| 179 | + def __le__(self, other: Interval[_OrderableT]) -> bool: ... |
| 180 | + @overload |
| 181 | + def __le__(self: IntervalT, other: IntervalIndex[IntervalT]) -> np_ndarray_bool: ... |
| 182 | + @overload |
| 183 | + def __eq__(self, other: Interval[_OrderableT]) -> bool: ... # type: ignore[misc] |
| 184 | + @overload |
| 185 | + def __eq__(self: IntervalT, other: IntervalIndex[IntervalT]) -> np_ndarray_bool: ... # type: ignore[misc] |
| 186 | + @overload |
| 187 | + def __eq__(self, other: Series[_OrderableT]) -> Series[bool]: ... # type: ignore[misc] |
| 188 | + @overload |
| 189 | + def __eq__(self, other: object) -> Literal[False]: ... |
| 190 | + @overload |
| 191 | + def __ne__(self, other: Interval[_OrderableT]) -> bool: ... # type: ignore[misc] |
| 192 | + @overload |
| 193 | + def __ne__(self: IntervalT, other: IntervalIndex[IntervalT]) -> np_ndarray_bool: ... # type: ignore[misc] |
| 194 | + @overload |
| 195 | + def __ne__(self, other: Series[_OrderableT]) -> Series[bool]: ... # type: ignore[misc] |
| 196 | + @overload |
| 197 | + def __ne__(self, other: object) -> Literal[True]: ... |
148 | 198 |
|
149 | 199 | class IntervalTree(IntervalMixin): |
150 | 200 | def __init__( |
|
0 commit comments