|
| 1 | +from datetime import timedelta |
| 2 | +from typing import ( |
| 3 | + ClassVar, |
| 4 | + Type, |
| 5 | + TypeVar, |
| 6 | + overload, |
| 7 | +) |
| 8 | + |
| 9 | +import numpy as np |
| 10 | + |
| 11 | +from pandas._libs.tslibs import ( |
| 12 | + NaTType, |
| 13 | + Tick, |
| 14 | +) |
| 15 | + |
| 16 | +_S = TypeVar("_S") |
| 17 | + |
| 18 | + |
| 19 | +def ints_to_pytimedelta( |
| 20 | + arr: np.ndarray, # const int64_t[:] |
| 21 | + box: bool = ..., |
| 22 | +) -> np.ndarray: ... # np.ndarray[object] |
| 23 | + |
| 24 | + |
| 25 | +def array_to_timedelta64( |
| 26 | + values: np.ndarray, # ndarray[object] |
| 27 | + unit: str | None = ..., |
| 28 | + errors: str = ..., |
| 29 | +) -> np.ndarray: ... # np.ndarray[m8ns] |
| 30 | + |
| 31 | + |
| 32 | +def parse_timedelta_unit(unit: str | None) -> str: ... |
| 33 | + |
| 34 | + |
| 35 | +def delta_to_nanoseconds(delta: Tick | np.timedelta64 | timedelta | int) -> int: ... |
| 36 | + |
| 37 | + |
| 38 | +class Timedelta(timedelta): |
| 39 | + min: ClassVar[Timedelta] |
| 40 | + max: ClassVar[Timedelta] |
| 41 | + resolution: ClassVar[Timedelta] |
| 42 | + value: int # np.int64 |
| 43 | + |
| 44 | + # error: "__new__" must return a class instance (got "Union[Timedelta, NaTType]") |
| 45 | + def __new__( # type: ignore[misc] |
| 46 | + cls: Type[_S], |
| 47 | + value=..., |
| 48 | + unit=..., |
| 49 | + **kwargs |
| 50 | + ) -> _S | NaTType: ... |
| 51 | + |
| 52 | + @property |
| 53 | + def days(self) -> int: ... |
| 54 | + @property |
| 55 | + def seconds(self) -> int: ... |
| 56 | + @property |
| 57 | + def microseconds(self) -> int: ... |
| 58 | + def total_seconds(self) -> float: ... |
| 59 | + |
| 60 | + def to_pytimedelta(self) -> timedelta: ... |
| 61 | + def to_timedelta64(self) -> np.timedelta64: ... |
| 62 | + |
| 63 | + @property |
| 64 | + def asm8(self) -> np.timedelta64: ... |
| 65 | + |
| 66 | + # TODO: round/floor/ceil could return NaT? |
| 67 | + def round(self: _S, freq) -> _S: ... |
| 68 | + def floor(self: _S, freq) -> _S: ... |
| 69 | + def ceil(self: _S, freq) -> _S: ... |
| 70 | + |
| 71 | + @property |
| 72 | + def resolution_string(self) -> str: ... |
| 73 | + |
| 74 | + def __add__(self, other: timedelta) -> timedelta: ... |
| 75 | + def __radd__(self, other: timedelta) -> timedelta: ... |
| 76 | + def __sub__(self, other: timedelta) -> timedelta: ... |
| 77 | + def __rsub__(self, other: timedelta) -> timedelta: ... |
| 78 | + def __neg__(self) -> timedelta: ... |
| 79 | + def __pos__(self) -> timedelta: ... |
| 80 | + def __abs__(self) -> timedelta: ... |
| 81 | + def __mul__(self, other: float) -> timedelta: ... |
| 82 | + def __rmul__(self, other: float) -> timedelta: ... |
| 83 | + |
| 84 | + @overload |
| 85 | + def __floordiv__(self, other: timedelta) -> int: ... |
| 86 | + @overload |
| 87 | + def __floordiv__(self, other: int) -> timedelta: ... |
| 88 | + |
| 89 | + @overload |
| 90 | + def __truediv__(self, other: timedelta) -> float: ... |
| 91 | + @overload |
| 92 | + def __truediv__(self, other: float) -> timedelta: ... |
| 93 | + def __mod__(self, other: timedelta) -> timedelta: ... |
| 94 | + def __divmod__(self, other: timedelta) -> tuple[int, timedelta]: ... |
| 95 | + |
| 96 | + def __le__(self, other: timedelta) -> bool: ... |
| 97 | + def __lt__(self, other: timedelta) -> bool: ... |
| 98 | + def __ge__(self, other: timedelta) -> bool: ... |
| 99 | + def __gt__(self, other: timedelta) -> bool: ... |
| 100 | + def __hash__(self) -> int: ... |
0 commit comments