|
15 | 15 |
|
16 | 16 | import pytest
|
17 | 17 |
|
| 18 | + |
18 | 19 | class ConcatenateBase(tm.TestCase):
|
19 | 20 |
|
20 | 21 | def setUp(self):
|
@@ -1934,30 +1935,30 @@ def test_concat_no_unnecessary_upcast(self):
|
1934 | 1935 | objs.append(pdt(np.array([1], dtype=np.float16, ndmin=dims)))
|
1935 | 1936 | self.assertTrue(pd.concat(objs).values.dtype == np.float64)
|
1936 | 1937 |
|
1937 |
| - # @pytest.mark.parametrize('dtype', np.sctypes['float']) |
1938 |
| - # def test_concat_no_unnecessary_upcast_pytest(dtype): |
1939 |
| - # klass = [Series, DataFrame, Panel] |
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 |
| - # assert x.values.dtype == dt |
1948 |
| - # |
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 |
| - # assert 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 |
| - # assert pd.concat(objs).values.dtype == np.int64 |
1958 |
| - # |
1959 |
| - # # not sure what is the best answer here |
1960 |
| - # objs = [] |
1961 |
| - # objs.append(pdt(np.array([1], dtype=np.int32, ndmin=dims))) |
1962 |
| - # objs.append(pdt(np.array([1], dtype=np.float16, ndmin=dims))) |
1963 |
| - # assert pd.concat(objs).values.dtype == np.float64 |
| 1938 | + |
| 1939 | +@pytest.mark.parametrize('pdt', [pd.Series, pd.DataFrame, pd.Panel]) |
| 1940 | +@pytest.mark.parametrize('dt', np.sctypes['float']) |
| 1941 | +def test_concat_no_unnecessary_upcast_pytest(dt, pdt): |
| 1942 | + # GH 13247 |
| 1943 | + dims = pdt().ndim |
| 1944 | + dfs = [pdt(np.array([1], dtype=dt, ndmin=dims)), |
| 1945 | + pdt(np.array([np.nan], dtype=dt, ndmin=dims)), |
| 1946 | + pdt(np.array([5], dtype=dt, ndmin=dims))] |
| 1947 | + x = pd.concat(dfs) |
| 1948 | + assert x.values.dtype == dt |
| 1949 | + |
| 1950 | + objs = [] |
| 1951 | + objs.append(pdt(np.array([1], dtype=np.float32, ndmin=dims))) |
| 1952 | + objs.append(pdt(np.array([1], dtype=np.float16, ndmin=dims))) |
| 1953 | + assert pd.concat(objs).values.dtype == np.float32 |
| 1954 | + |
| 1955 | + objs = [] |
| 1956 | + objs.append(pdt(np.array([1], dtype=np.int32, ndmin=dims))) |
| 1957 | + objs.append(pdt(np.array([1], dtype=np.int64, ndmin=dims))) |
| 1958 | + assert pd.concat(objs).values.dtype == np.int64 |
| 1959 | + |
| 1960 | + # not sure what is the best answer here |
| 1961 | + objs = [] |
| 1962 | + objs.append(pdt(np.array([1], dtype=np.int32, ndmin=dims))) |
| 1963 | + objs.append(pdt(np.array([1], dtype=np.float16, ndmin=dims))) |
| 1964 | + assert pd.concat(objs).values.dtype == np.float64 |
0 commit comments