Skip to content

Commit d9c96cd

Browse files
committed
TST: Test inplace operations on indexes that require type promotion.
1 parent a15fee0 commit d9c96cd

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

pandas/tests/test_index.py

+27
Original file line numberDiff line numberDiff line change
@@ -1922,6 +1922,33 @@ def test_promote_type(self):
19221922
self.assertEqual(index_promoted.dtype, np.float64)
19231923
self.assertIsInstance(index_promoted, Float64Index)
19241924

1925+
def test_promote_type_inplace(self):
1926+
# Related to GH-9966
1927+
index = Int64Index(np.arange(5))
1928+
index += np.pi
1929+
self.assertEqual(index.dtype, np.float64)
1930+
self.assertIsInstance(index, Float64Index)
1931+
1932+
index = Int64Index(np.arange(5))
1933+
index -= np.pi
1934+
self.assertEqual(index.dtype, np.float64)
1935+
self.assertIsInstance(index, Float64Index)
1936+
1937+
index = Int64Index(np.arange(5))
1938+
index *= np.pi
1939+
self.assertEqual(index.dtype, np.float64)
1940+
self.assertIsInstance(index, Float64Index)
1941+
1942+
index = Int64Index(np.arange(5))
1943+
index /= np.pi
1944+
self.assertEqual(index.dtype, np.float64)
1945+
self.assertIsInstance(index, Float64Index)
1946+
1947+
index = Int64Index(np.arange(5))
1948+
index //= np.pi
1949+
self.assertEqual(index.dtype, np.float64)
1950+
self.assertIsInstance(index, Float64Index)
1951+
19251952
def test_equals(self):
19261953

19271954
i = Float64Index([1.0,2.0])

0 commit comments

Comments
 (0)