|
13 | 13 | makeCustomDataframe as mkdf,
|
14 | 14 | assert_almost_equal)
|
15 | 15 |
|
| 16 | +import pytest |
16 | 17 |
|
17 | 18 | class ConcatenateBase(tm.TestCase):
|
18 | 19 |
|
@@ -1900,7 +1901,7 @@ def test_concat_multiindex_dfs_with_deepcopy(self):
|
1900 | 1901 | result_no_copy = pd.concat(example_dict, names=['testname'])
|
1901 | 1902 | tm.assert_frame_equal(result_no_copy, expected)
|
1902 | 1903 |
|
1903 |
| - def test_concat_no_unnecessary_upcats(self): |
| 1904 | + def test_concat_no_unnecessary_upcast(self): |
1904 | 1905 | # GH 13247
|
1905 | 1906 | for pdt in [pd.Series, pd.DataFrame, pd.Panel, pd.Panel4D]:
|
1906 | 1907 | dims = pdt().ndim
|
@@ -1933,30 +1934,28 @@ def test_concat_no_unnecessary_upcats(self):
|
1933 | 1934 | objs.append(pdt(np.array([1], dtype=np.float16, ndmin=dims)))
|
1934 | 1935 | self.assertTrue(pd.concat(objs).values.dtype == np.float64)
|
1935 | 1936 |
|
1936 |
| - @pytest.mark.parametrize('dtype', np.sctypes('float')) |
1937 |
| - @pytest.mark.parametrize('klass', [Series, DataFrame, Panel]) |
1938 |
| - def test_concat_no_unnecessary_upcats_pytest(self, dtype, klass): |
1939 |
| - # GH 13247 |
1940 |
| - for pdt in klass: |
1941 |
| - dims = pdt().ndim |
1942 |
| - for dt in dtype: |
1943 |
| - dfs = [pdt(np.array([1], dtype=dt, ndmin=dims)), |
1944 |
| - pdt(np.array([np.nan], dtype=dt, ndmin=dims)), |
1945 |
| - pdt(np.array([5], dtype=dt, ndmin=dims))] |
1946 |
| - x = pd.concat(dfs) |
1947 |
| - self.assertTrue(x.values.dtype == dt) |
1948 | 1937 |
|
1949 |
| - objs = [] |
1950 |
| - objs.append(pdt(np.array([1], dtype=np.float32, ndmin=dims))) |
1951 |
| - objs.append(pdt(np.array([1], dtype=np.float16, ndmin=dims))) |
1952 |
| - self.assertTrue(pd.concat(objs).values.dtype == np.float32) |
1953 |
| - |
1954 |
| - objs = [] |
1955 |
| - objs.append(pdt(np.array([1], dtype=np.int32, ndmin=dims))) |
1956 |
| - objs.append(pdt(np.array([1], dtype=np.int64, ndmin=dims))) |
1957 |
| - self.assertTrue(pd.concat(objs).values.dtype == np.int64) |
1958 |
| - |
1959 |
| - objs = [] |
1960 |
| - objs.append(pdt(np.array([1], dtype=np.int32, ndmin=dims))) |
1961 |
| - objs.append(pdt(np.array([1], dtype=np.float16, ndmin=dims))) |
1962 |
| - self.assertTrue(pd.concat(objs).values.dtype == np.float64) |
| 1938 | +@pytest.mark.parametrize('pdt', [Series, DataFrame, Panel]) |
| 1939 | +def test_concat_no_unnecessary_upcast_pytest(pdt): |
| 1940 | + dims = pdt().ndim |
| 1941 | + for dt in np.sctypes['float']: |
| 1942 | + dfs = [pdt(np.array([1], dtype=dt, ndmin=dims)), |
| 1943 | + pdt(np.array([np.nan], dtype=dt, ndmin=dims)), |
| 1944 | + pdt(np.array([5], dtype=dt, ndmin=dims))] |
| 1945 | + x = pd.concat(dfs) |
| 1946 | + assert x.values.dtype == dt |
| 1947 | + |
| 1948 | + objs = [] |
| 1949 | + objs.append(pdt(np.array([1], dtype=np.float32, ndmin=dims))) |
| 1950 | + objs.append(pdt(np.array([1], dtype=np.float16, ndmin=dims))) |
| 1951 | + assert pd.concat(objs).values.dtype == np.float32 |
| 1952 | + |
| 1953 | + objs = [] |
| 1954 | + objs.append(pdt(np.array([1], dtype=np.int32, ndmin=dims))) |
| 1955 | + objs.append(pdt(np.array([1], dtype=np.int64, ndmin=dims))) |
| 1956 | + assert pd.concat(objs).values.dtype == np.int64 |
| 1957 | + |
| 1958 | + objs = [] |
| 1959 | + objs.append(pdt(np.array([1], dtype=np.int32, ndmin=dims))) |
| 1960 | + objs.append(pdt(np.array([1], dtype=np.float16, ndmin=dims))) |
| 1961 | + assert pd.concat(objs).values.dtype == np.float64 |
0 commit comments