@@ -29,12 +29,7 @@ def setUp(self):
29
29
def create_index (self ):
30
30
return RangeIndex (5 )
31
31
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 ):
38
33
for op in ops :
39
34
for a , b in combinations (idxs , 2 ):
40
35
result = op (a , b )
@@ -46,6 +41,23 @@ def test_binops(self):
46
41
expected = op (Int64Index (idx ), scalar )
47
42
tm .assert_index_equal (result , expected )
48
43
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
+
49
61
def test_too_many_names (self ):
50
62
def testit ():
51
63
self .index .names = ["roger" , "harold" ]
0 commit comments