Skip to content

Commit 5d21d0f

Browse files
committed
TST: Add tests for timedelta
1 parent e62cc10 commit 5d21d0f

File tree

2 files changed

+330
-18
lines changed

2 files changed

+330
-18
lines changed

pandas-stubs/_libs/tslibs/timedeltas.pyi

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ from datetime import timedelta
22
from typing import (
33
ClassVar,
44
Literal,
5+
NamedTuple,
56
TypeVar,
67
Union,
78
overload,
@@ -11,11 +12,21 @@ import numpy as np
1112
from typing_extensions import TypeAlias
1213

1314
from pandas._libs.tslibs import (
15+
BaseOffset,
1416
NaTType,
1517
Tick,
1618
)
1719
from pandas._typing import npt
1820

21+
class Components(NamedTuple):
22+
days: int
23+
hours: int
24+
minutes: int
25+
seconds: int
26+
milliseconds: int
27+
microseconds: int
28+
nanoseconds: int
29+
1930
# This should be kept consistent with the keys in the dict timedelta_abbrevs
2031
# in pandas/_libs/tslibs/timedeltas.pyx
2132
TimeDeltaUnitChoices: TypeAlias = Literal[
@@ -70,18 +81,6 @@ UnitChoices: TypeAlias = Union[
7081

7182
_S = TypeVar("_S", bound=timedelta)
7283

73-
def ints_to_pytimedelta(
74-
arr: npt.NDArray[np.int64], # const int64_t[:]
75-
box: bool = ...,
76-
) -> npt.NDArray[np.object_]: ...
77-
def array_to_timedelta64(
78-
values: npt.NDArray[np.object_],
79-
unit: str | None = ...,
80-
errors: str = ...,
81-
) -> np.ndarray: ... # np.ndarray[m8ns]
82-
def parse_timedelta_unit(unit: str | None) -> UnitChoices: ...
83-
def delta_to_nanoseconds(delta: np.timedelta64 | timedelta | Tick) -> int: ...
84-
8584
class Timedelta(timedelta):
8685
min: ClassVar[Timedelta]
8786
max: ClassVar[Timedelta]
@@ -106,6 +105,8 @@ class Timedelta(timedelta):
106105
@property
107106
def days(self) -> int: ...
108107
@property
108+
def nanoseconds(self) -> int: ...
109+
@property
109110
def seconds(self) -> int: ...
110111
@property
111112
def microseconds(self) -> int: ...
@@ -115,9 +116,9 @@ class Timedelta(timedelta):
115116
@property
116117
def asm8(self) -> np.timedelta64: ...
117118
# TODO: round/floor/ceil could return NaT?
118-
def round(self: _S, freq: str) -> _S: ...
119-
def floor(self: _S, freq: str) -> _S: ...
120-
def ceil(self: _S, freq: str) -> _S: ...
119+
def round(self: _S, freq: str | BaseOffset) -> _S: ...
120+
def floor(self: _S, freq: str | BaseOffset) -> _S: ...
121+
def ceil(self: _S, freq: str | BaseOffset) -> _S: ...
121122
@property
122123
def resolution_string(self) -> str: ...
123124
def __add__(self, other: timedelta) -> Timedelta: ...
@@ -162,6 +163,5 @@ class Timedelta(timedelta):
162163
def isoformat(self) -> str: ...
163164
def to_numpy(self) -> np.timedelta64: ...
164165
@property
165-
def freq(self) -> None: ...
166-
@property
167-
def is_populated(self) -> bool: ...
166+
def components(self) -> Components: ...
167+
def view(self, dtype: npt.DTypeLike = ...) -> object: ...

0 commit comments

Comments
 (0)