Skip to content

Commit bc6e9d4

Browse files

File tree

14 files changed

+343
-431
lines changed

14 files changed

+343
-431
lines changed

pandas-stubs/core/resample.pyi

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,6 @@ class Resampler(BaseGroupBy[NDFrameT]):
9292
def nearest(self, limit: int | None = ...) -> NDFrameT: ...
9393
@final
9494
def bfill(self, limit: int | None = ...) -> NDFrameT: ...
95-
@overload
96-
def interpolate(
97-
self,
98-
method: InterpolateOptions = ...,
99-
*,
100-
axis: Axis = ...,
101-
limit: int | None = ...,
102-
inplace: Literal[True],
103-
limit_direction: Literal["forward", "backward", "both"] = ...,
104-
limit_area: Literal["inside", "outside"] | None = ...,
105-
**kwargs: Any,
106-
) -> None: ...
107-
@overload
10895
def interpolate(
10996
self,
11097
method: InterpolateOptions = ...,

tests/arrays/test_extension_array.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from tests import (
1515
check,
1616
np_1darray,
17+
np_1darray_intp,
1718
)
1819

1920

@@ -50,6 +51,6 @@ def test_ea_common() -> None:
5051
check(assert_type(arr.view(), IntegerArray), IntegerArray)
5152

5253
check(assert_type(arr.searchsorted(1), np.intp), np.intp)
53-
check(assert_type(arr.searchsorted([1]), "np_1darray[np.intp]"), np_1darray)
54+
check(assert_type(arr.searchsorted([1]), np_1darray_intp), np_1darray_intp)
5455
check(assert_type(arr.searchsorted(1, side="left"), np.intp), np.intp)
5556
check(assert_type(arr.searchsorted(1, sorter=[1, 0, 2]), np.intp), np.intp)

tests/indexes/test_categoricalindex.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
from __future__ import annotations
22

3-
import numpy as np
43
import pandas as pd
54
from typing_extensions import (
65
assert_type,
76
)
87

98
from tests import (
109
check,
11-
np_1darray,
10+
np_1darray_intp,
1211
)
1312

1413

@@ -23,7 +22,7 @@ def test_categoricalindex_unique() -> None:
2322
def test_categoricalindex_reindex() -> None:
2423
ci = pd.CategoricalIndex(["a", "b"])
2524
check(
26-
assert_type(ci.reindex([0, 1]), tuple[pd.Index, np_1darray[np.intp] | None]),
25+
assert_type(ci.reindex([0, 1]), tuple[pd.Index, np_1darray_intp | None]),
2726
tuple,
2827
)
2928

tests/indexes/test_datetime_index.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
from tests import (
1010
check,
11-
np_1darray,
11+
np_1darray_bool,
12+
np_1darray_intp,
1213
)
1314

1415

@@ -34,10 +35,10 @@ def test_index_relops() -> None:
3435
check(assert_type(data[idx > x], pd.DatetimeIndex), pd.DatetimeIndex)
3536

3637
ind = pd.Index([1, 2, 3])
37-
check(assert_type(ind <= 2, np_1darray[np.bool]), np_1darray[np.bool])
38-
check(assert_type(ind < 2, np_1darray[np.bool]), np_1darray[np.bool])
39-
check(assert_type(ind >= 2, np_1darray[np.bool]), np_1darray[np.bool])
40-
check(assert_type(ind > 2, np_1darray[np.bool]), np_1darray[np.bool])
38+
check(assert_type(ind <= 2, np_1darray_bool), np_1darray_bool)
39+
check(assert_type(ind < 2, np_1darray_bool), np_1darray_bool)
40+
check(assert_type(ind >= 2, np_1darray_bool), np_1darray_bool)
41+
check(assert_type(ind > 2, np_1darray_bool), np_1darray_bool)
4142

4243

4344
def test_datetime_index_constructor() -> None:
@@ -92,14 +93,8 @@ def test_datetimeindex_shift() -> None:
9293

9394
def test_datetimeindex_indexer_at_time() -> None:
9495
dti = pd.date_range("2023-01-01", "2023-02-01")
95-
check(
96-
assert_type(dti.indexer_at_time("10:00"), np_1darray[np.intp]),
97-
np_1darray[np.intp],
98-
)
99-
check(
100-
assert_type(dti.indexer_at_time(time(10)), np_1darray[np.intp]),
101-
np_1darray[np.intp],
102-
)
96+
check(assert_type(dti.indexer_at_time("10:00"), np_1darray_intp), np_1darray_intp)
97+
check(assert_type(dti.indexer_at_time(time(10)), np_1darray_intp), np_1darray_intp)
10398

10499

105100
def test_datetimeindex_indexer_between_time() -> None:
@@ -109,13 +104,13 @@ def test_datetimeindex_indexer_between_time() -> None:
109104
dti.indexer_between_time(
110105
"10:00", time(11), include_start=False, include_end=True
111106
),
112-
np_1darray[np.intp],
107+
np_1darray_intp,
113108
),
114-
np_1darray[np.intp],
109+
np_1darray_intp,
115110
)
116111
check(
117-
assert_type(dti.indexer_between_time(time(10), "11:00"), np_1darray[np.intp]),
118-
np_1darray[np.intp],
112+
assert_type(dti.indexer_between_time(time(10), "11:00"), np_1darray_intp),
113+
np_1darray_intp,
119114
)
120115

