From a06e1a41554fd850caa9d5c8b84b46db1e3c95a6 Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Tue, 28 Apr 2020 14:22:45 +0100 Subject: [PATCH 01/22] BUG: Series construction with EA dtype and index but no data fails --- doc/source/whatsnew/v1.1.0.rst | 2 +- pandas/core/construction.py | 6 +++++- pandas/tests/series/test_constructors.py | 7 +++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/doc/source/whatsnew/v1.1.0.rst b/doc/source/whatsnew/v1.1.0.rst index 949109d9bb75a..cb94fd2258b8b 100644 --- a/doc/source/whatsnew/v1.1.0.rst +++ b/doc/source/whatsnew/v1.1.0.rst @@ -731,7 +731,7 @@ ExtensionArray ^^^^^^^^^^^^^^ - Fixed bug where :meth:`Series.value_counts` would raise on empty input of ``Int64`` dtype (:issue:`33317`) -- +- Fixed bug in :class:`Series` construction with EA dtype and index but no data fails (:issue:`26469`) Other diff --git a/pandas/core/construction.py b/pandas/core/construction.py index 351ef1d0429da..3c5a5faeeb71e 100644 --- a/pandas/core/construction.py +++ b/pandas/core/construction.py @@ -516,7 +516,7 @@ def _try_cast( Parameters ---------- - arr : ndarray, list, tuple, iterator (catchall) + arr : ndarray, scalar, list, tuple, iterator (catchall) Excludes: ExtensionArray, Series, Index. dtype : np.dtype, ExtensionDtype or None copy : bool @@ -533,6 +533,10 @@ def _try_cast( if isinstance(dtype, ExtensionDtype) and dtype.kind != "M": # create an extension array from its dtype # DatetimeTZ case needs to go through maybe_cast_to_datetime + + if lib.is_scalar(arr): + arr = [arr] + array_type = dtype.construct_array_type()._from_sequence subarr = array_type(arr, dtype=dtype, copy=copy) return subarr diff --git a/pandas/tests/series/test_constructors.py b/pandas/tests/series/test_constructors.py index effb324298c95..c68b40acc1be2 100644 --- a/pandas/tests/series/test_constructors.py +++ b/pandas/tests/series/test_constructors.py @@ -1436,3 +1436,10 @@ def test_constructor_datetime64(self): series = Series(dates) assert np.issubdtype(series.dtype, np.dtype("M8[ns]")) + + @pytest.mark.parametrize("data", [None, pd.NA, 42]) + def test_constructor_broadcast_scalar_EA_dtype(self, data): + # https://github.com/pandas-dev/pandas/issues/26469 + result = pd.Series(data=data, index=[1, 2, 3], dtype="Int64") + expected = pd.Series([data] * 3, index=[1, 2, 3], dtype="Int64") + tm.assert_series_equal(result, expected) From 6ae334259f62c7ef84fe5f289be61bd05d43df2b Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Wed, 29 Apr 2020 14:40:49 +0100 Subject: [PATCH 02/22] redo tests --- pandas/tests/extension/arrow/test_bool.py | 10 ++++++++++ pandas/tests/extension/base/constructors.py | 15 +++++++++++++++ pandas/tests/extension/json/test_json.py | 15 +++++++++++++++ pandas/tests/extension/test_datetime.py | 5 ++++- pandas/tests/extension/test_numpy.py | 5 +++++ pandas/tests/extension/test_sparse.py | 10 +++++++++- pandas/tests/series/test_constructors.py | 7 ------- 7 files changed, 58 insertions(+), 9 deletions(-) diff --git a/pandas/tests/extension/arrow/test_bool.py b/pandas/tests/extension/arrow/test_bool.py index 94dd09d3eb053..7e3c9c6522697 100644 --- a/pandas/tests/extension/arrow/test_bool.py +++ b/pandas/tests/extension/arrow/test_bool.py @@ -55,6 +55,16 @@ def test_from_dtype(self, data): def test_from_sequence_from_cls(self, data): super().test_from_sequence_from_cls(data) + @pytest.mark.xfail(reason="GH-26469") + def test_series_constructor_no_data_with_index(self, data, na_value): + # pyarrow.lib.ArrowInvalid: only handle 1-dimensional arrays + super().test_series_constructor_no_data_with_index(data, na_value) + + @pytest.mark.xfail(reason="GH-26469") + def test_series_constructor_scalar_na_with_index(self, data, na_value): + # pyarrow.lib.ArrowInvalid: only handle 1-dimensional arrays + super().test_series_constructor_scalar_na_with_index(data, na_value) + class TestReduce(base.BaseNoReduceTests): def test_reduce_series_boolean(self): diff --git a/pandas/tests/extension/base/constructors.py b/pandas/tests/extension/base/constructors.py index 1ddc7af0f6268..ac46357c25eac 100644 --- a/pandas/tests/extension/base/constructors.py +++ b/pandas/tests/extension/base/constructors.py @@ -33,6 +33,21 @@ def test_series_constructor(self, data): assert result2.dtype == data.dtype assert isinstance(result2._mgr.blocks[0], ExtensionBlock) + def test_series_constructor_no_data_with_index(self, data, na_value): + result = pd.Series(index=[1, 2, 3], dtype=data.dtype) + expected = pd.Series([na_value] * 3, index=[1, 2, 3], dtype=data.dtype) + self.assert_series_equal(result, expected) + + def test_series_constructor_scalar_na_with_index(self, data, na_value): + result = pd.Series(data=na_value, index=[1, 2, 3], dtype=data.dtype) + expected = pd.Series([na_value] * 3, index=[1, 2, 3], dtype=data.dtype) + self.assert_series_equal(result, expected) + + def test_series_constructor_scalar_with_index(self, data): + result = pd.Series(data[0], index=[1, 2, 3], dtype=data.dtype) + expected = pd.Series([data[0]] * 3, index=[1, 2, 3], dtype=data.dtype) + self.assert_series_equal(result, expected) + @pytest.mark.parametrize("from_series", [True, False]) def test_dataframe_constructor_from_dict(self, data, from_series): if from_series: diff --git a/pandas/tests/extension/json/test_json.py b/pandas/tests/extension/json/test_json.py index 06b59aaeff68d..5b21b3d708179 100644 --- a/pandas/tests/extension/json/test_json.py +++ b/pandas/tests/extension/json/test_json.py @@ -150,6 +150,21 @@ def test_from_dtype(self, data): # construct from our dtype & string dtype pass + @pytest.mark.xfail(reason="GH-26469") + def test_series_constructor_no_data_with_index(self, data, na_value): + # RecursionError: maximum recursion depth exceeded in comparison + super().test_series_constructor_no_data_with_index(data, na_value) + + @pytest.mark.xfail(reason="GH-26469") + def test_series_constructor_scalar_na_with_index(self, data, na_value): + # RecursionError: maximum recursion depth exceeded in comparison + super().test_series_constructor_scalar_na_with_index(data, na_value) + + @pytest.mark.xfail(reason="GH-26469") + def test_series_constructor_scalar_with_index(self, data): + # TypeError: All values must be of type + super.test_series_constructor_scalar_with_index(data) + class TestReshaping(BaseJSON, base.BaseReshapingTests): @pytest.mark.skip(reason="Different definitions of NA") diff --git a/pandas/tests/extension/test_datetime.py b/pandas/tests/extension/test_datetime.py index 3aa188098620d..7e666110deeaa 100644 --- a/pandas/tests/extension/test_datetime.py +++ b/pandas/tests/extension/test_datetime.py @@ -82,7 +82,10 @@ class TestDatetimeDtype(BaseDatetimeTests, base.BaseDtypeTests): class TestConstructors(BaseDatetimeTests, base.BaseConstructorsTests): - pass + @pytest.mark.xfail(reason="GH-26469") + def test_series_constructor_scalar_with_index(self, data): + # TypeError: data type not understood + super().test_series_constructor_scalar_with_index(data) class TestGetitem(BaseDatetimeTests, base.BaseGetitemTests): diff --git a/pandas/tests/extension/test_numpy.py b/pandas/tests/extension/test_numpy.py index aa5a99282131a..0885972dfc6b4 100644 --- a/pandas/tests/extension/test_numpy.py +++ b/pandas/tests/extension/test_numpy.py @@ -151,6 +151,11 @@ def test_array_from_scalars(self, data): # ValueError: PandasArray must be 1-dimensional. super().test_array_from_scalars(data) + @skip_nested + def test_series_constructor_scalar_with_index(self, data): + # ValueError: Length of passed values is 1, index implies 3. + super().test_series_constructor_scalar_with_index(data) + class TestDtype(BaseNumPyTests, base.BaseDtypeTests): @pytest.mark.skip(reason="Incorrect expected.") diff --git a/pandas/tests/extension/test_sparse.py b/pandas/tests/extension/test_sparse.py index 694bbee59606f..8466d3485f64c 100644 --- a/pandas/tests/extension/test_sparse.py +++ b/pandas/tests/extension/test_sparse.py @@ -112,7 +112,15 @@ def test_view(self, data): class TestConstructors(BaseSparseTests, base.BaseConstructorsTests): - pass + @pytest.mark.xfail(reason="GH-26469", strict=False) + def test_series_constructor_no_data_with_index(self, data, na_value): + # ValueError: Cannot convert non-finite values (NA or inf) to integer + super().test_series_constructor_no_data_with_index(data, na_value) + + @pytest.mark.xfail(reason="GH-26469", strict=False) + def test_series_constructor_scalar_na_with_index(self, data, na_value): + # ValueError: Cannot convert non-finite values (NA or inf) to integer + super().test_series_constructor_scalar_na_with_index(data, na_value) class TestReshaping(BaseSparseTests, base.BaseReshapingTests): diff --git a/pandas/tests/series/test_constructors.py b/pandas/tests/series/test_constructors.py index c68b40acc1be2..effb324298c95 100644 --- a/pandas/tests/series/test_constructors.py +++ b/pandas/tests/series/test_constructors.py @@ -1436,10 +1436,3 @@ def test_constructor_datetime64(self): series = Series(dates) assert np.issubdtype(series.dtype, np.dtype("M8[ns]")) - - @pytest.mark.parametrize("data", [None, pd.NA, 42]) - def test_constructor_broadcast_scalar_EA_dtype(self, data): - # https://github.com/pandas-dev/pandas/issues/26469 - result = pd.Series(data=data, index=[1, 2, 3], dtype="Int64") - expected = pd.Series([data] * 3, index=[1, 2, 3], dtype="Int64") - tm.assert_series_equal(result, expected) From 1881a03a3383ef7e32f181a7e55085f88b89a1ce Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Thu, 30 Apr 2020 12:10:08 +0100 Subject: [PATCH 03/22] add test_series_constructor_scalar_with_one_element_index --- pandas/tests/extension/base/constructors.py | 23 +++++++++++++++------ pandas/tests/extension/json/test_json.py | 7 ++++++- pandas/tests/extension/test_datetime.py | 5 +++++ pandas/tests/extension/test_numpy.py | 5 +++++ 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/pandas/tests/extension/base/constructors.py b/pandas/tests/extension/base/constructors.py index ac46357c25eac..a55379b96a198 100644 --- a/pandas/tests/extension/base/constructors.py +++ b/pandas/tests/extension/base/constructors.py @@ -34,18 +34,29 @@ def test_series_constructor(self, data): assert isinstance(result2._mgr.blocks[0], ExtensionBlock) def test_series_constructor_no_data_with_index(self, data, na_value): - result = pd.Series(index=[1, 2, 3], dtype=data.dtype) - expected = pd.Series([na_value] * 3, index=[1, 2, 3], dtype=data.dtype) + dtype = data.dtype + result = pd.Series(index=[1, 2, 3], dtype=dtype) + expected = pd.Series([na_value] * 3, index=[1, 2, 3], dtype=dtype) self.assert_series_equal(result, expected) def test_series_constructor_scalar_na_with_index(self, data, na_value): - result = pd.Series(data=na_value, index=[1, 2, 3], dtype=data.dtype) - expected = pd.Series([na_value] * 3, index=[1, 2, 3], dtype=data.dtype) + dtype = data.dtype + result = pd.Series(na_value, index=[1, 2, 3], dtype=dtype) + expected = pd.Series([na_value] * 3, index=[1, 2, 3], dtype=dtype) self.assert_series_equal(result, expected) def test_series_constructor_scalar_with_index(self, data): - result = pd.Series(data[0], index=[1, 2, 3], dtype=data.dtype) - expected = pd.Series([data[0]] * 3, index=[1, 2, 3], dtype=data.dtype) + scalar = data[0] + dtype = data.dtype + result = pd.Series(scalar, index=[1, 2, 3], dtype=dtype) + expected = pd.Series([scalar] * 3, index=[1, 2, 3], dtype=dtype) + self.assert_series_equal(result, expected) + + def test_series_constructor_scalar_with_one_element_index(self, data): + scalar = data[0] + dtype = data.dtype + result = pd.Series(scalar, index=["foo"], dtype=dtype) + expected = pd.Series([scalar], index=["foo"], dtype=dtype) self.assert_series_equal(result, expected) @pytest.mark.parametrize("from_series", [True, False]) diff --git a/pandas/tests/extension/json/test_json.py b/pandas/tests/extension/json/test_json.py index 5b21b3d708179..dd117e61cc5d9 100644 --- a/pandas/tests/extension/json/test_json.py +++ b/pandas/tests/extension/json/test_json.py @@ -163,7 +163,12 @@ def test_series_constructor_scalar_na_with_index(self, data, na_value): @pytest.mark.xfail(reason="GH-26469") def test_series_constructor_scalar_with_index(self, data): # TypeError: All values must be of type - super.test_series_constructor_scalar_with_index(data) + super().test_series_constructor_scalar_with_index(data) + + @pytest.mark.xfail(reason="GH-26469") + def test_series_constructor_scalar_with_one_element_index(self, data): + # TypeError: All values must be of type + super().test_series_constructor_scalar_with_one_element_index(data) class TestReshaping(BaseJSON, base.BaseReshapingTests): diff --git a/pandas/tests/extension/test_datetime.py b/pandas/tests/extension/test_datetime.py index 1b1378d20aab1..45364bbe43b53 100644 --- a/pandas/tests/extension/test_datetime.py +++ b/pandas/tests/extension/test_datetime.py @@ -87,6 +87,11 @@ def test_series_constructor_scalar_with_index(self, data): # TypeError: data type not understood super().test_series_constructor_scalar_with_index(data) + @pytest.mark.xfail(reason="GH-26469") + def test_series_constructor_scalar_with_one_element_index(self, data): + # TypeError: data type not understood + super().test_series_constructor_scalar_with_one_element_index(data) + class TestGetitem(BaseDatetimeTests, base.BaseGetitemTests): pass diff --git a/pandas/tests/extension/test_numpy.py b/pandas/tests/extension/test_numpy.py index 0885972dfc6b4..89dcf752a3a5f 100644 --- a/pandas/tests/extension/test_numpy.py +++ b/pandas/tests/extension/test_numpy.py @@ -156,6 +156,11 @@ def test_series_constructor_scalar_with_index(self, data): # ValueError: Length of passed values is 1, index implies 3. super().test_series_constructor_scalar_with_index(data) + @skip_nested + def test_series_constructor_scalar_with_one_element_index(self, data): + # ValueError: PandasArray must be 1-dimensional. + super().test_series_constructor_scalar_with_one_element_index(data) + class TestDtype(BaseNumPyTests, base.BaseDtypeTests): @pytest.mark.skip(reason="Incorrect expected.") From 45ef9a5fff5067eed94be8f2999928f94ecf113d Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Thu, 30 Apr 2020 14:09:52 +0100 Subject: [PATCH 04/22] move dtype to test function parameters --- pandas/tests/extension/arrow/test_bool.py | 8 ++++---- pandas/tests/extension/base/constructors.py | 12 ++++-------- pandas/tests/extension/json/test_json.py | 16 ++++++++-------- pandas/tests/extension/test_datetime.py | 8 ++++---- pandas/tests/extension/test_numpy.py | 8 ++++---- pandas/tests/extension/test_sparse.py | 8 ++++---- 6 files changed, 28 insertions(+), 32 deletions(-) diff --git a/pandas/tests/extension/arrow/test_bool.py b/pandas/tests/extension/arrow/test_bool.py index 7e3c9c6522697..ba5b7c2e5a3ab 100644 --- a/pandas/tests/extension/arrow/test_bool.py +++ b/pandas/tests/extension/arrow/test_bool.py @@ -56,14 +56,14 @@ def test_from_sequence_from_cls(self, data): super().test_from_sequence_from_cls(data) @pytest.mark.xfail(reason="GH-26469") - def test_series_constructor_no_data_with_index(self, data, na_value): + def test_series_constructor_no_data_with_index(self, dtype, na_value): # pyarrow.lib.ArrowInvalid: only handle 1-dimensional arrays - super().test_series_constructor_no_data_with_index(data, na_value) + super().test_series_constructor_no_data_with_index(dtype, na_value) @pytest.mark.xfail(reason="GH-26469") - def test_series_constructor_scalar_na_with_index(self, data, na_value): + def test_series_constructor_scalar_na_with_index(self, dtype, na_value): # pyarrow.lib.ArrowInvalid: only handle 1-dimensional arrays - super().test_series_constructor_scalar_na_with_index(data, na_value) + super().test_series_constructor_scalar_na_with_index(dtype, na_value) class TestReduce(base.BaseNoReduceTests): diff --git a/pandas/tests/extension/base/constructors.py b/pandas/tests/extension/base/constructors.py index a55379b96a198..de719fc8eda14 100644 --- a/pandas/tests/extension/base/constructors.py +++ b/pandas/tests/extension/base/constructors.py @@ -33,28 +33,24 @@ def test_series_constructor(self, data): assert result2.dtype == data.dtype assert isinstance(result2._mgr.blocks[0], ExtensionBlock) - def test_series_constructor_no_data_with_index(self, data, na_value): - dtype = data.dtype + def test_series_constructor_no_data_with_index(self, dtype, na_value): result = pd.Series(index=[1, 2, 3], dtype=dtype) expected = pd.Series([na_value] * 3, index=[1, 2, 3], dtype=dtype) self.assert_series_equal(result, expected) - def test_series_constructor_scalar_na_with_index(self, data, na_value): - dtype = data.dtype + def test_series_constructor_scalar_na_with_index(self, dtype, na_value): result = pd.Series(na_value, index=[1, 2, 3], dtype=dtype) expected = pd.Series([na_value] * 3, index=[1, 2, 3], dtype=dtype) self.assert_series_equal(result, expected) - def test_series_constructor_scalar_with_index(self, data): + def test_series_constructor_scalar_with_index(self, data, dtype): scalar = data[0] - dtype = data.dtype result = pd.Series(scalar, index=[1, 2, 3], dtype=dtype) expected = pd.Series([scalar] * 3, index=[1, 2, 3], dtype=dtype) self.assert_series_equal(result, expected) - def test_series_constructor_scalar_with_one_element_index(self, data): + def test_series_constructor_scalar_with_one_element_index(self, data, dtype): scalar = data[0] - dtype = data.dtype result = pd.Series(scalar, index=["foo"], dtype=dtype) expected = pd.Series([scalar], index=["foo"], dtype=dtype) self.assert_series_equal(result, expected) diff --git a/pandas/tests/extension/json/test_json.py b/pandas/tests/extension/json/test_json.py index dd117e61cc5d9..287da11add841 100644 --- a/pandas/tests/extension/json/test_json.py +++ b/pandas/tests/extension/json/test_json.py @@ -151,24 +151,24 @@ def test_from_dtype(self, data): pass @pytest.mark.xfail(reason="GH-26469") - def test_series_constructor_no_data_with_index(self, data, na_value): + def test_series_constructor_no_data_with_index(self, dtype, na_value): # RecursionError: maximum recursion depth exceeded in comparison - super().test_series_constructor_no_data_with_index(data, na_value) + super().test_series_constructor_no_data_with_index(dtype, na_value) @pytest.mark.xfail(reason="GH-26469") - def test_series_constructor_scalar_na_with_index(self, data, na_value): + def test_series_constructor_scalar_na_with_index(self, dtype, na_value): # RecursionError: maximum recursion depth exceeded in comparison - super().test_series_constructor_scalar_na_with_index(data, na_value) + super().test_series_constructor_scalar_na_with_index(dtype, na_value) @pytest.mark.xfail(reason="GH-26469") - def test_series_constructor_scalar_with_index(self, data): + def test_series_constructor_scalar_with_index(self, data, dtype): # TypeError: All values must be of type - super().test_series_constructor_scalar_with_index(data) + super().test_series_constructor_scalar_with_index(data, dtype) @pytest.mark.xfail(reason="GH-26469") - def test_series_constructor_scalar_with_one_element_index(self, data): + def test_series_constructor_scalar_with_one_element_index(self, data, dtype): # TypeError: All values must be of type - super().test_series_constructor_scalar_with_one_element_index(data) + super().test_series_constructor_scalar_with_one_element_index(data, dtype) class TestReshaping(BaseJSON, base.BaseReshapingTests): diff --git a/pandas/tests/extension/test_datetime.py b/pandas/tests/extension/test_datetime.py index 45364bbe43b53..293ab928f807b 100644 --- a/pandas/tests/extension/test_datetime.py +++ b/pandas/tests/extension/test_datetime.py @@ -83,14 +83,14 @@ class TestDatetimeDtype(BaseDatetimeTests, base.BaseDtypeTests): class TestConstructors(BaseDatetimeTests, base.BaseConstructorsTests): @pytest.mark.xfail(reason="GH-26469") - def test_series_constructor_scalar_with_index(self, data): + def test_series_constructor_scalar_with_index(self, data, dtype): # TypeError: data type not understood - super().test_series_constructor_scalar_with_index(data) + super().test_series_constructor_scalar_with_index(data, dtype) @pytest.mark.xfail(reason="GH-26469") - def test_series_constructor_scalar_with_one_element_index(self, data): + def test_series_constructor_scalar_with_one_element_index(self, data, dtype): # TypeError: data type not understood - super().test_series_constructor_scalar_with_one_element_index(data) + super().test_series_constructor_scalar_with_one_element_index(data, dtype) class TestGetitem(BaseDatetimeTests, base.BaseGetitemTests): diff --git a/pandas/tests/extension/test_numpy.py b/pandas/tests/extension/test_numpy.py index 89dcf752a3a5f..f4c5f5a48beb9 100644 --- a/pandas/tests/extension/test_numpy.py +++ b/pandas/tests/extension/test_numpy.py @@ -152,14 +152,14 @@ def test_array_from_scalars(self, data): super().test_array_from_scalars(data) @skip_nested - def test_series_constructor_scalar_with_index(self, data): + def test_series_constructor_scalar_with_index(self, data, dtype): # ValueError: Length of passed values is 1, index implies 3. - super().test_series_constructor_scalar_with_index(data) + super().test_series_constructor_scalar_with_index(data, dtype) @skip_nested - def test_series_constructor_scalar_with_one_element_index(self, data): + def test_series_constructor_scalar_with_one_element_index(self, data, dtype): # ValueError: PandasArray must be 1-dimensional. - super().test_series_constructor_scalar_with_one_element_index(data) + super().test_series_constructor_scalar_with_one_element_index(data, dtype) class TestDtype(BaseNumPyTests, base.BaseDtypeTests): diff --git a/pandas/tests/extension/test_sparse.py b/pandas/tests/extension/test_sparse.py index 8466d3485f64c..990f133800f47 100644 --- a/pandas/tests/extension/test_sparse.py +++ b/pandas/tests/extension/test_sparse.py @@ -113,14 +113,14 @@ def test_view(self, data): class TestConstructors(BaseSparseTests, base.BaseConstructorsTests): @pytest.mark.xfail(reason="GH-26469", strict=False) - def test_series_constructor_no_data_with_index(self, data, na_value): + def test_series_constructor_no_data_with_index(self, dtype, na_value): # ValueError: Cannot convert non-finite values (NA or inf) to integer - super().test_series_constructor_no_data_with_index(data, na_value) + super().test_series_constructor_no_data_with_index(dtype, na_value) @pytest.mark.xfail(reason="GH-26469", strict=False) - def test_series_constructor_scalar_na_with_index(self, data, na_value): + def test_series_constructor_scalar_na_with_index(self, dtype, na_value): # ValueError: Cannot convert non-finite values (NA or inf) to integer - super().test_series_constructor_scalar_na_with_index(data, na_value) + super().test_series_constructor_scalar_na_with_index(dtype, na_value) class TestReshaping(BaseSparseTests, base.BaseReshapingTests): From a339f05c89d88ab29964dc313f0035bf3bcf71a6 Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Thu, 30 Apr 2020 14:15:09 +0100 Subject: [PATCH 05/22] comment - whatsnew --- doc/source/whatsnew/v1.1.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.1.0.rst b/doc/source/whatsnew/v1.1.0.rst index 08b6abb39660e..6b272d8465be9 100644 --- a/doc/source/whatsnew/v1.1.0.rst +++ b/doc/source/whatsnew/v1.1.0.rst @@ -732,7 +732,7 @@ ExtensionArray ^^^^^^^^^^^^^^ - Fixed bug where :meth:`Series.value_counts` would raise on empty input of ``Int64`` dtype (:issue:`33317`) -- Fixed bug in :class:`Series` construction with EA dtype and index but no data fails (:issue:`26469`) +- Fixed bug in :class:`Series` construction with EA dtype and index but no data or scalar data fails (:issue:`26469`) Other From 6bfbd1ad542c60d52c52bf2aa2b376daf5dbb629 Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Thu, 30 Apr 2020 14:20:22 +0100 Subject: [PATCH 06/22] comment - merge tests --- pandas/tests/extension/base/constructors.py | 2 -- pandas/tests/extension/json/test_json.py | 5 ----- pandas/tests/extension/test_datetime.py | 5 ----- pandas/tests/extension/test_numpy.py | 5 ----- 4 files changed, 17 deletions(-) diff --git a/pandas/tests/extension/base/constructors.py b/pandas/tests/extension/base/constructors.py index de719fc8eda14..0695797497854 100644 --- a/pandas/tests/extension/base/constructors.py +++ b/pandas/tests/extension/base/constructors.py @@ -49,8 +49,6 @@ def test_series_constructor_scalar_with_index(self, data, dtype): expected = pd.Series([scalar] * 3, index=[1, 2, 3], dtype=dtype) self.assert_series_equal(result, expected) - def test_series_constructor_scalar_with_one_element_index(self, data, dtype): - scalar = data[0] result = pd.Series(scalar, index=["foo"], dtype=dtype) expected = pd.Series([scalar], index=["foo"], dtype=dtype) self.assert_series_equal(result, expected) diff --git a/pandas/tests/extension/json/test_json.py b/pandas/tests/extension/json/test_json.py index 287da11add841..23da017e10408 100644 --- a/pandas/tests/extension/json/test_json.py +++ b/pandas/tests/extension/json/test_json.py @@ -165,11 +165,6 @@ def test_series_constructor_scalar_with_index(self, data, dtype): # TypeError: All values must be of type super().test_series_constructor_scalar_with_index(data, dtype) - @pytest.mark.xfail(reason="GH-26469") - def test_series_constructor_scalar_with_one_element_index(self, data, dtype): - # TypeError: All values must be of type - super().test_series_constructor_scalar_with_one_element_index(data, dtype) - class TestReshaping(BaseJSON, base.BaseReshapingTests): @pytest.mark.skip(reason="Different definitions of NA") diff --git a/pandas/tests/extension/test_datetime.py b/pandas/tests/extension/test_datetime.py index 293ab928f807b..332b39df8bc91 100644 --- a/pandas/tests/extension/test_datetime.py +++ b/pandas/tests/extension/test_datetime.py @@ -87,11 +87,6 @@ def test_series_constructor_scalar_with_index(self, data, dtype): # TypeError: data type not understood super().test_series_constructor_scalar_with_index(data, dtype) - @pytest.mark.xfail(reason="GH-26469") - def test_series_constructor_scalar_with_one_element_index(self, data, dtype): - # TypeError: data type not understood - super().test_series_constructor_scalar_with_one_element_index(data, dtype) - class TestGetitem(BaseDatetimeTests, base.BaseGetitemTests): pass diff --git a/pandas/tests/extension/test_numpy.py b/pandas/tests/extension/test_numpy.py index f4c5f5a48beb9..f6fcd4a7c7439 100644 --- a/pandas/tests/extension/test_numpy.py +++ b/pandas/tests/extension/test_numpy.py @@ -156,11 +156,6 @@ def test_series_constructor_scalar_with_index(self, data, dtype): # ValueError: Length of passed values is 1, index implies 3. super().test_series_constructor_scalar_with_index(data, dtype) - @skip_nested - def test_series_constructor_scalar_with_one_element_index(self, data, dtype): - # ValueError: PandasArray must be 1-dimensional. - super().test_series_constructor_scalar_with_one_element_index(data, dtype) - class TestDtype(BaseNumPyTests, base.BaseDtypeTests): @pytest.mark.skip(reason="Incorrect expected.") From 1c8bd8c58fb8dd822e9a1b9f6c8c527757ff8572 Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Thu, 30 Apr 2020 15:17:31 +0100 Subject: [PATCH 07/22] special case to avoid _try_cast call --- pandas/core/construction.py | 6 ++---- pandas/tests/extension/test_datetime.py | 5 +---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/pandas/core/construction.py b/pandas/core/construction.py index 3c5a5faeeb71e..ea245afa26783 100644 --- a/pandas/core/construction.py +++ b/pandas/core/construction.py @@ -450,6 +450,8 @@ def sanitize_array( subarr = _try_cast(arr, dtype, copy, raise_cast_failure) elif isinstance(data, abc.Set): raise TypeError("Set type is unordered") + elif is_extension_array_dtype(dtype) and lib.is_scalar(data) and index is not None: + subarr = construct_1d_arraylike_from_scalar(data, len(index), dtype) else: subarr = _try_cast(data, dtype, copy, raise_cast_failure) @@ -533,10 +535,6 @@ def _try_cast( if isinstance(dtype, ExtensionDtype) and dtype.kind != "M": # create an extension array from its dtype # DatetimeTZ case needs to go through maybe_cast_to_datetime - - if lib.is_scalar(arr): - arr = [arr] - array_type = dtype.construct_array_type()._from_sequence subarr = array_type(arr, dtype=dtype, copy=copy) return subarr diff --git a/pandas/tests/extension/test_datetime.py b/pandas/tests/extension/test_datetime.py index 332b39df8bc91..e026809f7e611 100644 --- a/pandas/tests/extension/test_datetime.py +++ b/pandas/tests/extension/test_datetime.py @@ -82,10 +82,7 @@ class TestDatetimeDtype(BaseDatetimeTests, base.BaseDtypeTests): class TestConstructors(BaseDatetimeTests, base.BaseConstructorsTests): - @pytest.mark.xfail(reason="GH-26469") - def test_series_constructor_scalar_with_index(self, data, dtype): - # TypeError: data type not understood - super().test_series_constructor_scalar_with_index(data, dtype) + pass class TestGetitem(BaseDatetimeTests, base.BaseGetitemTests): From 840df492aed6580e12f4f15da7c529c256e2c259 Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Thu, 30 Apr 2020 15:40:21 +0100 Subject: [PATCH 08/22] troubleshoot --- pandas/core/construction.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/construction.py b/pandas/core/construction.py index ea245afa26783..23f76aba7c106 100644 --- a/pandas/core/construction.py +++ b/pandas/core/construction.py @@ -450,7 +450,7 @@ def sanitize_array( subarr = _try_cast(arr, dtype, copy, raise_cast_failure) elif isinstance(data, abc.Set): raise TypeError("Set type is unordered") - elif is_extension_array_dtype(dtype) and lib.is_scalar(data) and index is not None: + elif lib.is_scalar(data) and index is not None: subarr = construct_1d_arraylike_from_scalar(data, len(index), dtype) else: subarr = _try_cast(data, dtype, copy, raise_cast_failure) From 9cf81ee9b7896ac293368a6e79568e19ca2dd808 Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Thu, 30 Apr 2020 15:45:10 +0100 Subject: [PATCH 09/22] less failures --- pandas/core/construction.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/construction.py b/pandas/core/construction.py index 23f76aba7c106..e517d50777631 100644 --- a/pandas/core/construction.py +++ b/pandas/core/construction.py @@ -450,7 +450,7 @@ def sanitize_array( subarr = _try_cast(arr, dtype, copy, raise_cast_failure) elif isinstance(data, abc.Set): raise TypeError("Set type is unordered") - elif lib.is_scalar(data) and index is not None: + elif lib.is_scalar(data) and index is not None and dtype is not None: subarr = construct_1d_arraylike_from_scalar(data, len(index), dtype) else: subarr = _try_cast(data, dtype, copy, raise_cast_failure) From d42771445e473645b24fdb5d142d4c4013deaf9d Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Thu, 30 Apr 2020 16:37:15 +0100 Subject: [PATCH 10/22] maybe_cast_to_datetime --- pandas/core/construction.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pandas/core/construction.py b/pandas/core/construction.py index e517d50777631..e6e26f0eec597 100644 --- a/pandas/core/construction.py +++ b/pandas/core/construction.py @@ -451,6 +451,9 @@ def sanitize_array( elif isinstance(data, abc.Set): raise TypeError("Set type is unordered") elif lib.is_scalar(data) and index is not None and dtype is not None: + data = maybe_cast_to_datetime(data, dtype) + if not lib.is_scalar(data): + data = data[0] subarr = construct_1d_arraylike_from_scalar(data, len(index), dtype) else: subarr = _try_cast(data, dtype, copy, raise_cast_failure) From d47cba43f4a6c78d0ca00b11d4f2747ef8bc9f66 Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Thu, 30 Apr 2020 18:27:35 +0100 Subject: [PATCH 11/22] add failure reason for pyarrow --- pandas/tests/extension/arrow/test_bool.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/tests/extension/arrow/test_bool.py b/pandas/tests/extension/arrow/test_bool.py index ba5b7c2e5a3ab..2442c537a09f7 100644 --- a/pandas/tests/extension/arrow/test_bool.py +++ b/pandas/tests/extension/arrow/test_bool.py @@ -55,12 +55,12 @@ def test_from_dtype(self, data): def test_from_sequence_from_cls(self, data): super().test_from_sequence_from_cls(data) - @pytest.mark.xfail(reason="GH-26469") + @pytest.mark.xfail(reason="pa.NULL is not recognised as scalar, GH-26469") def test_series_constructor_no_data_with_index(self, dtype, na_value): # pyarrow.lib.ArrowInvalid: only handle 1-dimensional arrays super().test_series_constructor_no_data_with_index(dtype, na_value) - @pytest.mark.xfail(reason="GH-26469") + @pytest.mark.xfail(reason="pa.NULL is not recognised as scalar, GH-26469") def test_series_constructor_scalar_na_with_index(self, dtype, na_value): # pyarrow.lib.ArrowInvalid: only handle 1-dimensional arrays super().test_series_constructor_scalar_na_with_index(dtype, na_value) From c5cc30db2abdac48950ee57d22d97b0dbdafcbb5 Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Thu, 30 Apr 2020 18:59:43 +0100 Subject: [PATCH 12/22] update issue ref for ArrowBoolDtype --- pandas/tests/extension/arrow/test_bool.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/tests/extension/arrow/test_bool.py b/pandas/tests/extension/arrow/test_bool.py index 2442c537a09f7..dec3b316e00b8 100644 --- a/pandas/tests/extension/arrow/test_bool.py +++ b/pandas/tests/extension/arrow/test_bool.py @@ -55,12 +55,12 @@ def test_from_dtype(self, data): def test_from_sequence_from_cls(self, data): super().test_from_sequence_from_cls(data) - @pytest.mark.xfail(reason="pa.NULL is not recognised as scalar, GH-26469") + @pytest.mark.xfail(reason="pa.NULL is not recognised as scalar, GH-33899") def test_series_constructor_no_data_with_index(self, dtype, na_value): # pyarrow.lib.ArrowInvalid: only handle 1-dimensional arrays super().test_series_constructor_no_data_with_index(dtype, na_value) - @pytest.mark.xfail(reason="pa.NULL is not recognised as scalar, GH-26469") + @pytest.mark.xfail(reason="pa.NULL is not recognised as scalar, GH-33899") def test_series_constructor_scalar_na_with_index(self, dtype, na_value): # pyarrow.lib.ArrowInvalid: only handle 1-dimensional arrays super().test_series_constructor_scalar_na_with_index(dtype, na_value) From 421aa7cc9b4c1be117bffe1bdddfcb023c0f1ed4 Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Thu, 30 Apr 2020 19:36:33 +0100 Subject: [PATCH 13/22] remove sparse test overrides --- pandas/tests/extension/test_sparse.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/pandas/tests/extension/test_sparse.py b/pandas/tests/extension/test_sparse.py index 990f133800f47..694bbee59606f 100644 --- a/pandas/tests/extension/test_sparse.py +++ b/pandas/tests/extension/test_sparse.py @@ -112,15 +112,7 @@ def test_view(self, data): class TestConstructors(BaseSparseTests, base.BaseConstructorsTests): - @pytest.mark.xfail(reason="GH-26469", strict=False) - def test_series_constructor_no_data_with_index(self, dtype, na_value): - # ValueError: Cannot convert non-finite values (NA or inf) to integer - super().test_series_constructor_no_data_with_index(dtype, na_value) - - @pytest.mark.xfail(reason="GH-26469", strict=False) - def test_series_constructor_scalar_na_with_index(self, dtype, na_value): - # ValueError: Cannot convert non-finite values (NA or inf) to integer - super().test_series_constructor_scalar_na_with_index(dtype, na_value) + pass class TestReshaping(BaseSparseTests, base.BaseReshapingTests): From 4c5135699eef442888269cb5334c6200aa1265a5 Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Thu, 30 Apr 2020 20:06:36 +0100 Subject: [PATCH 14/22] ref to new issue for JSONDtype RecursionError --- pandas/tests/extension/json/test_json.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/tests/extension/json/test_json.py b/pandas/tests/extension/json/test_json.py index 23da017e10408..15108732124b5 100644 --- a/pandas/tests/extension/json/test_json.py +++ b/pandas/tests/extension/json/test_json.py @@ -150,12 +150,12 @@ def test_from_dtype(self, data): # construct from our dtype & string dtype pass - @pytest.mark.xfail(reason="GH-26469") + @pytest.mark.xfail(reason="RecursionError, GH-33900") def test_series_constructor_no_data_with_index(self, dtype, na_value): # RecursionError: maximum recursion depth exceeded in comparison super().test_series_constructor_no_data_with_index(dtype, na_value) - @pytest.mark.xfail(reason="GH-26469") + @pytest.mark.xfail(reason="RecursionError, GH-33900") def test_series_constructor_scalar_na_with_index(self, dtype, na_value): # RecursionError: maximum recursion depth exceeded in comparison super().test_series_constructor_scalar_na_with_index(dtype, na_value) From ff4ff639322be6cbc1593c0ca61558d973839051 Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Thu, 30 Apr 2020 20:21:27 +0100 Subject: [PATCH 15/22] collection as scalar msg and gh ref --- pandas/tests/extension/json/test_json.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/extension/json/test_json.py b/pandas/tests/extension/json/test_json.py index 15108732124b5..c505435078f9f 100644 --- a/pandas/tests/extension/json/test_json.py +++ b/pandas/tests/extension/json/test_json.py @@ -160,7 +160,7 @@ def test_series_constructor_scalar_na_with_index(self, dtype, na_value): # RecursionError: maximum recursion depth exceeded in comparison super().test_series_constructor_scalar_na_with_index(dtype, na_value) - @pytest.mark.xfail(reason="GH-26469") + @pytest.mark.xfail(reason="collection as scalar, GH-33901") def test_series_constructor_scalar_with_index(self, data, dtype): # TypeError: All values must be of type super().test_series_constructor_scalar_with_index(data, dtype) From 268f3a52d958207e605b6383cb3a77613dfcdee7 Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Fri, 1 May 2020 10:49:13 +0100 Subject: [PATCH 16/22] fix corner case --- pandas/core/construction.py | 10 +++++++--- pandas/tests/series/test_constructors.py | 6 ++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/pandas/core/construction.py b/pandas/core/construction.py index e6e26f0eec597..1130dc617141e 100644 --- a/pandas/core/construction.py +++ b/pandas/core/construction.py @@ -451,9 +451,13 @@ def sanitize_array( elif isinstance(data, abc.Set): raise TypeError("Set type is unordered") elif lib.is_scalar(data) and index is not None and dtype is not None: - data = maybe_cast_to_datetime(data, dtype) - if not lib.is_scalar(data): - data = data[0] + try: + data = maybe_cast_to_datetime(data, dtype) + except TypeError: + pass + else: + if not lib.is_scalar(data): + data = data[0] subarr = construct_1d_arraylike_from_scalar(data, len(index), dtype) else: subarr = _try_cast(data, dtype, copy, raise_cast_failure) diff --git a/pandas/tests/series/test_constructors.py b/pandas/tests/series/test_constructors.py index 22076eb05db88..85f47d0f6f5a4 100644 --- a/pandas/tests/series/test_constructors.py +++ b/pandas/tests/series/test_constructors.py @@ -1444,3 +1444,9 @@ def test_constructor_datetime64(self): series = Series(dates) assert np.issubdtype(series.dtype, np.dtype("M8[ns]")) + + def test_constructor_datetimelike_scalar_to_string_dtype(self): + # https://github.com/pandas-dev/pandas/pull/33846 + result = Series("M", index=[1, 2, 3], dtype="string") + expected = pd.Series(["M", "M", "M"], index=[1, 2, 3], dtype="string") + tm.assert_series_equal(result, expected) From 2df2bf1f4bf05ead3c77558c4b5d801d6519bc18 Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Fri, 1 May 2020 15:31:26 +0100 Subject: [PATCH 17/22] comment - maybe_cast_to_datetime --- pandas/core/construction.py | 10 +++------- pandas/core/dtypes/cast.py | 4 +++- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/pandas/core/construction.py b/pandas/core/construction.py index 1130dc617141e..e6e26f0eec597 100644 --- a/pandas/core/construction.py +++ b/pandas/core/construction.py @@ -451,13 +451,9 @@ def sanitize_array( elif isinstance(data, abc.Set): raise TypeError("Set type is unordered") elif lib.is_scalar(data) and index is not None and dtype is not None: - try: - data = maybe_cast_to_datetime(data, dtype) - except TypeError: - pass - else: - if not lib.is_scalar(data): - data = data[0] + data = maybe_cast_to_datetime(data, dtype) + if not lib.is_scalar(data): + data = data[0] subarr = construct_1d_arraylike_from_scalar(data, len(index), dtype) else: subarr = _try_cast(data, dtype, copy, raise_cast_failure) diff --git a/pandas/core/dtypes/cast.py b/pandas/core/dtypes/cast.py index e50d635a1ba6c..19d5c86b6a1be 100644 --- a/pandas/core/dtypes/cast.py +++ b/pandas/core/dtypes/cast.py @@ -1384,7 +1384,9 @@ def maybe_cast_to_datetime(value, dtype, errors: str = "raise"): pass # coerce datetimelike to object - elif is_datetime64_dtype(value) and not is_datetime64_dtype(dtype): + elif is_datetime64_dtype( + getattr(value, "dtype", None) + ) and not is_datetime64_dtype(dtype): if is_object_dtype(dtype): if value.dtype != DT64NS_DTYPE: value = value.astype(DT64NS_DTYPE) From e598f4c466bbe4d7b5fb9d65e007040bb2a8da1d Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Fri, 1 May 2020 16:40:30 +0100 Subject: [PATCH 18/22] add test for gh-33559 --- pandas/tests/extension/base/constructors.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pandas/tests/extension/base/constructors.py b/pandas/tests/extension/base/constructors.py index 0695797497854..52e29cffc79c4 100644 --- a/pandas/tests/extension/base/constructors.py +++ b/pandas/tests/extension/base/constructors.py @@ -38,6 +38,11 @@ def test_series_constructor_no_data_with_index(self, dtype, na_value): expected = pd.Series([na_value] * 3, index=[1, 2, 3], dtype=dtype) self.assert_series_equal(result, expected) + # GH 33559 - empty index + result = pd.Series(index=[], dtype=dtype) + expected = pd.Series([], index=pd.Index([], dtype="object"), dtype=dtype) + self.assert_series_equal(result, expected) + def test_series_constructor_scalar_na_with_index(self, dtype, na_value): result = pd.Series(na_value, index=[1, 2, 3], dtype=dtype) expected = pd.Series([na_value] * 3, index=[1, 2, 3], dtype=dtype) From 8c44e23b444ac544d09190b022864a717c3e4e93 Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Fri, 1 May 2020 18:03:25 +0100 Subject: [PATCH 19/22] troubleshoot timeout --- pandas/tests/extension/arrow/test_bool.py | 4 ++-- pandas/tests/extension/json/test_json.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pandas/tests/extension/arrow/test_bool.py b/pandas/tests/extension/arrow/test_bool.py index dec3b316e00b8..cd7b718e4b536 100644 --- a/pandas/tests/extension/arrow/test_bool.py +++ b/pandas/tests/extension/arrow/test_bool.py @@ -55,12 +55,12 @@ def test_from_dtype(self, data): def test_from_sequence_from_cls(self, data): super().test_from_sequence_from_cls(data) - @pytest.mark.xfail(reason="pa.NULL is not recognised as scalar, GH-33899") + @pytest.mark.skip(reason="pa.NULL is not recognised as scalar, GH-33899") def test_series_constructor_no_data_with_index(self, dtype, na_value): # pyarrow.lib.ArrowInvalid: only handle 1-dimensional arrays super().test_series_constructor_no_data_with_index(dtype, na_value) - @pytest.mark.xfail(reason="pa.NULL is not recognised as scalar, GH-33899") + @pytest.mark.skip(reason="pa.NULL is not recognised as scalar, GH-33899") def test_series_constructor_scalar_na_with_index(self, dtype, na_value): # pyarrow.lib.ArrowInvalid: only handle 1-dimensional arrays super().test_series_constructor_scalar_na_with_index(dtype, na_value) diff --git a/pandas/tests/extension/json/test_json.py b/pandas/tests/extension/json/test_json.py index d79769208ab56..fb62ab04134ba 100644 --- a/pandas/tests/extension/json/test_json.py +++ b/pandas/tests/extension/json/test_json.py @@ -150,17 +150,17 @@ def test_from_dtype(self, data): # construct from our dtype & string dtype pass - @pytest.mark.xfail(reason="RecursionError, GH-33900") + @pytest.mark.skip(reason="RecursionError, GH-33900") def test_series_constructor_no_data_with_index(self, dtype, na_value): # RecursionError: maximum recursion depth exceeded in comparison super().test_series_constructor_no_data_with_index(dtype, na_value) - @pytest.mark.xfail(reason="RecursionError, GH-33900") + @pytest.mark.skip(reason="RecursionError, GH-33900") def test_series_constructor_scalar_na_with_index(self, dtype, na_value): # RecursionError: maximum recursion depth exceeded in comparison super().test_series_constructor_scalar_na_with_index(dtype, na_value) - @pytest.mark.xfail(reason="collection as scalar, GH-33901") + @pytest.mark.skip(reason="collection as scalar, GH-33901") def test_series_constructor_scalar_with_index(self, data, dtype): # TypeError: All values must be of type super().test_series_constructor_scalar_with_index(data, dtype) From dac66d0e8dbbd3bc686318a513aa2f3bf22db4cf Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Fri, 1 May 2020 18:47:03 +0100 Subject: [PATCH 20/22] troubleshoot timeout --- pandas/tests/extension/arrow/test_bool.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/tests/extension/arrow/test_bool.py b/pandas/tests/extension/arrow/test_bool.py index cd7b718e4b536..dec3b316e00b8 100644 --- a/pandas/tests/extension/arrow/test_bool.py +++ b/pandas/tests/extension/arrow/test_bool.py @@ -55,12 +55,12 @@ def test_from_dtype(self, data): def test_from_sequence_from_cls(self, data): super().test_from_sequence_from_cls(data) - @pytest.mark.skip(reason="pa.NULL is not recognised as scalar, GH-33899") + @pytest.mark.xfail(reason="pa.NULL is not recognised as scalar, GH-33899") def test_series_constructor_no_data_with_index(self, dtype, na_value): # pyarrow.lib.ArrowInvalid: only handle 1-dimensional arrays super().test_series_constructor_no_data_with_index(dtype, na_value) - @pytest.mark.skip(reason="pa.NULL is not recognised as scalar, GH-33899") + @pytest.mark.xfail(reason="pa.NULL is not recognised as scalar, GH-33899") def test_series_constructor_scalar_na_with_index(self, dtype, na_value): # pyarrow.lib.ArrowInvalid: only handle 1-dimensional arrays super().test_series_constructor_scalar_na_with_index(dtype, na_value) From f2026d3959720364caef1b9f1c22d6fad50dfe65 Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Fri, 1 May 2020 19:49:22 +0100 Subject: [PATCH 21/22] troubleshoot timeout --- pandas/tests/extension/arrow/test_bool.py | 4 ++-- pandas/tests/extension/json/test_json.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pandas/tests/extension/arrow/test_bool.py b/pandas/tests/extension/arrow/test_bool.py index dec3b316e00b8..cd7b718e4b536 100644 --- a/pandas/tests/extension/arrow/test_bool.py +++ b/pandas/tests/extension/arrow/test_bool.py @@ -55,12 +55,12 @@ def test_from_dtype(self, data): def test_from_sequence_from_cls(self, data): super().test_from_sequence_from_cls(data) - @pytest.mark.xfail(reason="pa.NULL is not recognised as scalar, GH-33899") + @pytest.mark.skip(reason="pa.NULL is not recognised as scalar, GH-33899") def test_series_constructor_no_data_with_index(self, dtype, na_value): # pyarrow.lib.ArrowInvalid: only handle 1-dimensional arrays super().test_series_constructor_no_data_with_index(dtype, na_value) - @pytest.mark.xfail(reason="pa.NULL is not recognised as scalar, GH-33899") + @pytest.mark.skip(reason="pa.NULL is not recognised as scalar, GH-33899") def test_series_constructor_scalar_na_with_index(self, dtype, na_value): # pyarrow.lib.ArrowInvalid: only handle 1-dimensional arrays super().test_series_constructor_scalar_na_with_index(dtype, na_value) diff --git a/pandas/tests/extension/json/test_json.py b/pandas/tests/extension/json/test_json.py index fb62ab04134ba..d79769208ab56 100644 --- a/pandas/tests/extension/json/test_json.py +++ b/pandas/tests/extension/json/test_json.py @@ -150,17 +150,17 @@ def test_from_dtype(self, data): # construct from our dtype & string dtype pass - @pytest.mark.skip(reason="RecursionError, GH-33900") + @pytest.mark.xfail(reason="RecursionError, GH-33900") def test_series_constructor_no_data_with_index(self, dtype, na_value): # RecursionError: maximum recursion depth exceeded in comparison super().test_series_constructor_no_data_with_index(dtype, na_value) - @pytest.mark.skip(reason="RecursionError, GH-33900") + @pytest.mark.xfail(reason="RecursionError, GH-33900") def test_series_constructor_scalar_na_with_index(self, dtype, na_value): # RecursionError: maximum recursion depth exceeded in comparison super().test_series_constructor_scalar_na_with_index(dtype, na_value) - @pytest.mark.skip(reason="collection as scalar, GH-33901") + @pytest.mark.xfail(reason="collection as scalar, GH-33901") def test_series_constructor_scalar_with_index(self, data, dtype): # TypeError: All values must be of type super().test_series_constructor_scalar_with_index(data, dtype) From 52fcd7f62074817c92d1d5874c19bf51dbb75738 Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Fri, 1 May 2020 21:02:43 +0100 Subject: [PATCH 22/22] skip on py3.6 --- pandas/tests/extension/arrow/test_bool.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pandas/tests/extension/arrow/test_bool.py b/pandas/tests/extension/arrow/test_bool.py index cd7b718e4b536..681c6f9a19dc5 100644 --- a/pandas/tests/extension/arrow/test_bool.py +++ b/pandas/tests/extension/arrow/test_bool.py @@ -1,6 +1,8 @@ import numpy as np import pytest +from pandas.compat import PY37 + import pandas as pd import pandas._testing as tm from pandas.tests.extension import base @@ -55,12 +57,14 @@ def test_from_dtype(self, data): def test_from_sequence_from_cls(self, data): super().test_from_sequence_from_cls(data) - @pytest.mark.skip(reason="pa.NULL is not recognised as scalar, GH-33899") + @pytest.mark.skipif(not PY37, reason="timeout on Linux py36_locale") + @pytest.mark.xfail(reason="pa.NULL is not recognised as scalar, GH-33899") def test_series_constructor_no_data_with_index(self, dtype, na_value): # pyarrow.lib.ArrowInvalid: only handle 1-dimensional arrays super().test_series_constructor_no_data_with_index(dtype, na_value) - @pytest.mark.skip(reason="pa.NULL is not recognised as scalar, GH-33899") + @pytest.mark.skipif(not PY37, reason="timeout on Linux py36_locale") + @pytest.mark.xfail(reason="pa.NULL is not recognised as scalar, GH-33899") def test_series_constructor_scalar_na_with_index(self, dtype, na_value): # pyarrow.lib.ArrowInvalid: only handle 1-dimensional arrays super().test_series_constructor_scalar_na_with_index(dtype, na_value)