Skip to content

Commit 0407502

Browse files
TomAugspurgerjreback
authored andcommitted
floordiv addtl tests
1 parent c5255da commit 0407502

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

pandas/tests/test_index.py

+20
Original file line numberDiff line numberDiff line change
@@ -3464,6 +3464,26 @@ def setUp(self):
34643464
def create_index(self):
34653465
return RangeIndex(5)
34663466

3467+
def test_binops(self):
3468+
import operator as op
3469+
from itertools import combinations
3470+
ops = [op.add, op.sub, op.mul, op.floordiv, op.truediv, pow]
3471+
scalars = [-1, 1, 2]
3472+
idxs = [RangeIndex(0, 10, 1),
3473+
RangeIndex(0, 20, 2),
3474+
RangeIndex(-10, 10, 2),
3475+
RangeIndex(5, -5, -1)]
3476+
for op in ops:
3477+
for a, b in combinations(idxs, 2):
3478+
result = op(a, b)
3479+
expected = op(Int64Index(a), Int64Index(b))
3480+
tm.assert_index_equal(result, expected)
3481+
for idx in idxs:
3482+
for scalar in scalars:
3483+
result = op(idx, scalar)
3484+
expected = op(Int64Index(idx), scalar)
3485+
tm.assert_index_equal(result, expected)
3486+
34673487
def test_too_many_names(self):
34683488
def testit():
34693489
self.index.names = ["roger", "harold"]

0 commit comments

Comments
 (0)