121116

tests/indexes/test_indexes.py

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
TYPE_CHECKING_INVALID_USAGE,
2929
check,
3030
np_1darray,
31+
np_1darray_bool,
32+
np_1darray_int64,
33+
np_1darray_intp,
3134
np_ndarray_dt,
3235
pytest_warns_bounded,
3336
)
@@ -48,13 +51,13 @@ def test_index_duplicated() -> None:
4851
df = pd.DataFrame({"x": [1, 2, 3, 4]}, index=pd.Index([1, 2, 3, 2]))
4952
ind = df.index
5053
duplicated = ind.duplicated("first")
51-
check(assert_type(duplicated, np_1darray[np.bool]), np_1darray[np.bool])
54+
check(assert_type(duplicated, np_1darray_bool), np_1darray_bool)
5255

5356

5457
def test_index_isin() -> None:
5558
ind = pd.Index([1, 2, 3, 4, 5])
5659
isin = ind.isin([2, 4])
57-
check(assert_type(isin, np_1darray[np.bool]), np_1darray[np.bool])
60+
check(assert_type(isin, np_1darray_bool), np_1darray_bool)
5861

5962

6063
def test_index_astype() -> None:
@@ -248,11 +251,8 @@ def test_types_to_numpy() -> None:
248251
check(assert_type(idx.to_numpy(na_value=0), np_1darray), np_1darray)
249252

