|
13 | 13 | iNaT,
|
14 | 14 | lib,
|
15 | 15 | )
|
| 16 | +from pandas.compat.numpy import np_version_under1p19 |
16 | 17 | import pandas.util._test_decorators as td
|
17 | 18 |
|
18 | 19 | from pandas.core.dtypes.common import (
|
@@ -1840,3 +1841,25 @@ def test_constructor(rand_series_with_duplicate_datetimeindex):
|
1840 | 1841 | dups = rand_series_with_duplicate_datetimeindex
|
1841 | 1842 | assert isinstance(dups, Series)
|
1842 | 1843 | assert isinstance(dups.index, DatetimeIndex)
|
| 1844 | + |
| 1845 | + |
| 1846 | +@pytest.mark.parametrize( |
| 1847 | + "input_dict,expected", |
| 1848 | + [ |
| 1849 | + ({0: 0}, np.array([[0]], dtype=np.int64)), |
| 1850 | + ({"a": "a"}, np.array([["a"]], dtype=object)), |
| 1851 | + ({1: 1}, np.array([[1]], dtype=np.int64)), |
| 1852 | + ], |
| 1853 | +) |
| 1854 | +@pytest.mark.skipif(np_version_under1p19, reason="fails on numpy below 1.19") |
| 1855 | +def test_numpy_array(input_dict, expected): |
| 1856 | + result = np.array([Series(input_dict)]) |
| 1857 | + tm.assert_numpy_array_equal(result, expected) |
| 1858 | + |
| 1859 | + |
| 1860 | +@pytest.mark.skipif( |
| 1861 | + not np_version_under1p19, reason="check failure on numpy below 1.19" |
| 1862 | +) |
| 1863 | +def test_numpy_array_np_v1p19(): |
| 1864 | + with pytest.raises(KeyError, match="0"): |
| 1865 | + np.array([Series({1: 1})]) |
0 commit comments