#NEWLINE# def test_numeric_compat2( self ) : #NEWLINE# #INDENT# idx = RangeIndex ( 0 , 10 , 2 ) #NEWLINE# result = ( idx * 2 ) #NEWLINE# expected = RangeIndex ( 0 , 20 , 4 ) #NEWLINE# self . assertTrue ( result . equals ( expected ) ) #NEWLINE# result = ( idx + 2 ) #NEWLINE# expected = RangeIndex ( 2 , 12 , 2 ) #NEWLINE# self . assertTrue ( result . equals ( expected ) ) #NEWLINE# result = ( idx - 2 ) #NEWLINE# expected = RangeIndex ( ( - 2 ) , 8 , 2 ) #NEWLINE# self . assertTrue ( result . equals ( expected ) ) #NEWLINE# result = ( idx / 2 ) #NEWLINE# if PY3 : #NEWLINE# #INDENT# expected = RangeIndex ( 0 , 5 , 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# expected = RangeIndex ( 0 , 5 , 1 ) . astype ( 'float64' ) #NEWLINE# #UNINDENT# self . assertTrue ( result . equals ( expected ) ) #NEWLINE# result = ( idx / 4 ) #NEWLINE# expected = ( RangeIndex ( 0 , 10 , 2 ) . values / 4 ) #NEWLINE# self . assertTrue ( result . equals ( expected ) ) #NEWLINE# result = ( idx // 1 ) #NEWLINE# expected = idx #NEWLINE# tm . assert_index_equal ( result , expected , exact = True ) #NEWLINE# result = ( idx * idx ) #NEWLINE# expected = Index ( ( idx . values * idx . values ) ) #NEWLINE# tm . assert_index_equal ( result , expected , exact = True ) #NEWLINE# idx = RangeIndex ( 0 , 1000 , 2 ) #NEWLINE# result = ( idx ** 2 ) #NEWLINE# expected = ( idx . _int64index ** 2 ) #NEWLINE# tm . assert_index_equal ( Index ( result . values ) , expected , exact = True ) #NEWLINE# cases_exact = [ ( RangeIndex ( 0 , 1000 , 2 ) , 2 , RangeIndex ( 0 , 500 , 1 ) ) , ( RangeIndex ( ( - 99 ) , ( - 201 ) , ( - 3 ) ) , ( - 3 ) , RangeIndex ( 33 , 67 , 1 ) ) , ( RangeIndex ( 0 , 1000 , 1 ) , 2 , ( RangeIndex ( 0 , 1000 , 1 ) . _int64index // 2 ) ) , ( RangeIndex ( 0 , 100 , 1 ) , 2.0 , ( RangeIndex ( 0 , 100 , 1 ) . _int64index // 2.0 ) ) , ( RangeIndex ( ) , 50 , RangeIndex ( ) ) , ( RangeIndex ( 2 , 4 , 2 ) , 3 , RangeIndex ( 0 , 1 , 1 ) ) , ( RangeIndex ( ( - 5 ) , ( - 10 ) , ( - 6 ) ) , 4 , RangeIndex ( ( - 2 ) , ( - 1 ) , 1 ) ) , ( RangeIndex ( ( - 100 ) , ( - 200 ) , 3 ) , 2 , RangeIndex ( ) ) ] #NEWLINE# for ( idx , div , expected ) in cases_exact : #NEWLINE# #INDENT# tm . assert_index_equal ( ( idx // div ) , expected , exact = True )