1010)
1111import pandas ._testing as tm
1212
13- # aliases to make some tests easier to read
14- RI = RangeIndex
15-
1613
1714class TestRangeIndex :
1815 @pytest .fixture
@@ -507,25 +504,31 @@ def test_len_specialised(self, step):
507504 @pytest .mark .parametrize (
508505 "indices, expected" ,
509506 [
510- ([RI (1 , 12 , 5 )], RI (1 , 12 , 5 )),
511- ([RI (0 , 6 , 4 )], RI (0 , 6 , 4 )),
512- ([RI (1 , 3 ), RI (3 , 7 )], RI (1 , 7 )),
513- ([RI (1 , 5 , 2 ), RI (5 , 6 )], RI (1 , 6 , 2 )),
514- ([RI (1 , 3 , 2 ), RI (4 , 7 , 3 )], RI (1 , 7 , 3 )),
515- ([RI (- 4 , 3 , 2 ), RI (4 , 7 , 2 )], RI (- 4 , 7 , 2 )),
516- ([RI (- 4 , - 8 ), RI (- 8 , - 12 )], RI (0 , 0 )),
517- ([RI (- 4 , - 8 ), RI (3 , - 4 )], RI (0 , 0 )),
518- ([RI (- 4 , - 8 ), RI (3 , 5 )], RI (3 , 5 )),
519- ([RI (- 4 , - 2 ), RI (3 , 5 )], Index ([- 4 , - 3 , 3 , 4 ])),
520- ([RI (- 2 ), RI (3 , 5 )], RI (3 , 5 )),
521- ([RI (2 ), RI (2 )], Index ([0 , 1 , 0 , 1 ])),
522- ([RI (2 ), RI (2 , 5 ), RI (5 , 8 , 4 )], RI (0 , 6 )),
523- ([RI (2 ), RI (3 , 5 ), RI (5 , 8 , 4 )], Index ([0 , 1 , 3 , 4 , 5 ])),
524- ([RI (- 2 , 2 ), RI (2 , 5 ), RI (5 , 8 , 4 )], RI (- 2 , 6 )),
525- ([RI (3 ), Index ([- 1 , 3 , 15 ])], Index ([0 , 1 , 2 , - 1 , 3 , 15 ])),
526- ([RI (3 ), Index ([- 1 , 3.1 , 15.0 ])], Index ([0 , 1 , 2 , - 1 , 3.1 , 15.0 ])),
527- ([RI (3 ), Index (["a" , None , 14 ])], Index ([0 , 1 , 2 , "a" , None , 14 ])),
528- ([RI (3 , 1 ), Index (["a" , None , 14 ])], Index (["a" , None , 14 ])),
507+ ([RangeIndex (1 , 12 , 5 )], RangeIndex (1 , 12 , 5 )),
508+ ([RangeIndex (0 , 6 , 4 )], RangeIndex (0 , 6 , 4 )),
509+ ([RangeIndex (1 , 3 ), RangeIndex (3 , 7 )], RangeIndex (1 , 7 )),
510+ ([RangeIndex (1 , 5 , 2 ), RangeIndex (5 , 6 )], RangeIndex (1 , 6 , 2 )),
511+ ([RangeIndex (1 , 3 , 2 ), RangeIndex (4 , 7 , 3 )], RangeIndex (1 , 7 , 3 )),
512+ ([RangeIndex (- 4 , 3 , 2 ), RangeIndex (4 , 7 , 2 )], RangeIndex (- 4 , 7 , 2 )),
513+ ([RangeIndex (- 4 , - 8 ), RangeIndex (- 8 , - 12 )], RangeIndex (0 , 0 )),
514+ ([RangeIndex (- 4 , - 8 ), RangeIndex (3 , - 4 )], RangeIndex (0 , 0 )),
515+ ([RangeIndex (- 4 , - 8 ), RangeIndex (3 , 5 )], RangeIndex (3 , 5 )),
516+ ([RangeIndex (- 4 , - 2 ), RangeIndex (3 , 5 )], Index ([- 4 , - 3 , 3 , 4 ])),
517+ ([RangeIndex (- 2 ), RangeIndex (3 , 5 )], RangeIndex (3 , 5 )),
518+ ([RangeIndex (2 ), RangeIndex (2 )], Index ([0 , 1 , 0 , 1 ])),
519+ ([RangeIndex (2 ), RangeIndex (2 , 5 ), RangeIndex (5 , 8 , 4 )], RangeIndex (0 , 6 )),
520+ (
521+ [RangeIndex (2 ), RangeIndex (3 , 5 ), RangeIndex (5 , 8 , 4 )],
522+ Index ([0 , 1 , 3 , 4 , 5 ]),
523+ ),
524+ (
525+ [RangeIndex (- 2 , 2 ), RangeIndex (2 , 5 ), RangeIndex (5 , 8 , 4 )],
526+ RangeIndex (- 2 , 6 ),
527+ ),
528+ ([RangeIndex (3 ), Index ([- 1 , 3 , 15 ])], Index ([0 , 1 , 2 , - 1 , 3 , 15 ])),
529+ ([RangeIndex (3 ), Index ([- 1 , 3.1 , 15.0 ])], Index ([0 , 1 , 2 , - 1 , 3.1 , 15.0 ])),
530+ ([RangeIndex (3 ), Index (["a" , None , 14 ])], Index ([0 , 1 , 2 , "a" , None , 14 ])),
531+ ([RangeIndex (3 , 1 ), Index (["a" , None , 14 ])], Index (["a" , None , 14 ])),
529532 ],
530533 )
531534 def test_append (self , indices , expected ):
@@ -567,7 +570,7 @@ def test_format_empty(self):
567570 assert empty_idx .format (name = True ) == ["" ]
568571
569572 @pytest .mark .parametrize (
570- "RI " ,
573+ "ri " ,
571574 [
572575 RangeIndex (0 , - 1 , - 1 ),
573576 RangeIndex (0 , 1 , 1 ),
@@ -576,10 +579,10 @@ def test_format_empty(self):
576579 RangeIndex (- 3 , - 5 , - 2 ),
577580 ],
578581 )
579- def test_append_len_one (self , RI ):
582+ def test_append_len_one (self , ri ):
580583 # GH39401
581- result = RI .append ([])
582- tm .assert_index_equal (result , RI , exact = True )
584+ result = ri .append ([])
585+ tm .assert_index_equal (result , ri , exact = True )
583586
584587 @pytest .mark .parametrize ("base" , [RangeIndex (0 , 2 ), Index ([0 , 1 ])])
585588 def test_isin_range (self , base ):
0 commit comments