@@ -275,37 +275,6 @@ def test_index_arithmetic() -> None:
275275 check (assert_type (3 // idx , "pd.Index[float]" ), pd .Index , np .float64 )
276276
277277
278- def test_index_relops () -> None :
279- # GH 265
280- data = pd .date_range ("2022-01-01" , "2022-01-31" , freq = "D" )
281- x = pd .Timestamp ("2022-01-17" )
282- idx = pd .Index (data , name = "date" )
283- check (assert_type (data [x <= idx ], pd .DatetimeIndex ), pd .DatetimeIndex )
284- check (assert_type (data [x < idx ], pd .DatetimeIndex ), pd .DatetimeIndex )
285- check (assert_type (data [x >= idx ], pd .DatetimeIndex ), pd .DatetimeIndex )
286- check (assert_type (data [x > idx ], pd .DatetimeIndex ), pd .DatetimeIndex )
287- check (assert_type (data [idx < x ], pd .DatetimeIndex ), pd .DatetimeIndex )
288- check (assert_type (data [idx >= x ], pd .DatetimeIndex ), pd .DatetimeIndex )
289- check (assert_type (data [idx > x ], pd .DatetimeIndex ), pd .DatetimeIndex )
290- check (assert_type (data [idx <= x ], pd .DatetimeIndex ), pd .DatetimeIndex )
291-
292- dt_idx = pd .DatetimeIndex (data , name = "date" )
293- check (assert_type (data [x <= dt_idx ], pd .DatetimeIndex ), pd .DatetimeIndex )
294- check (assert_type (data [x >= dt_idx ], pd .DatetimeIndex ), pd .DatetimeIndex )
295- check (assert_type (data [x < dt_idx ], pd .DatetimeIndex ), pd .DatetimeIndex )
296- check (assert_type (data [x > dt_idx ], pd .DatetimeIndex ), pd .DatetimeIndex )
297- check (assert_type (data [dt_idx <= x ], pd .DatetimeIndex ), pd .DatetimeIndex )
298- check (assert_type (data [dt_idx >= x ], pd .DatetimeIndex ), pd .DatetimeIndex )
299- check (assert_type (data [dt_idx < x ], pd .DatetimeIndex ), pd .DatetimeIndex )
300- check (assert_type (data [dt_idx > x ], pd .DatetimeIndex ), pd .DatetimeIndex )
301-
302- ind = pd .Index ([1 , 2 , 3 ])
303- check (assert_type (ind <= 2 , np_1darray [np .bool ]), np_1darray [np .bool ])
304- check (assert_type (ind >= 2 , np_1darray [np .bool ]), np_1darray [np .bool ])
305- check (assert_type (ind < 2 , np_1darray [np .bool ]), np_1darray [np .bool ])
306- check (assert_type (ind > 2 , np_1darray [np .bool ]), np_1darray [np .bool ])
307-
308-
309278def test_range_index_union () -> None :
310279 check (
311280 assert_type (
@@ -1167,33 +1136,6 @@ def test_index_constructors() -> None:
11671136 pd .Index (flist , dtype = np .float16 )
11681137
11691138
1170- def test_datetime_index_constructor () -> None :
1171- check (assert_type (pd .DatetimeIndex (["2020" ]), pd .DatetimeIndex ), pd .DatetimeIndex )
1172- check (
1173- assert_type (pd .DatetimeIndex (["2020" ], name = "ts" ), pd .DatetimeIndex ),
1174- pd .DatetimeIndex ,
1175- )
1176- check (
1177- assert_type (pd .DatetimeIndex (["2020" ], freq = "D" ), pd .DatetimeIndex ),
1178- pd .DatetimeIndex ,
1179- )
1180- check (
1181- assert_type (pd .DatetimeIndex (["2020" ], tz = "Asia/Kathmandu" ), pd .DatetimeIndex ),
1182- pd .DatetimeIndex ,
1183- )
1184-
1185- # https://github.com/microsoft/python-type-stubs/issues/115
1186- df = pd .DataFrame ({"A" : [1 , 2 , 3 ], "B" : [5 , 6 , 7 ]})
1187-
1188- check (
1189- assert_type (
1190- pd .DatetimeIndex (data = df ["A" ], tz = None , ambiguous = "NaT" , copy = True ),
1191- pd .DatetimeIndex ,
1192- ),
1193- pd .DatetimeIndex ,
1194- )
1195-
1196-
11971139def test_iter () -> None :
11981140 # GH 723
11991141 with pytest_warns_bounded (
@@ -1207,16 +1149,6 @@ def test_iter() -> None:
12071149 check (assert_type (ts , pd .Timestamp ), pd .Timestamp )
12081150
12091151
1210- def test_intersection () -> None :
1211- # GH 744
1212- index = pd .DatetimeIndex (["2022-01-01" ])
1213- check (assert_type (index .intersection (index ), pd .DatetimeIndex ), pd .DatetimeIndex )
1214- check (
1215- assert_type (index .intersection ([pd .Timestamp ("1/1/2023" )]), pd .DatetimeIndex ),
1216- pd .DatetimeIndex ,
1217- )
1218-
1219-
12201152def test_annotate () -> None :
12211153 # GH 502
12221154 df = pd .DataFrame ({"a" : [1 , 2 ]})
@@ -1368,24 +1300,11 @@ def test_disallow_empty_index() -> None:
13681300 _0 = pd .Index () # type: ignore[call-overload] # pyright: ignore[reportCallIssue]
13691301
13701302
1371- def test_datetime_index_max_min_reductions () -> None :
1372- dtidx = pd .DatetimeIndex (["2020-01-01" , "2020-01-02" ])
1373- check (assert_type (dtidx .argmax (), np .int64 ), np .int64 )
1374- check (assert_type (dtidx .argmin (), np .int64 ), np .int64 )
1375- check (assert_type (dtidx .max (), pd .Timestamp ), pd .Timestamp )
1376- check (assert_type (dtidx .min (), pd .Timestamp ), pd .Timestamp )
1377-
1378-
13791303def test_periodindex_shift () -> None :
13801304 ind = pd .period_range (start = "2022-06-01" , periods = 10 )
13811305 check (assert_type (ind .shift (1 ), pd .PeriodIndex ), pd .PeriodIndex )
13821306
13831307
1384- def test_datetimeindex_shift () -> None :
1385- ind = pd .date_range ("2023-01-01" , "2023-02-01" )
1386- check (assert_type (ind .shift (1 ), pd .DatetimeIndex ), pd .DatetimeIndex )
1387-
1388-
13891308def test_timedeltaindex_shift () -> None :
13901309 ind = pd .date_range ("1/1/2021" , "1/5/2021" ) - pd .Timestamp ("1/3/2019" )
13911310 # broken on 3.0.0.dev0 as of 20250813, fix with pandas-dev/pandas/issues/62094
0 commit comments