From 755b2f854fd7a2e0c1796d7129bd6c376101208b Mon Sep 17 00:00:00 2001 From: Brock Date: Tue, 3 Sep 2024 15:06:34 -0700 Subject: [PATCH 1/4] TST (string): more targeted xfails in test_string.py --- pandas/tests/extension/test_string.py | 36 +++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/pandas/tests/extension/test_string.py b/pandas/tests/extension/test_string.py index e1f2db149edf9..bc090081ee53c 100644 --- a/pandas/tests/extension/test_string.py +++ b/pandas/tests/extension/test_string.py @@ -22,7 +22,7 @@ import numpy as np import pytest -from pandas._config import using_string_dtype +from pandas.compat import HAS_PYARROW import pandas as pd import pandas._testing as tm @@ -31,10 +31,6 @@ from pandas.core.arrays.string_ import StringDtype from pandas.tests.extension import base -pytestmark = pytest.mark.xfail( - using_string_dtype(), reason="TODO(infer_string)", strict=False -) - def maybe_split_array(arr, chunked): if not chunked: @@ -217,6 +213,36 @@ def test_compare_scalar(self, data, comparison_op): def test_groupby_extension_apply(self, data_for_grouping, groupby_apply_op): super().test_groupby_extension_apply(data_for_grouping, groupby_apply_op) + def test_combine_add(self, data_repeated, using_infer_string, request): + dtype = next(data_repeated(1)).dtype + if using_infer_string and ( + (dtype.na_value is pd.NA) and (dtype.storage == "python" and HAS_PYARROW) + ): + mark = pytest.mark.xfail( + reason="The pointwise operation result will be inferred to " + "string[nan, pyarrow], which does not match the input dtype" + ) + request.node.add_marker(mark) + super().test_combine_add(data_repeated) + + def test_arith_series_with_array( + self, data, all_arithmetic_operators, using_infer_string, request + ): + dtype = data.dtype + if ( + using_infer_string + and all_arithmetic_operators == "__radd__" + and ( + (dtype.na_value is pd.NA) or (dtype.storage == "python" and HAS_PYARROW) + ) + ): + mark = pytest.mark.xfail( + reason="The pointwise operation result will be inferred to " + "string[nan, pyarrow], which does not match the input dtype" + ) + request.node.add_marker(mark) + super().test_arith_series_with_array(data, all_arithmetic_operators) + class Test2DCompat(base.Dim2CompatTests): @pytest.fixture(autouse=True) From 6446d0af2e8c3e3d82b500dc1b9e38954efd08d6 Mon Sep 17 00:00:00 2001 From: Brock Date: Wed, 4 Sep 2024 07:29:49 -0700 Subject: [PATCH 2/4] Fix no-pyarrow test --- pandas/tests/extension/test_string.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/extension/test_string.py b/pandas/tests/extension/test_string.py index bc090081ee53c..f48d5caff9985 100644 --- a/pandas/tests/extension/test_string.py +++ b/pandas/tests/extension/test_string.py @@ -216,7 +216,7 @@ def test_groupby_extension_apply(self, data_for_grouping, groupby_apply_op): def test_combine_add(self, data_repeated, using_infer_string, request): dtype = next(data_repeated(1)).dtype if using_infer_string and ( - (dtype.na_value is pd.NA) and (dtype.storage == "python" and HAS_PYARROW) + (dtype.na_value is pd.NA) and dtype.storage == "python" ): mark = pytest.mark.xfail( reason="The pointwise operation result will be inferred to " From 0644def02381317e770403ab3bfb6269e02eb4f5 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Wed, 4 Sep 2024 11:09:03 -0700 Subject: [PATCH 3/4] Update pandas/tests/extension/test_string.py Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> --- pandas/tests/extension/test_string.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/extension/test_string.py b/pandas/tests/extension/test_string.py index f48d5caff9985..c9427785cb175 100644 --- a/pandas/tests/extension/test_string.py +++ b/pandas/tests/extension/test_string.py @@ -222,7 +222,7 @@ def test_combine_add(self, data_repeated, using_infer_string, request): reason="The pointwise operation result will be inferred to " "string[nan, pyarrow], which does not match the input dtype" ) - request.node.add_marker(mark) + request.applymarker(mark) super().test_combine_add(data_repeated) def test_arith_series_with_array( From 167c03ced7caf575fa162daa950024db74748792 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Wed, 4 Sep 2024 11:09:08 -0700 Subject: [PATCH 4/4] Update pandas/tests/extension/test_string.py Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> --- pandas/tests/extension/test_string.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/extension/test_string.py b/pandas/tests/extension/test_string.py index c9427785cb175..17f6eb8282b23 100644 --- a/pandas/tests/extension/test_string.py +++ b/pandas/tests/extension/test_string.py @@ -240,7 +240,7 @@ def test_arith_series_with_array( reason="The pointwise operation result will be inferred to " "string[nan, pyarrow], which does not match the input dtype" ) - request.node.add_marker(mark) + request.applymarker(mark) super().test_arith_series_with_array(data, all_arithmetic_operators)