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
5457def 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
6063def 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:
11911191def 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:
13671361def 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
14061397def test_array_property () -> None :
0 commit comments