@@ -29,12 +29,7 @@ def setUp(self):
2929 def create_index (self ):
3030 return RangeIndex (5 )
3131
32- def test_binops (self ):
33- ops = [operator .add , operator .sub , operator .mul , operator .floordiv ,
34- operator .truediv , pow ]
35- scalars = [- 1 , 1 , 2 ]
36- idxs = [RangeIndex (0 , 10 , 1 ), RangeIndex (0 , 20 , 2 ),
37- RangeIndex (- 10 , 10 , 2 ), RangeIndex (5 , - 5 , - 1 )]
32+ def check_binop (self , ops , scalars , idxs ):
3833 for op in ops :
3934 for a , b in combinations (idxs , 2 ):
4035 result = op (a , b )
@@ -46,6 +41,23 @@ def test_binops(self):
4641 expected = op (Int64Index (idx ), scalar )
4742 tm .assert_index_equal (result , expected )
4843
44+ def test_binops (self ):
45+ ops = [operator .add , operator .sub , operator .mul , operator .floordiv ,
46+ operator .truediv ]
47+ scalars = [- 1 , 1 , 2 ]
48+ idxs = [RangeIndex (0 , 10 , 1 ), RangeIndex (0 , 20 , 2 ),
49+ RangeIndex (- 10 , 10 , 2 ), RangeIndex (5 , - 5 , - 1 )]
50+ self .check_binop (ops , scalars , idxs )
51+
52+ def test_binops_pow (self ):
53+ # later versions of numpy don't allow powers of negative integers
54+ # so test separately
55+ # https://github.com/numpy/numpy/pull/8127
56+ ops = [pow ]
57+ scalars = [1 , 2 ]
58+ idxs = [RangeIndex (0 , 10 , 1 ), RangeIndex (0 , 20 , 2 )]
59+ self .check_binop (ops , scalars , idxs )
60+
4961 def test_too_many_names (self ):
5062 def testit ():
5163 self .index .names = ["roger" , "harold" ]
0 commit comments