@@ -868,34 +868,41 @@ def test_len_specialised(self):
868868 i = RangeIndex (0 , 5 , step )
869869 assert len (i ) == 0
870870
871- def test_append (self ):
871+ @pytest .fixture (params = [
872+ ([RI (1 , 12 , 5 )], RI (1 , 12 , 5 )),
873+ ([RI (0 , 6 , 4 )], RI (0 , 6 , 4 )),
874+ ([RI (1 , 3 ), RI (3 , 7 )], RI (1 , 7 )),
875+ ([RI (1 , 5 , 2 ), RI (5 , 6 )], RI (1 , 6 , 2 )),
876+ ([RI (1 , 3 , 2 ), RI (4 , 7 , 3 )], RI (1 , 7 , 3 )),
877+ ([RI (- 4 , 3 , 2 ), RI (4 , 7 , 2 )], RI (- 4 , 7 , 2 )),
878+ ([RI (- 4 , - 8 ), RI (- 8 , - 12 )], RI (0 , 0 )),
879+ ([RI (- 4 , - 8 ), RI (3 , - 4 )], RI (0 , 0 )),
880+ ([RI (- 4 , - 8 ), RI (3 , 5 )], RI (3 , 5 )),
881+ ([RI (- 4 , - 2 ), RI (3 , 5 )], I64 ([- 4 , - 3 , 3 , 4 ])),
882+ ([RI (- 2 ,), RI (3 , 5 )], RI (3 , 5 )),
883+ ([RI (2 ,), RI (2 )], I64 ([0 , 1 , 0 , 1 ])),
884+ ([RI (2 ,), RI (2 , 5 ), RI (5 , 8 , 4 )], RI (0 , 6 )),
885+ ([RI (2 ,), RI (3 , 5 ), RI (5 , 8 , 4 )], I64 ([0 , 1 , 3 , 4 , 5 ])),
886+ ([RI (- 2 , 2 ), RI (2 , 5 ), RI (5 , 8 , 4 )], RI (- 2 , 6 )),
887+ ([RI (3 ,), I64 ([- 1 , 3 , 15 ])], I64 ([0 , 1 , 2 , - 1 , 3 , 15 ])),
888+ ([RI (3 ,), F64 ([- 1 , 3.1 , 15. ])], F64 ([0 , 1 , 2 , - 1 , 3.1 , 15. ])),
889+ ([RI (3 ,), OI (['a' , None , 14 ])], OI ([0 , 1 , 2 , 'a' , None , 14 ])),
890+ ([RI (3 , 1 ), OI (['a' , None , 14 ])], OI (['a' , None , 14 ]))
891+ ])
892+ def appends (self , request ):
893+ """Inputs and expected outputs for RangeIndex.append test"""
894+
895+ return request .param
896+
897+ def test_append (self , appends ):
872898 # GH16212
873- cases = [([RI (1 , 12 , 5 )], RI (1 , 12 , 5 )),
874- ([RI (0 , 6 , 4 )], RI (0 , 6 , 4 )),
875- ([RI (1 , 3 ), RI (3 , 7 )], RI (1 , 7 )),
876- ([RI (1 , 5 , 2 ), RI (5 , 6 )], RI (1 , 6 , 2 )),
877- ([RI (1 , 3 , 2 ), RI (4 , 7 , 3 )], RI (1 , 7 , 3 )),
878- ([RI (- 4 , 3 , 2 ), RI (4 , 7 , 2 )], RI (- 4 , 7 , 2 )),
879- ([RI (- 4 , - 8 ), RI (- 8 , - 12 )], RI (0 , 0 )),
880- ([RI (- 4 , - 8 ), RI (3 , - 4 )], RI (0 , 0 )),
881- ([RI (- 4 , - 8 ), RI (3 , 5 )], RI (3 , 5 )),
882- ([RI (- 4 , - 2 ), RI (3 , 5 )], I64 ([- 4 , - 3 , 3 , 4 ])),
883- ([RI (- 2 ,), RI (3 , 5 )], RI (3 , 5 )),
884- ([RI (2 ,), RI (2 )], I64 ([0 , 1 , 0 , 1 ])),
885- ([RI (2 ,), RI (2 , 5 ), RI (5 , 8 , 4 )], RI (0 , 6 )),
886- ([RI (2 ,), RI (3 , 5 ), RI (5 , 8 , 4 )], I64 ([0 , 1 , 3 , 4 , 5 ])),
887- ([RI (- 2 , 2 ), RI (2 , 5 ), RI (5 , 8 , 4 )], RI (- 2 , 6 )),
888- ([RI (3 ,), I64 ([- 1 , 3 , 15 ])], I64 ([0 , 1 , 2 , - 1 , 3 , 15 ])),
889- ([RI (3 ,), F64 ([- 1 , 3.1 , 15. ])], F64 ([0 , 1 , 2 , - 1 , 3.1 , 15. ])),
890- ([RI (3 ,), OI (['a' , None , 14 ])], OI ([0 , 1 , 2 , 'a' , None , 14 ])),
891- ([RI (3 , 1 ), OI (['a' , None , 14 ])], OI (['a' , None , 14 ]))
892- ]
893-
894- for indices , expected in cases :
895- result = indices [0 ].append (indices [1 :])
896- tm .assert_index_equal (result , expected , exact = True )
897-
898- if len (indices ) == 2 :
899- # Append single item rather than list
900- result2 = indices [0 ].append (indices [1 ])
901- tm .assert_index_equal (result2 , expected , exact = True )
899+
900+ indices , expected = appends
901+
902+ result = indices [0 ].append (indices [1 :])
903+ tm .assert_index_equal (result , expected , exact = True )
904+
905+ if len (indices ) == 2 :
906+ # Append single item rather than list
907+ result2 = indices [0 ].append (indices [1 ])
908+ tm .assert_index_equal (result2 , expected , exact = True )
0 commit comments