Skip to content

Commit 1611528

Browse files
committed
Fix all functions in pandas.testing
1 parent 03cbbd7 commit 1611528

File tree

1 file changed

+92
-40
lines changed

1 file changed

+92
-40
lines changed

pandas-stubs/_testing/__init__.pyi

Lines changed: 92 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,105 @@
1-
from collections.abc import Generator
1+
from collections.abc import (
2+
Container,
3+
Generator,
4+
Iterable,
5+
)
26
from contextlib import contextmanager
37
from typing import (
48
Any,
59
Literal,
610
overload,
711
)
12+
import warnings
813

14+
from matplotlib.artist import Artist
915
import numpy as np
1016
from pandas import (
17+
Categorical,
1118
DataFrame,
1219
Index,
1320
Series,
1421
)
22+
from pandas.arrays import (
23+
DatetimeArray,
24+
IntervalArray,
25+
PeriodArray,
26+
SparseArray,
27+
TimedeltaArray,
28+
)
29+
from pandas.core.arrays.base import ExtensionArray
30+
31+
from pandas._typing import (
32+
AnyArrayLike,
33+
T,
34+
)
1535

16-
def assert_almost_equal(left, right, check_dtype: bool | str = ..., **kwargs): ...
17-
def assert_dict_equal(left, right, compare_keys: bool = ...): ...
18-
def assert_index_equal(left: Index, right: Index) -> None: ...
19-
def assert_class_equal(left, right, exact: bool | str = ..., obj=...): ...
20-
def assert_attr_equal(attr, left, right, obj: str = ...): ...
21-
def assert_is_valid_plot_return_object(objs) -> None: ...
22-
def assert_is_sorted(seq) -> None: ...
36+
def assert_almost_equal(
37+
left: T,
38+
right: T,
39+
check_dtype: bool | Literal["equiv"] = ...,
40+
rtol: float = ...,
41+
atol: float = ...,
42+
**kwargs,
43+
) -> None: ...
44+
def assert_dict_equal(left: dict, right: dict, compare_keys: bool = ...) -> None: ...
45+
def assert_index_equal(
46+
left: Index,
47+
right: Index,
48+
exact: bool | Literal["equiv"] = ...,
49+
check_names: bool = ...,
50+
check_exact: bool = ...,
51+
check_categorical: bool = ...,
52+
check_order: bool = ...,
53+
rtol: float = ...,
54+
atol: float = ...,
55+
obj: str = ...,
56+
) -> None: ...
57+
def assert_class_equal(
58+
left: T, right: T, exact: bool | Literal["equiv"] = ..., obj: str = ...
59+
) -> None: ...
60+
def assert_attr_equal(
61+
attr: str, left: object, right: object, obj: str = ...
62+
) -> None: ...
63+
def assert_is_valid_plot_return_object(
64+
objs: Series | np.ndarray | Artist | tuple | dict,
65+
) -> None: ...
66+
def assert_is_sorted(seq: AnyArrayLike) -> None: ...
2367
def assert_categorical_equal(
24-
left,
25-
right,
68+
left: Categorical,
69+
right: Categorical,
2670
check_dtype: bool = ...,
2771
check_category_order: bool = ...,
2872
obj: str = ...,
2973
) -> None: ...
3074
def assert_interval_array_equal(
31-
left, right, exact: str = ..., obj: str = ...
75+
left: IntervalArray,
76+
right: IntervalArray,
77+
exact: bool | Literal["equiv"] = ...,
78+
obj: str = ...,
79+
) -> None: ...
80+
def assert_period_array_equal(
81+
left: PeriodArray, right: PeriodArray, obj: str = ...
82+
) -> None: ...
83+
def assert_datetime_array_equal(
84+
left: DatetimeArray, right: DatetimeArray, check_freq: bool = ...
85+
) -> None: ...
86+
def assert_timedelta_array_equal(
87+
left: TimedeltaArray, right: TimedeltaArray, check_freq: bool = ...
3288
) -> None: ...
33-
def assert_period_array_equal(left, right, obj: str = ...) -> None: ...
34-
def assert_datetime_array_equal(left, right, obj: str = ...) -> None: ...
35-
def assert_timedelta_array_equal(left, right, obj: str = ...) -> None: ...
3689
def assert_numpy_array_equal(
3790
left,
3891
right,
3992
strict_nan: bool = ...,
40-
check_dtype: bool = ...,
41-
err_msg=...,
42-
check_same=...,
93+
check_dtype: bool | Literal["equiv"] = ...,
94+
err_msg: str | None = ...,
95+
check_same: Literal["copy", "same"] | None = ...,
4396
obj: str = ...,
44-
): ...
97+
index_values: Index | np.ndarray | None = ...,
98+
) -> None: ...
4599
def assert_extension_array_equal(
46-
left,
47-
right,
48-
check_dtype: bool = ...,
100+
left: ExtensionArray,
101+
right: ExtensionArray,
102+
check_dtype: bool | Literal["equiv"] = ...,
49103
index_values: Index | np.ndarray | None = ...,
50104
check_exact: bool = ...,
51105
rtol: float = ...,
@@ -56,8 +110,8 @@ def assert_extension_array_equal(
56110
def assert_series_equal(
57111
left: Series,
58112
right: Series,
59-
check_dtype: bool = ...,
60-
check_index_type: bool | str = ...,
113+
check_dtype: bool | Literal["equiv"] = ...,
114+
check_index_type: bool | Literal["equiv"] = ...,
61115
check_series_type: bool = ...,
62116
check_names: bool = ...,
63117
check_exact: bool = ...,
@@ -77,8 +131,8 @@ def assert_series_equal(
77131
def assert_series_equal(
78132
left: Series,
79133
right: Series,
80-
check_dtype: bool = ...,
81-
check_index_type: bool | str = ...,
134+
check_dtype: bool | Literal["equiv"] = ...,
135+
check_index_type: bool | Literal["equiv"] = ...,
82136
check_series_type: bool = ...,
83137
check_names: bool = ...,
84138
check_exact: bool = ...,
@@ -108,29 +162,27 @@ def assert_frame_equal(
108162
check_categorical: bool = ...,
109163
check_like: bool = ...,
110164
check_freq: bool = ...,
111-
check_flag: bool = ...,
165+
check_flags: bool = ...,
112166
rtol: float = ...,
113167
atol: float = ...,
114168
obj: str = ...,
115169
) -> None: ...
116170
def assert_equal(left, right, **kwargs) -> None: ...
117-
def assert_sp_array_equal(
118-
left,
119-
right,
120-
check_dtype: bool = ...,
121-
check_kind: bool = ...,
122-
check_fill_value: bool = ...,
123-
consolidate_block_indices: bool = ...,
124-
) -> None: ...
125-
def assert_contains_all(iterable, dic) -> None: ...
126-
def assert_copy(iter1, iter2, **eql_kwargs) -> None: ...
171+
def assert_sp_array_equal(left: SparseArray, right: SparseArray) -> None: ...
172+
def assert_contains_all(iterable: Iterable[T], dic: Container[T]) -> None: ...
173+
def assert_copy(iter1: Iterable[T], iter2: Iterable[T], **eql_kwargs) -> None: ...
174+
@contextmanager
127175
def assert_produces_warning(
128-
expected_warning=...,
129-
filter_level: str = ...,
130-
clear=...,
176+
expected_warning: (
177+
type[Warning] | Literal[False] | tuple[type[Warning], ...] | None
178+
) = ...,
179+
filter_level: Literal[
180+
"error", "ignore", "always", "default", "module", "once"
181+
] = ...,
131182
check_stacklevel: bool = ...,
132183
raise_on_extra_warnings: bool = ...,
133-
) -> None: ...
184+
match: str | None = None,
185+
) -> Generator[list[warnings.WarningMessage], None, None]: ...
134186
@contextmanager
135187
def ensure_clean(
136188
filename: str | None = ..., return_filelike: bool = ..., **kwargs: Any

0 commit comments

Comments
 (0)