Skip to content

COMPAT/TST: fix test for range testing of negative integers to neg powers #14498

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions pandas/tests/indexes/test_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@ def setUp(self):
def create_index(self):
return RangeIndex(5)

def test_binops(self):
ops = [operator.add, operator.sub, operator.mul, operator.floordiv,
operator.truediv, pow]
scalars = [-1, 1, 2]
idxs = [RangeIndex(0, 10, 1), RangeIndex(0, 20, 2),
RangeIndex(-10, 10, 2), RangeIndex(5, -5, -1)]
def check_binop(self, ops, scalars, idxs):
for op in ops:
for a, b in combinations(idxs, 2):
result = op(a, b)
Expand All @@ -46,6 +41,23 @@ def test_binops(self):
expected = op(Int64Index(idx), scalar)
tm.assert_index_equal(result, expected)

def test_binops(self):
ops = [operator.add, operator.sub, operator.mul, operator.floordiv,
operator.truediv]
scalars = [-1, 1, 2]
idxs = [RangeIndex(0, 10, 1), RangeIndex(0, 20, 2),
RangeIndex(-10, 10, 2), RangeIndex(5, -5, -1)]
self.check_binop(ops, scalars, idxs)

def test_binops_pow(self):
# later versions of numpy don't allow powers of negative integers
# so test separately
# https://github.com/numpy/numpy/pull/8127
ops = [pow]
scalars = [1, 2]
idxs = [RangeIndex(0, 10, 1), RangeIndex(0, 20, 2)]
self.check_binop(ops, scalars, idxs)

def test_too_many_names(self):
def testit():
self.index.names = ["roger", "harold"]
Expand Down