250253
r_idx = pd.RangeIndex(2)
251-
check(assert_type(r_idx.to_numpy(), np_1darray[np.int64]), np_1darray[np.int64])
252-
check(
253-
assert_type(r_idx.to_numpy(na_value=0), np_1darray[np.int64]),
254-
np_1darray[np.int64],
255-
)
254+
check(assert_type(r_idx.to_numpy(), np_1darray_int64), np_1darray_int64)
255+
check(assert_type(r_idx.to_numpy(na_value=0), np_1darray_int64), np_1darray_int64)
256256
check(
257257
assert_type(r_idx.to_numpy(dtype="int", copy=True), np_1darray),
258258
np_1darray,
@@ -1191,38 +1191,32 @@ def test_datetime_operators_builtin() -> None:
11911191
def test_get_loc() -> None:
11921192
unique_index = pd.Index(list("abc"))
11931193
check(
1194-
assert_type(unique_index.get_loc("b"), int | slice | np_1darray[np.bool]),
1194+
assert_type(unique_index.get_loc("b"), int | slice | np_1darray_bool),
11951195
int,
11961196
)
11971197

11981198
monotonic_index = pd.Index(list("abbc"))
11991199
check(
1200-
assert_type(monotonic_index.get_loc("b"), int | slice | np_1darray[np.bool]),
1200+
assert_type(monotonic_index.get_loc("b"), int | slice | np_1darray_bool),
12011201
slice,
12021202
)
12031203

12041204
non_monotonic_index = pd.Index(list("abcb"))
12051205
check(
1206-
assert_type(
1207-
non_monotonic_index.get_loc("b"), int | slice | np_1darray[np.bool]
1208-
),
1209-
np_1darray[np.bool],
1206+
assert_type(non_monotonic_index.get_loc("b"), int | slice | np_1darray_bool),
1207+
np_1darray_bool,
12101208
)
12111209

12121210
i1, i2, i3 = pd.Interval(0, 1), pd.Interval(1, 2), pd.Interval(0, 2)
12131211
unique_interval_index = pd.IntervalIndex([i1, i2])
12141212
check(
1215-
assert_type(
1216-
unique_interval_index.get_loc(i1), int | slice | np_1darray[np.bool]
1217-
),
1213+
assert_type(unique_interval_index.get_loc(i1), int | slice | np_1darray_bool),
12181214
np.int64,
12191215
)
12201216
overlap_interval_index = pd.IntervalIndex([i1, i2, i3])
12211217
check(
1222-
assert_type(
1223-
overlap_interval_index.get_loc(1), int | slice | np_1darray[np.bool]
1224-
),
1225-
np_1darray[np.bool],
1218+
assert_type(overlap_interval_index.get_loc(1), int | slice | np_1darray_bool),
1219+
np_1darray_bool,
12261220
)
12271221

12281222

@@ -1367,13 +1361,13 @@ def test_index_naming() -> None:
13671361
def test_index_searchsorted() -> None:
13681362
idx = pd.Index([1, 2, 3])
13691363
check(assert_type(idx.searchsorted(1), np.intp), np.intp)
1370-
check(assert_type(idx.searchsorted([1]), "np_1darray[np.intp]"), np_1darray)
1371-
check(assert_type(idx.searchsorted(range(1, 2)), "np_1darray[np.intp]"), np_1darray)
1364+
check(assert_type(idx.searchsorted([1]), np_1darray_intp), np_1darray_intp)
1365+
check(assert_type(idx.searchsorted(range(1, 2)), np_1darray_intp), np_1darray_intp)
13721366
check(
1373-
assert_type(idx.searchsorted(pd.Series([1])), "np_1darray[np.intp]"), np_1darray
1367+
assert_type(idx.searchsorted(pd.Series([1])), np_1darray_intp), np_1darray_intp
13741368
)
13751369
check(
1376-
assert_type(idx.searchsorted(np.array([1])), "np_1darray[np.intp]"), np_1darray
1370+
assert_type(idx.searchsorted(np.array([1])), np_1darray_intp), np_1darray_intp
13771371
)
13781372
check(assert_type(idx.searchsorted(1, side="left"), np.intp), np.intp)
13791373
check(assert_type(idx.searchsorted(1, sorter=[1, 0, 2]), np.intp), np.intp)
@@ -1397,10 +1391,7 @@ def test_period_index_asof_locs() -> None:
13971391
idx = pd.PeriodIndex(["2000", "2001"], freq="D")
13981392
where = pd.DatetimeIndex(["2023-05-30 00:12:00", "2023-06-01 00:00:00"])
13991393
mask = np.ones(2, dtype=bool)
1400-
check(
1401-
assert_type(idx.asof_locs(where, mask), np_1darray[np.intp]),
1402-
np_1darray[np.intp],
1403-
)
1394+
check(assert_type(idx.asof_locs(where, mask), np_1darray_intp), np_1darray_intp)
14041395

14051396

14061397
def test_array_property() -> None:

tests/indexes/test_rangeindex.py

Lines changed: 11 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,54 @@
11
from __future__ import annotations
22

3-
import numpy as np
43
import pandas as pd
54
from typing_extensions import (
65
assert_type,
76
)
87

98
from tests import (
109
check,
11-
np_1darray,
10+
np_1darray_intp,
1211
)
1312

1413

1514
def test_rangeindex_floordiv() -> None:
1615
ri = pd.RangeIndex(3)
17-
check(
18-
assert_type(ri // 2, "pd.Index[int]"),
19-
pd.Index,
20-
)
16+
check(assert_type(ri // 2, "pd.Index[int]"), pd.Index)
2117

2218

2319
def test_rangeindex_min_max() -> None:
2420
ri = pd.RangeIndex(3)
25-
check(
26-
assert_type(ri.min(), int),
27-
int,
28-
)
29-
check(
30-
assert_type(ri.max(axis=0), int),
31-
int,
32-
)
21+
check(assert_type(ri.min(), int), int)
22+
check(assert_type(ri.max(axis=0), int), int)
3323

3424

3525
def test_rangeindex_equals() -> None:
3626
ri = pd.RangeIndex(3)
37-
check(
38-
assert_type(ri.equals(ri), bool),
39-
bool,
40-
)
27+
check(assert_type(ri.equals(ri), bool), bool)
4128

4229

4330
def test_rangeindex_tolist() -> None:
4431
ri = pd.RangeIndex.from_range(range(3))
45-
check(
46-
assert_type(ri.tolist(), list[int]),
47-
list[int],
48-
)
32+
check(assert_type(ri.tolist(), list[int]), list[int])
4933

5034

5135
def test_rangeindex_get_indexer() -> None:
5236
ri = pd.RangeIndex.from_range(range(3))
53-
check(
54-
assert_type(ri.get_indexer(ri), np_1darray[np.intp]),
55-
np_1darray[np.intp],
56-
)
37+
check(assert_type(ri.get_indexer(ri), np_1darray_intp), np_1darray_intp)
5738

5839

5940
def test_rangeindex_argsort() -> None:
6041
ri = pd.RangeIndex.from_range(range(3))
61-
check(
62-
assert_type(ri.argsort(), np_1darray[np.intp]),
63-
np_1darray[np.intp],
64-
)
42+
check(assert_type(ri.argsort(), np_1darray_intp), np_1darray_intp)
6543

6644

6745
def test_rangeindex_join() -> None:
6846
ri = pd.RangeIndex.from_range(range(3))
69-
check(
70-
assert_type(ri.join(ri), pd.Index),
71-
pd.Index,
72-
)
47+
check(assert_type(ri.join(ri), pd.Index), pd.Index)
7348
check(
7449
assert_type(
7550
ri.join(ri, return_indexers=True),
76-
tuple[pd.Index, np_1darray[np.intp] | None, np_1darray[np.intp] | None],
51+
tuple[pd.Index, np_1darray_intp | None, np_1darray_intp | None],
7752
),
78-
tuple[pd.Index, np_1darray[np.intp] | None, np_1darray[np.intp] | None],
53+
tuple[pd.Index, np_1darray_intp | None, np_1darray_intp | None],
7954
)

0 commit comments

Comments
 (0)