Skip to content

Commit 6f4ebe6

Browse files
Backport PR #60134 on branch 2.3.x (TST (string dtype): remove xfails in extension tests + fix categorical/string dispatch) (#60178)
Backport PR #60134: TST (string dtype): remove xfails in extension tests + fix categorical/string dispatch Co-authored-by: Joris Van den Bossche <[email protected]>
1 parent 6a9ef0c commit 6f4ebe6

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
@@ -148,7 +148,6 @@ def test_map(self, data, na_action):
148148
result = data.map(lambda x: x, na_action=na_action)
149149
tm.assert_extension_array_equal(result, data)
150150

151-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
152151
def test_arith_frame_with_scalar(self, data, all_arithmetic_operators, request):
153152
# frame & scalar
154153
op_name = all_arithmetic_operators
@@ -160,7 +159,6 @@ def test_arith_frame_with_scalar(self, data, all_arithmetic_operators, request):
160159
)
161160
super().test_arith_frame_with_scalar(data, op_name)
162161

163-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
164162
def test_arith_series_with_scalar(self, data, all_arithmetic_operators, request):
165163
op_name = all_arithmetic_operators
166164
if op_name == "__rmod__":

pandas/tests/extension/test_numpy.py

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

21-
from pandas._config import using_string_dtype
22-
2321
from pandas.core.dtypes.dtypes import NumpyEADtype
2422

2523
import pandas as pd
@@ -244,15 +242,13 @@ def test_insert_invalid(self, data, invalid_scalar):
244242
frame_scalar_exc = None
245243
series_array_exc = None
246244

247-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
248245
def test_divmod(self, data):
249246
divmod_exc = None
250247
if data.dtype.kind == "O":
251248
divmod_exc = TypeError
252249
self.divmod_exc = divmod_exc
253250
super().test_divmod(data)
254251

255-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
256252
def test_divmod_series_array(self, data):
257253
ser = pd.Series(data)
258254
exc = None
@@ -261,7 +257,6 @@ def test_divmod_series_array(self, data):
261257
self.divmod_exc = exc
262258
self._check_divmod_op(ser, divmod, data)
263259

264-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
265260
def test_arith_series_with_scalar(self, data, all_arithmetic_operators, request):
266261
opname = all_arithmetic_operators
267262
series_scalar_exc = None
@@ -275,7 +270,6 @@ def test_arith_series_with_scalar(self, data, all_arithmetic_operators, request)
275270
self.series_scalar_exc = series_scalar_exc
276271
super().test_arith_series_with_scalar(data, all_arithmetic_operators)
277272

278-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
279273
def test_arith_series_with_array(self, data, all_arithmetic_operators):
280274
opname = all_arithmetic_operators
281275
series_array_exc = None
@@ -284,7 +278,6 @@ def test_arith_series_with_array(self, data, all_arithmetic_operators):
284278
self.series_array_exc = series_array_exc
285279
super().test_arith_series_with_array(data, all_arithmetic_operators)
286280

287-
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
288281
def test_arith_frame_with_scalar(self, data, all_arithmetic_operators, request):
289282
opname = all_arithmetic_operators
290283
frame_scalar_exc = None

0 commit comments

Comments
 (0)