File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 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):
18001800
18011801 assert coerce (idx ) == expected
18021802
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+
18031822
18041823class TestMixedIntIndex (Base ):
18051824 # Mostly the tests from common.py for which the results differ
You can’t perform that action at this time.
0 commit comments