File tree 1 file changed +19
-0
lines changed
1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -1800,6 +1800,25 @@ def test_string_index_repr(self):
1800
1800
1801
1801
assert coerce (idx ) == expected
1802
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
+ delta = dtype (delta )
1808
+ idx = pd .Index ([10 , 11 , 12 ], dtype = dtype )
1809
+ result = idx + delta
1810
+ expected = pd .Index (idx .values + delta , dtype = dtype )
1811
+ tm .assert_index_equal (result , expected )
1812
+
1813
+ # this subtraction used to fail
1814
+ result = idx - delta
1815
+ expected = pd .Index (idx .values - delta , dtype = dtype )
1816
+ tm .assert_index_equal (result , expected )
1817
+
1818
+ tm .assert_index_equal (idx + idx , 2 * idx )
1819
+ tm .assert_index_equal (idx - idx , 0 * idx )
1820
+ assert not (idx - idx ).empty
1821
+
1803
1822
1804
1823
class TestMixedIntIndex (Base ):
1805
1824
# Mostly the tests from common.py for which the results differ
You can’t perform that action at this time.
0 commit comments