@@ -172,6 +172,10 @@ def test_difference_none() -> None:
172
172
# GH 253
173
173
check (assert_type (ind .difference ([1 ]), "pd.Index[int]" ), pd .Index )
174
174
175
+ # check with sort parameter
176
+ check (assert_type (ind .difference ([1 , None ], sort = False ), "pd.Index[int]" ), pd .Index )
177
+ check (assert_type (ind .difference ([1 ], sort = True ), "pd.Index[int]" ), pd .Index )
178
+
175
179
176
180
def test_str_split () -> None :
177
181
# GH 194
@@ -314,6 +318,18 @@ def test_range_index_union():
314
318
)
315
319
316
320
321
+ def test_index_union_sort () -> None :
322
+ """Test sort argument in pd.Index.union GH1264."""
323
+ check (
324
+ assert_type (pd .Index (["e" , "f" ]).union (["a" , "b" , "c" ], sort = True ), pd .Index ),
325
+ pd .Index ,
326
+ )
327
+ check (
328
+ assert_type (pd .Index (["e" , "f" ]).union (["a" , "b" , "c" ], sort = False ), pd .Index ),
329
+ pd .Index ,
330
+ )
331
+
332
+
317
333
def test_range_index_start_stop_step ():
318
334
idx = pd .RangeIndex (3 )
319
335
check (assert_type (idx .start , int ), int )
@@ -1361,3 +1377,10 @@ def test_index_dict() -> None:
1361
1377
),
1362
1378
pd .TimedeltaIndex ,
1363
1379
)
1380
+
1381
+
1382
+ def test_index_infer_objects () -> None :
1383
+ """Test infer_objects method on Index."""
1384
+ df = pd .DataFrame ({"A" : ["a" , 1 , 2 , 3 ]})
1385
+ idx = df .set_index ("A" ).index [1 :]
1386
+ check (assert_type (idx .infer_objects (), pd .Index ), pd .Index )
0 commit comments