Skip to content

Commit 0bcbef2

Browse files
more xfails specific for no pyarrow
1 parent 9c7e10f commit 0bcbef2

20 files changed

+124
-7
lines changed

pandas/tests/apply/test_numba.py

+1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def test_numba_nonunique_unsupported(apply_axis):
104104

105105

106106
def test_numba_unsupported_dtypes(apply_axis):
107+
pytest.importorskip("pyarrow")
107108
f = lambda x: x
108109
df = DataFrame({"a": [1, 2], "b": ["a", "b"], "c": [4, 5]})
109110
df["c"] = df["c"].astype("double[pyarrow]")

pandas/tests/arrays/boolean/test_arithmetic.py

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
import numpy as np
44
import pytest
55

6+
from pandas._config import using_string_dtype
7+
8+
from pandas.compat import HAS_PYARROW
9+
610
import pandas as pd
711
import pandas._testing as tm
812

@@ -90,6 +94,9 @@ def test_op_int8(left_array, right_array, opname):
9094
# -----------------------------------------------------------------------------
9195

9296

97+
@pytest.mark.xfail(
98+
using_string_dtype() and not HAS_PYARROW, reason="TODO(infer_string)"
99+
)
93100
def test_error_invalid_values(data, all_arithmetic_operators, using_infer_string):
94101
# invalid ops
95102

pandas/tests/frame/indexing/test_where.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.common import is_scalar
1012

1113
import pandas as pd
@@ -1018,6 +1020,9 @@ def test_where_producing_ea_cond_for_np_dtype():
10181020
tm.assert_frame_equal(result, expected)
10191021

10201022

1023+
@pytest.mark.xfail(
1024+
using_string_dtype() and not HAS_PYARROW, reason="TODO(infer_string)", strict=False
1025+
)
10211026
@pytest.mark.parametrize(
10221027
"replacement", [0.001, True, "snake", None, datetime(2022, 5, 4)]
10231028
)

pandas/tests/frame/methods/test_info.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from pandas._config import using_string_dtype
1111

1212
from pandas.compat import (
13+
HAS_PYARROW,
1314
IS64,
1415
PYPY,
1516
)
@@ -520,7 +521,7 @@ def test_info_int_columns():
520521
assert result == expected
521522

522523

523-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
524+
@pytest.mark.xfail(using_string_dtype() and HAS_PYARROW, reason="TODO(infer_string)")
524525
def test_memory_usage_empty_no_warning():
525526
# GH#50066
526527
df = DataFrame(index=["a", "b"])

pandas/tests/frame/methods/test_rank.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
import numpy as np
77
import pytest
88

9+
from pandas._config import using_string_dtype
10+
911
from pandas._libs.algos import (
1012
Infinity,
1113
NegInfinity,
1214
)
15+
from pandas.compat import HAS_PYARROW
1316

1417
from pandas import (
1518
DataFrame,
@@ -464,9 +467,18 @@ def test_rank_inf_nans_na_option(
464467
],
465468
)
466469
def test_rank_object_first(
467-
self, frame_or_series, na_option, ascending, expected, using_infer_string
470+
self,
471+
request,
472+
frame_or_series,
473+
na_option,
474+
ascending,
475+
expected,
476+
using_infer_string,
468477
):
469478
obj = frame_or_series(["foo", "foo", None, "foo"])
479+
if using_string_dtype() and not HAS_PYARROW and isinstance(obj, Series):
480+
request.applymarker(pytest.mark.xfail(reason="TODO(infer_string)"))
481+
470482
result = obj.rank(method="first", na_option=na_option, ascending=ascending)
471483
expected = frame_or_series(expected)
472484
if using_infer_string and isinstance(obj, Series):

pandas/tests/frame/methods/test_value_counts.py

+7
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
import pandas as pd
59
import pandas._testing as tm
610

@@ -132,6 +136,9 @@ def test_data_frame_value_counts_dropna_true(nulls_fixture):
132136
tm.assert_series_equal(result, expected)
133137

134138

