Skip to content

Commit 26a3db1

Browse files
fixup xfails
1 parent 0b2bd61 commit 26a3db1

31 files changed

+183
-78
lines changed

Diff for: pandas/tests/apply/test_frame_apply.py

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
from pandas._config import using_string_dtype
88

9+
from pandas.compat import HAS_PYARROW
10+
911
from pandas.core.dtypes.dtypes import CategoricalDtype
1012

1113
import pandas as pd
@@ -1245,6 +1247,9 @@ def test_agg_multiple_mixed():
12451247
tm.assert_frame_equal(result, expected)
12461248

12471249

1250+
@pytest.mark.xfail(
1251+
using_string_dtype() and not HAS_PYARROW, reason="TODO(infer_string)"
1252+
)
12481253
def test_agg_multiple_mixed_raises():
12491254
# GH 20909
12501255
mdf = DataFrame(

Diff for: pandas/tests/apply/test_invalid_arg.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
from pandas._config import using_string_dtype
1616

17+
from pandas.compat import HAS_PYARROW
1718
from pandas.errors import SpecificationError
1819

1920
from pandas import (
@@ -212,7 +213,9 @@ def transform(row):
212213

213214

214215
# we should raise a proper TypeError instead of propagating the pyarrow error
215-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
216+
@pytest.mark.xfail(
217+
using_string_dtype() and not HAS_PYARROW, reason="TODO(infer_string)"
218+
)
216219
@pytest.mark.parametrize(
217220
"df, func, expected",
218221
tm.get_cython_table_params(
@@ -234,7 +237,9 @@ def test_agg_cython_table_raises_frame(df, func, expected, axis, using_infer_str
234237

235238

236239
# we should raise a proper TypeError instead of propagating the pyarrow error
237-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
240+
@pytest.mark.xfail(
241+
using_string_dtype() and not HAS_PYARROW, reason="TODO(infer_string)"
242+
)
238243
@pytest.mark.parametrize(
239244
"series, func, expected",
240245
chain(

Diff for: pandas/tests/arithmetic/test_object.py

+6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
import numpy as np
99
import pytest
1010

11+
from pandas._config import using_string_dtype
12+
13+
from pandas.compat import HAS_PYARROW
1114
import pandas.util._test_decorators as td
1215

1316
import pandas as pd
@@ -315,6 +318,9 @@ def test_add(self):
315318
expected = pd.Index(["1a", "1b", "1c"])
316319
tm.assert_index_equal("1" + index, expected)
317320

321+
@pytest.mark.xfail(
322+
using_string_dtype() and not HAS_PYARROW, reason="TODO(infer_string)"
323+
)
318324
def test_sub_fail(self, using_infer_string):
319325
index = pd.Index([str(i) for i in range(10)])
320326

Diff for: pandas/tests/arrays/categorical/test_analytics.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66

77
from pandas._config import using_string_dtype
88

9-
from pandas.compat import PYPY
9+
from pandas.compat import (
10+
HAS_PYARROW,
11+
PYPY,
12+
)
1013

1114
from pandas import (
1215
Categorical,
@@ -296,7 +299,9 @@ def test_nbytes(self):
296299
exp = 3 + 3 * 8 # 3 int8s for values + 3 int64s for categories
297300
assert cat.nbytes == exp
298301

299-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
302+
@pytest.mark.xfail(
303+
using_string_dtype() and HAS_PYARROW, reason="TODO(infer_string)"
304+
)
300305
def test_memory_usage(self):
301306
cat = Categorical([1, 2, 3])
302307

Diff for: pandas/tests/arrays/categorical/test_constructors.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
from pandas._config import using_string_dtype
1010

11+
from pandas.compat import HAS_PYARROW
12+
1113
from pandas.core.dtypes.common import (
1214
is_float_dtype,
1315
is_integer_dtype,
@@ -442,7 +444,9 @@ def test_constructor_str_unknown(self):
442444
with pytest.raises(ValueError, match="Unknown dtype"):
443445
Categorical([1, 2], dtype="foo")
444446

445-
@pytest.mark.xfail(using_string_dtype(), reason="Can't be NumPy strings")
447+
@pytest.mark.xfail(
448+
using_string_dtype() and HAS_PYARROW, reason="Can't be NumPy strings"
449+
)
446450
def test_constructor_np_strs(self):
447451
# GH#31499 Hashtable.map_locations needs to work on np.str_ objects
448452
cat = Categorical(["1", "0", "1"], [np.str_("0"), np.str_("1")])

Diff for: pandas/tests/arrays/integer/test_reduction.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import numpy as np
22
import pytest
33

4+
from pandas.compat import HAS_PYARROW
5+
46
import pandas as pd
57
from pandas import (
68
DataFrame,
@@ -102,9 +104,10 @@ def test_groupby_reductions(op, expected):
102104
["all", Series([True, True, True], index=["A", "B", "C"], dtype="boolean")],
103105
],
104106
)
105-
def test_mixed_reductions(op, expected, using_infer_string):
106-
if op in ["any", "all"] and using_infer_string:
107-
expected = expected.astype("bool")
107+
def test_mixed_reductions(request, op, expected, using_infer_string):
108+
if op in ["any", "all"] and using_infer_string and HAS_PYARROW:
109+
# TODO(infer_string) inconsistent result type
110+
request.applymarker(pytest.mark.xfail(reason="TODO(infer_string)"))
108111
df = DataFrame(
109112
{
110113
"A": ["a", "b", "b"],

Diff for: pandas/tests/base/test_conversion.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import numpy as np
22
import pytest
33

4+
from pandas._config import using_string_dtype
5+
6+
from pandas.compat import HAS_PYARROW
7+
48
from pandas.core.dtypes.dtypes import DatetimeTZDtype
59

610
import pandas as pd
@@ -20,6 +24,7 @@
2024
SparseArray,
2125
TimedeltaArray,
2226
)
27+
from pandas.core.arrays.string_ import StringArrayNumpySemantics
2328
from pandas.core.arrays.string_arrow import ArrowStringArrayNumpySemantics
2429

2530

@@ -218,7 +223,9 @@ def test_iter_box_period(self):
218223
)
219224
def test_values_consistent(arr, expected_type, dtype, using_infer_string):
220225
if using_infer_string and dtype == "object":
221-
expected_type = ArrowStringArrayNumpySemantics
226+
expected_type = (
227+
ArrowStringArrayNumpySemantics if HAS_PYARROW else StringArrayNumpySemantics
228+
)
222229
l_values = Series(arr)._values
223230
r_values = pd.Index(arr)._values
224231
assert type(l_values) is expected_type
@@ -355,6 +362,9 @@ def test_to_numpy(arr, expected, index_or_series_or_array, request):
355362
tm.assert_numpy_array_equal(result, expected)
356363

357364

365+
@pytest.mark.xfail(
366+
using_string_dtype() and not HAS_PYARROW, reason="TODO(infer_string)", strict=False
367+
)
358368
@pytest.mark.parametrize("as_series", [True, False])
359369
@pytest.mark.parametrize(
360370
"arr", [np.array([1, 2, 3], dtype="int64"), np.array(["a", "b", "c"], dtype=object)]

Diff for: pandas/tests/copy_view/test_astype.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from pandas._config import using_string_dtype
77

8+
from pandas.compat import HAS_PYARROW
89
from pandas.compat.pyarrow import pa_version_under12p0
910
import pandas.util._test_decorators as td
1011

@@ -197,7 +198,7 @@ def test_astype_arrow_timestamp():
197198
assert np.shares_memory(get_array(df, "a"), get_array(result, "a")._pa_array)
198199

199200

200-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
201+
@pytest.mark.xfail(using_string_dtype() and HAS_PYARROW, reason="TODO(infer_string)")
201202
def test_convert_dtypes_infer_objects():
202203
ser = Series(["a", "b", "c"])
203204
ser_orig = ser.copy()
@@ -213,7 +214,7 @@ def test_convert_dtypes_infer_objects():
213214
tm.assert_series_equal(ser, ser_orig)
214215

215216

216-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
217+
@pytest.mark.xfail(using_string_dtype() and HAS_PYARROW, reason="TODO(infer_string)")
217218
def test_convert_dtypes():
218219
df = DataFrame({"a": ["a", "b"], "b": [1, 2], "c": [1.5, 2.5], "d": [True, False]})
219220
df_orig = df.copy()

Diff for: pandas/tests/copy_view/test_functions.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
from pandas._config import using_string_dtype
55

6+
from pandas.compat import HAS_PYARROW
7+
68
from pandas import (
79
DataFrame,
810
Index,
@@ -14,7 +16,7 @@
1416
from pandas.tests.copy_view.util import get_array
1517

1618

17-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
19+
@pytest.mark.xfail(using_string_dtype() and HAS_PYARROW, reason="TODO(infer_string)")
1820
def test_concat_frames():
1921
df = DataFrame({"b": ["a"] * 3})
2022
df2 = DataFrame({"a": ["a"] * 3})
@@ -33,7 +35,7 @@ def test_concat_frames():
3335
tm.assert_frame_equal(df, df_orig)
3436

3537

36-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
38+
@pytest.mark.xfail(using_string_dtype() and HAS_PYARROW, reason="TODO(infer_string)")
3739
def test_concat_frames_updating_input():
3840
df = DataFrame({"b": ["a"] * 3})
3941
df2 = DataFrame({"a": ["a"] * 3})
@@ -153,7 +155,7 @@ def test_concat_copy_keyword():
153155
assert np.shares_memory(get_array(df2, "b"), get_array(result, "b"))
154156

155157

156-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
158+
@pytest.mark.xfail(using_string_dtype() and HAS_PYARROW, reason="TODO(infer_string)")
157159
@pytest.mark.parametrize(
158160
"func",
159161
[
@@ -249,7 +251,7 @@ def test_merge_copy_keyword():
249251
assert np.shares_memory(get_array(df2, "b"), get_array(result, "b"))
250252

251253

252-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
254+
@pytest.mark.xfail(using_string_dtype() and HAS_PYARROW, reason="TODO(infer_string)")
253255
def test_join_on_key():
254256
df_index = Index(["a", "b", "c"], name="key")
255257

@@ -277,7 +279,7 @@ def test_join_on_key():
277279
tm.assert_frame_equal(df2, df2_orig)
278280

279281

280-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
282+
@pytest.mark.xfail(using_string_dtype() and HAS_PYARROW, reason="TODO(infer_string)")
281283
def test_join_multiple_dataframes_on_key():
282284
df_index = Index(["a", "b", "c"], name="key")
283285

Diff for: pandas/tests/copy_view/test_interp_fillna.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
from pandas._config import using_string_dtype
55

6+
from pandas.compat import HAS_PYARROW
7+
68
from pandas import (
79
NA,
810
DataFrame,
@@ -121,7 +123,7 @@ def test_interpolate_cannot_with_object_dtype():
121123
df.interpolate()
122124

123125

124-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
126+
@pytest.mark.xfail(using_string_dtype() and HAS_PYARROW, reason="TODO(infer_string)")
125127
def test_interpolate_object_convert_no_op():
126128
df = DataFrame({"a": ["a", "b", "c"], "b": 1})
127129
arr_a = get_array(df, "a")

Diff for: pandas/tests/copy_view/test_methods.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
from pandas._config import using_string_dtype
55

6+
from pandas.compat import HAS_PYARROW
7+
68
import pandas as pd
79
from pandas import (
810
DataFrame,
@@ -714,7 +716,7 @@ def test_head_tail(method):
714716
tm.assert_frame_equal(df, df_orig)
715717

716718

717-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
719+
@pytest.mark.xfail(using_string_dtype() and HAS_PYARROW, reason="TODO(infer_string)")
718720
def test_infer_objects():
719721
df = DataFrame({"a": [1, 2], "b": "c", "c": 1, "d": "x"})
720722
df_orig = df.copy()
@@ -730,6 +732,9 @@ def test_infer_objects():
730732
tm.assert_frame_equal(df, df_orig)
731733

732734

735+
@pytest.mark.xfail(
736+
using_string_dtype() and not HAS_PYARROW, reason="TODO(infer_string)"
737+
)
733738
def test_infer_objects_no_reference():
734739
df = DataFrame(
735740
{
@@ -899,7 +904,7 @@ def test_sort_values_inplace(obj, kwargs):
899904
tm.assert_equal(view, obj_orig)
900905

901906

902-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
907+
@pytest.mark.xfail(using_string_dtype() and HAS_PYARROW, reason="TODO(infer_string)")
903908
@pytest.mark.parametrize("decimals", [-1, 0, 1])
904909
def test_round(decimals):
905910
df = DataFrame({"a": [1, 2], "b": "c"})

Diff for: pandas/tests/copy_view/test_replace.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
from pandas._config import using_string_dtype
55

6+
from pandas.compat import HAS_PYARROW
7+
68
from pandas import (
79
Categorical,
810
DataFrame,
@@ -59,7 +61,7 @@ def test_replace_regex_inplace_refs():
5961
tm.assert_frame_equal(view, df_orig)
6062

6163

62-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
64+
@pytest.mark.xfail(using_string_dtype() and HAS_PYARROW, reason="TODO(infer_string)")
6365
def test_replace_regex_inplace():
6466
df = DataFrame({"a": ["aaa", "bbb"]})
6567
arr = get_array(df, "a")
@@ -257,7 +259,7 @@ def test_replace_empty_list():
257259
assert not df2._mgr._has_no_reference(0)
258260

259261

260-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
262+
@pytest.mark.xfail(using_string_dtype() and HAS_PYARROW, reason="TODO(infer_string)")
261263
@pytest.mark.parametrize("value", ["d", None])
262264
def test_replace_object_list_inplace(value):
263265
df = DataFrame({"a": ["a", "b", "c"]})

Diff for: pandas/tests/extension/base/ops.py

+23-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
from pandas._config import using_string_dtype
99

10+
from pandas.compat import HAS_PYARROW
11+
1012
from pandas.core.dtypes.common import is_string_dtype
1113

1214
import pandas as pd
@@ -140,7 +142,12 @@ class BaseArithmeticOpsTests(BaseOpsUtil):
140142
series_array_exc: type[Exception] | None = TypeError
141143
divmod_exc: type[Exception] | None = TypeError
142144

143-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
145+
# TODO(infer_string) need to remove import of pyarrow
146+
@pytest.mark.xfail(
147+
using_string_dtype() and not HAS_PYARROW,
148+
reason="TODO(infer_string)",
149+
strict=False,
150+
)
144151
def test_arith_series_with_scalar(self, data, all_arithmetic_operators):
145152
# series & scalar
146153
if all_arithmetic_operators == "__rmod__" and is_string_dtype(data.dtype):
@@ -150,7 +157,11 @@ def test_arith_series_with_scalar(self, data, all_arithmetic_operators):
150157
ser = pd.Series(data)
151158
self.check_opname(ser, op_name, ser.iloc[0])
152159

153-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
160+
@pytest.mark.xfail(
161+
using_string_dtype() and not HAS_PYARROW,
162+
reason="TODO(infer_string)",
163+
strict=False,
164+
)
154165
def test_arith_frame_with_scalar(self, data, all_arithmetic_operators):
155166
# frame & scalar
156167
if all_arithmetic_operators == "__rmod__" and is_string_dtype(data.dtype):
@@ -160,14 +171,22 @@ def test_arith_frame_with_scalar(self, data, all_arithmetic_operators):
160171
df = pd.DataFrame({"A": data})
161172
self.check_opname(df, op_name, data[0])
162173

163-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
174+
@pytest.mark.xfail(
175+
using_string_dtype() and not HAS_PYARROW,
176+
reason="TODO(infer_string)",
177+
strict=False,
178+
)
164179
def test_arith_series_with_array(self, data, all_arithmetic_operators):
165180
# ndarray & other series
166181
op_name = all_arithmetic_operators
167182
ser = pd.Series(data)
168183
self.check_opname(ser, op_name, pd.Series([ser.iloc[0]] * len(ser)))
169184

170-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
185+
@pytest.mark.xfail(
186+
using_string_dtype() and not HAS_PYARROW,
187+
reason="TODO(infer_string)",
188+
strict=False,
189+
)
171190
def test_divmod(self, data):
172191
ser = pd.Series(data)
173192
self._check_divmod_op(ser, divmod, 1)

0 commit comments

Comments
 (0)