We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 10c17d4 commit da22c0aCopy full SHA for da22c0a
pandas/tests/indexes/test_base.py
@@ -1800,6 +1800,24 @@ def test_string_index_repr(self):
1800
1801
assert coerce(idx) == expected
1802
1803
+ @pytest.mark.parametrize('dtype', [np.int64, np.float64])
1804
+ @pytest.mark.parametrize('delta', [1, 0, -1])
1805
+ def test_addsub_arithmetic(self, dtype, delta):
1806
+ # GH 8142
1807
+ idx = pd.Index([10, 11, 12], dtype=dtype)
1808
+ result = idx + dtype(delta)
1809
+ expected = pd.Index(idx.values + dtype(delta), dtype=dtype)
1810
+ tm.assert_index_equal(result, expected)
1811
+
1812
+ # this subtraction used to fail
1813
+ result = idx - dtype(delta)
1814
+ expected = pd.Index(idx.values - dtype(delta), dtype=dtype)
1815
1816
1817
+ tm.assert_index_equal(idx + idx, 2 * idx)
1818
+ tm.assert_index_equal(idx - idx, 0 * idx)
1819
+ assert not (idx - idx).empty
1820
1821
1822
class TestMixedIntIndex(Base):
1823
# Mostly the tests from common.py for which the results differ
0 commit comments