139+
@pytest.mark.xfail(
140+
using_string_dtype() and not HAS_PYARROW, reason="TODO(infer_string)"
141+
)
135142
def test_data_frame_value_counts_dropna_false(nulls_fixture):
136143
# GH 41334
137144
df = pd.DataFrame(

pandas/tests/frame/test_api.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
from pandas._config import using_string_dtype
99
from pandas._config.config import option_context
1010

11+
from pandas.compat import HAS_PYARROW
12+
1113
import pandas as pd
1214
from pandas import (
1315
DataFrame,
@@ -113,7 +115,9 @@ def test_not_hashable(self):
113115
with pytest.raises(TypeError, match=msg):
114116
hash(empty_frame)
115117

116-
@pytest.mark.xfail(using_string_dtype(), reason="surrogates not allowed")
118+
@pytest.mark.xfail(
119+
using_string_dtype() and HAS_PYARROW, reason="surrogates not allowed"
120+
)
117121
def test_column_name_contains_unicode_surrogate(self):
118122
# GH 25509
119123
colname = "\ud83d"

pandas/tests/frame/test_arithmetic.py

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

1414
from pandas._config import using_string_dtype
1515

16+
from pandas.compat import HAS_PYARROW
17+
1618
import pandas as pd
1719
from pandas import (
1820
DataFrame,
@@ -1542,7 +1544,9 @@ def test_comparisons(self, simple_frame, float_frame, func):
15421544
with pytest.raises(ValueError, match=msg):
15431545
func(simple_frame, simple_frame[:2])
15441546

1545-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
1547+
@pytest.mark.xfail(
1548+
using_string_dtype() and HAS_PYARROW, reason="TODO(infer_string)"
1549+
)
15461550
def test_strings_to_numbers_comparisons_raises(self, compare_operators_no_eq_ne):
15471551
# GH 11565
15481552
df = DataFrame(

pandas/tests/frame/test_constructors.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from pandas._config import using_string_dtype
2525

2626
from pandas._libs import lib
27+
from pandas.compat import HAS_PYARROW
2728
from pandas.compat.numpy import np_version_gt2
2829
from pandas.errors import IntCastingNaNError
2930

@@ -299,7 +300,7 @@ def test_constructor_dtype_nocast_view_2d_array(self):
299300
df2 = DataFrame(df.values, dtype=df[0].dtype)
300301
assert df2._mgr.blocks[0].values.flags.c_contiguous
301302

302-
@pytest.mark.xfail(using_string_dtype(), reason="conversion copies")
303+
@pytest.mark.xfail(using_string_dtype() and HAS_PYARROW, reason="conversion copies")
303304
def test_1d_object_array_does_not_copy(self):
304305
# https://github.com/pandas-dev/pandas/issues/39272
305306
arr = np.array(["a", "b"], dtype="object")

pandas/tests/frame/test_logical_ops.py

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
import numpy as np
55
import pytest
66

7+
from pandas._config import using_string_dtype
8+
9+
from pandas.compat import HAS_PYARROW
10+
711
from pandas import (
812
CategoricalIndex,
913
DataFrame,
@@ -96,6 +100,9 @@ def test_logical_ops_int_frame(self):
96100
res_ser = df1a_int["A"] | df1a_bool["A"]
97101
tm.assert_series_equal(res_ser, df1a_bool["A"])
98102

103+
@pytest.mark.xfail(
104+
using_string_dtype() and not HAS_PYARROW, reason="TODO(infer_string)"
105+
)
99106
def test_logical_ops_invalid(self, using_infer_string):
100107
# GH#5808
101108

pandas/tests/groupby/test_groupby.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1408,7 +1408,7 @@ def g(group):
14081408

14091409

14101410
# TODO harmonize error messages
1411-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)")
1411+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
14121412
@pytest.mark.parametrize("grouper", ["A", ["A", "B"]])
14131413
def test_set_group_name(df, grouper, using_infer_string):
14141414
def f(group):

pandas/tests/indexes/test_old_base.py

+1
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ def test_repr_max_seq_item_setting(self, simple_index):
245245
repr(idx)
246246
assert "..." not in str(idx)
247247

248+
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
248249
@pytest.mark.filterwarnings(r"ignore:PeriodDtype\[B\] is deprecated:FutureWarning")
249250
def test_ensure_copied_data(self, index):
250251
# Check the "copy" argument of each Index.__new__ is honoured

pandas/tests/indexing/test_loc.py

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from pandas._config import using_string_dtype
1717

1818
from pandas._libs import index as libindex
19+
from pandas.compat import HAS_PYARROW
1920
from pandas.errors import IndexingError
2021

2122
import pandas as pd
@@ -1388,6 +1389,9 @@ def test_loc_setitem_categorical_values_partial_column_slice(self):
13881389
df.loc[1:2, "a"] = Categorical(["b", "b"], categories=["a", "b"])
13891390
df.loc[2:3, "b"] = Categorical(["b", "b"], categories=["a", "b"])
13901391

1392+
@pytest.mark.xfail(
1393+
using_string_dtype() and not HAS_PYARROW, reason="TODO(infer_string)"
1394+
)
13911395
def test_loc_setitem_single_row_categorical(self, using_infer_string):
13921396
# GH#25495
13931397
df = DataFrame({"Alpha": ["a"], "Numeric": [0]})

pandas/tests/io/parser/conftest.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import pytest
66

7+
from pandas.compat import HAS_PYARROW
78
from pandas.compat._optional import VERSIONS
89

910
from pandas import (
@@ -117,7 +118,15 @@ def csv1(datapath):
117118

118119
_py_parsers_only = [_pythonParser]
119120
_c_parsers_only = [_cParserHighMemory, _cParserLowMemory]
120-
_pyarrow_parsers_only = [pytest.param(_pyarrowParser, marks=pytest.mark.single_cpu)]
121+
_pyarrow_parsers_only = [
122+
pytest.param(
123+
_pyarrowParser,
124+
marks=[
125+
pytest.mark.single_cpu,
126+
pytest.mark.skipif(not HAS_PYARROW, reason="pyarrow is not installed"),
127+
],
128+
)
129+
]
121130

122131
_all_parsers = [*_c_parsers_only, *_py_parsers_only, *_pyarrow_parsers_only]
123132

pandas/tests/series/test_api.py

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
import numpy as np
55
import pytest
66

7+
from pandas._config import using_string_dtype
8+
9+
from pandas.compat import HAS_PYARROW
10+
711
import pandas as pd
812
from pandas import (
913
DataFrame,
@@ -160,6 +164,9 @@ def test_attrs(self):
160164
result = s + 1
161165
assert result.attrs == {"version": 1}
162166

167+
@pytest.mark.xfail(
168+
using_string_dtype() and not HAS_PYARROW, reason="TODO(infer_string)"
169+
)
163170
def test_inspect_getmembers(self):
164171
# GH38782
165172
pytest.importorskip("jinja2")

pandas/tests/series/test_arithmetic.py

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
from pandas._libs import lib
1515
from pandas._libs.tslibs import IncompatibleFrequency
16+
from pandas.compat import HAS_PYARROW
1617

1718
import pandas as pd
1819
from pandas import (
@@ -193,6 +194,9 @@ def test_string_addition(self, target_add, input_value, expected_value):
193194
expected = Series(expected_value)
194195
tm.assert_series_equal(result, expected)
195196

197+
@pytest.mark.xfail(
198+
using_string_dtype() and not HAS_PYARROW, reason="TODO(infer_string)"
199+
)
196200
def test_divmod(self):
197201
# GH#25557
198202
a = Series([1, 1, 1, np.nan], index=["a", "b", "c", "d"])

pandas/tests/series/test_logical_ops.py

+8
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 import (
1012
DataFrame,
1113
Index,
@@ -143,6 +145,9 @@ def test_logical_operators_int_dtype_with_bool(self):
143145
expected = Series([False, True, True, True])
144146
tm.assert_series_equal(result, expected)
145147

148+
@pytest.mark.xfail(
149+
using_string_dtype() and not HAS_PYARROW, reason="TODO(infer_string)"
150+
)
146151
def test_logical_operators_int_dtype_with_object(self, using_infer_string):
147152
# GH#9016: support bitwise op for integer types
148153
s_0123 = Series(range(4), dtype="int64")
@@ -462,6 +467,9 @@ def test_logical_ops_label_based(self, using_infer_string):
462467
with pytest.raises(TypeError, match=msg):
463468
t & v
464469

470+
@pytest.mark.xfail(
471+
using_string_dtype() and not HAS_PYARROW, reason="TODO(infer_string)"
472+
)
465473
def test_logical_ops_df_compat(self):
466474
# GH#1134
467475
s1 = Series([True, False, True], index=list("ABC"), name="x")

pandas/tests/series/test_reductions.py

+13
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
import pandas as pd
59
from pandas import Series
610
import pandas._testing as tm
@@ -162,6 +166,9 @@ def test_validate_stat_keepdims():
162166
np.sum(ser, keepdims=True)
163167

164168

169+
@pytest.mark.xfail(
170+
using_string_dtype() and not HAS_PYARROW, reason="TODO(infer_string)"
171+
)
165172
def test_mean_with_convertible_string_raises(using_infer_string):
166173
# GH#44008
167174
ser = Series(["1", "2"])
@@ -181,6 +188,9 @@ def test_mean_with_convertible_string_raises(using_infer_string):
181188
df.mean()
182189

183190

191+
@pytest.mark.xfail(
192+
using_string_dtype() and not HAS_PYARROW, reason="TODO(infer_string)"
193+
)
184194
def test_mean_dont_convert_j_to_complex():
185195
# GH#36703
186196
df = pd.DataFrame([{"db": "J", "numeric": 123}])
@@ -199,6 +209,9 @@ def test_mean_dont_convert_j_to_complex():
199209
np.mean(df["db"].astype("string").array)
200210

201211

212+
@pytest.mark.xfail(
213+
using_string_dtype() and not HAS_PYARROW, reason="TODO(infer_string)"
214+
)
202215
def test_median_with_convertible_string_raises():
203216
# GH#34671 this _could_ return a string "2", but definitely not float 2.0
204217
msg = r"Cannot convert \['1' '2' '3'\] to numeric|does not support"

0 commit comments

Comments
 (0)