Skip to content

Commit 988a7c8

Browse files
TST (string dtype): remove xfails in extension tests + fix categorical/string dispatch (#60134)
Co-authored-by: Matthew Roeschke <[email protected]>
1 parent dc057b4 commit 988a7c8

File tree

4 files changed

+0
-36
lines changed

4 files changed

+0
-36
lines changed

pandas/core/arrays/string_.py

-1
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,6 @@ def _cmp_method(self, other, op):
915915
if not is_array_like(other):
916916
other = np.asarray(other)
917917
other = other[valid]
918-
other = np.asarray(other)
919918

920919
if op.__name__ in ops.ARITHMETIC_BINOPS:
921920
result = np.empty_like(self._ndarray, dtype="object")

pandas/tests/extension/base/ops.py

-26
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
import numpy as np
66
import pytest
77

8-
from pandas._config import using_string_dtype
9-
10-
from pandas.compat import HAS_PYARROW
11-
128
from pandas.core.dtypes.common import is_string_dtype
139

1410
import pandas as pd
@@ -134,12 +130,6 @@ class BaseArithmeticOpsTests(BaseOpsUtil):
134130
series_array_exc: type[Exception] | None = TypeError
135131
divmod_exc: type[Exception] | None = TypeError
136132

137-
# TODO(infer_string) need to remove import of pyarrow
138-
@pytest.mark.xfail(
139-
using_string_dtype() and not HAS_PYARROW,
140-
reason="TODO(infer_string)",
141-
strict=False,
142-
)
143133
def test_arith_series_with_scalar(self, data, all_arithmetic_operators):
144134
# series & scalar
145135
if all_arithmetic_operators == "__rmod__" and is_string_dtype(data.dtype):
@@ -149,11 +139,6 @@ def test_arith_series_with_scalar(self, data, all_arithmetic_operators):
149139
ser = pd.Series(data)
150140
self.check_opname(ser, op_name, ser.iloc[0])
151141

152-
@pytest.mark.xfail(
153-
using_string_dtype() and not HAS_PYARROW,
154-
reason="TODO(infer_string)",
155-
strict=False,
156-
)
157142
def test_arith_frame_with_scalar(self, data, all_arithmetic_operators):
158143
# frame & scalar
159144
if all_arithmetic_operators == "__rmod__" and is_string_dtype(data.dtype):
@@ -163,22 +148,12 @@ def test_arith_frame_with_scalar(self, data, all_arithmetic_operators):
163148
df = pd.DataFrame({"A": data})
164149
self.check_opname(df, op_name, data[0])
165150

166-
@pytest.mark.xfail(
167-
using_string_dtype() and not HAS_PYARROW,
168-
reason="TODO(infer_string)",
169-
strict=False,
170-
)
171151
def test_arith_series_with_array(self, data, all_arithmetic_operators):
172152
# ndarray & other series
173153
op_name = all_arithmetic_operators
174154
ser = pd.Series(data)
175155
self.check_opname(ser, op_name, pd.Series([ser.iloc[0]] * len(ser)))
176156

177-
@pytest.mark.xfail(
178-
using_string_dtype() and not HAS_PYARROW,
179-
reason="TODO(infer_string)",
180-
strict=False,
181-
)
182157
def test_divmod(self, data):
183158
ser = pd.Series(data)
184159
self._check_divmod_op(ser, divmod, 1)
@@ -194,7 +169,6 @@ def test_divmod_series_array(self, data, data_for_twos):
194169
other = pd.Series(other)
195170
self._check_divmod_op(other, ops.rdivmod, ser)
196171

197-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
198172
def test_add_series_with_extension_array(self, data):
199173
# Check adding an ExtensionArray to a Series of the same dtype matches
200174
# the behavior of adding the arrays directly and then wrapping in a

pandas/tests/extension/test_categorical.py

-2
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ def test_map(self, data, na_action):
140140
result = data.map(lambda x: x, na_action=na_action)
141141
tm.assert_extension_array_equal(result, data)
142142

143-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
144143
def test_arith_frame_with_scalar(self, data, all_arithmetic_operators, request):
145144
# frame & scalar
146145
op_name = all_arithmetic_operators
@@ -152,7 +151,6 @@ def test_arith_frame_with_scalar(self, data, all_arithmetic_operators, request):
152151
)
153152
super().test_arith_frame_with_scalar(data, op_name)
154153

155-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
156154
def test_arith_series_with_scalar(self, data, all_arithmetic_operators, request):
157155
op_name = all_arithmetic_operators
158156
if op_name == "__rmod__":

pandas/tests/extension/test_numpy.py

-7
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
import numpy as np
2020
import pytest
2121

22-
from pandas._config import using_string_dtype
23-
2422
from pandas.core.dtypes.dtypes import NumpyEADtype
2523

2624
import pandas as pd
@@ -257,15 +255,13 @@ def test_insert_invalid(self, data, invalid_scalar):
257255
frame_scalar_exc = None
258256
series_array_exc = None
259257

260-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
261258
def test_divmod(self, data):
262259
divmod_exc = None
263260
if data.dtype.kind == "O":
264261
divmod_exc = TypeError
265262
self.divmod_exc = divmod_exc
266263
super().test_divmod(data)
267264

268-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
269265
def test_divmod_series_array(self, data):
270266
ser = pd.Series(data)
271267
exc = None
@@ -274,7 +270,6 @@ def test_divmod_series_array(self, data):
274270
self.divmod_exc = exc
275271
self._check_divmod_op(ser, divmod, data)
276272

277-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
278273
def test_arith_series_with_scalar(self, data, all_arithmetic_operators, request):
279274
opname = all_arithmetic_operators
280275
series_scalar_exc = None
@@ -288,7 +283,6 @@ def test_arith_series_with_scalar(self, data, all_arithmetic_operators, request)
288283
self.series_scalar_exc = series_scalar_exc
289284
super().test_arith_series_with_scalar(data, all_arithmetic_operators)
290285

291-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
292286
def test_arith_series_with_array(self, data, all_arithmetic_operators):
293287
opname = all_arithmetic_operators
294288
series_array_exc = None
@@ -297,7 +291,6 @@ def test_arith_series_with_array(self, data, all_arithmetic_operators):
297291
self.series_array_exc = series_array_exc
298292
super().test_arith_series_with_array(data, all_arithmetic_operators)
299293

300-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
301294
def test_arith_frame_with_scalar(self, data, all_arithmetic_operators, request):
302295
opname = all_arithmetic_operators
303296
frame_scalar_exc = None

0 commit comments

Comments
 (0)