Skip to content

Commit

Permalink
TST (string dtype): remove xfails in extension tests + fix categorica…
Browse files Browse the repository at this point in the history
…l/string dispatch (#60134)

Co-authored-by: Matthew Roeschke <[email protected]>
  • Loading branch information
jorisvandenbossche and mroeschke authored Nov 4, 2024
1 parent dc057b4 commit 988a7c8
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 36 deletions.
1 change: 0 additions & 1 deletion pandas/core/arrays/string_.py
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,6 @@ def _cmp_method(self, other, op):
if not is_array_like(other):
other = np.asarray(other)
other = other[valid]
other = np.asarray(other)

if op.__name__ in ops.ARITHMETIC_BINOPS:
result = np.empty_like(self._ndarray, dtype="object")
Expand Down
26 changes: 0 additions & 26 deletions pandas/tests/extension/base/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
import numpy as np
import pytest

from pandas._config import using_string_dtype

from pandas.compat import HAS_PYARROW

from pandas.core.dtypes.common import is_string_dtype

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

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

@pytest.mark.xfail(
using_string_dtype() and not HAS_PYARROW,
reason="TODO(infer_string)",
strict=False,
)
def test_arith_frame_with_scalar(self, data, all_arithmetic_operators):
# frame & scalar
if all_arithmetic_operators == "__rmod__" and is_string_dtype(data.dtype):
Expand All @@ -163,22 +148,12 @@ def test_arith_frame_with_scalar(self, data, all_arithmetic_operators):
df = pd.DataFrame({"A": data})
self.check_opname(df, op_name, data[0])

@pytest.mark.xfail(
using_string_dtype() and not HAS_PYARROW,
reason="TODO(infer_string)",
strict=False,
)
def test_arith_series_with_array(self, data, all_arithmetic_operators):
# ndarray & other series
op_name = all_arithmetic_operators
ser = pd.Series(data)
self.check_opname(ser, op_name, pd.Series([ser.iloc[0]] * len(ser)))

@pytest.mark.xfail(
using_string_dtype() and not HAS_PYARROW,
reason="TODO(infer_string)",
strict=False,
)
def test_divmod(self, data):
ser = pd.Series(data)
self._check_divmod_op(ser, divmod, 1)
Expand All @@ -194,7 +169,6 @@ def test_divmod_series_array(self, data, data_for_twos):
other = pd.Series(other)
self._check_divmod_op(other, ops.rdivmod, ser)

@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
def test_add_series_with_extension_array(self, data):
# Check adding an ExtensionArray to a Series of the same dtype matches
# the behavior of adding the arrays directly and then wrapping in a
Expand Down
2 changes: 0 additions & 2 deletions pandas/tests/extension/test_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ def test_map(self, data, na_action):
result = data.map(lambda x: x, na_action=na_action)
tm.assert_extension_array_equal(result, data)

@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
def test_arith_frame_with_scalar(self, data, all_arithmetic_operators, request):
# frame & scalar
op_name = all_arithmetic_operators
Expand All @@ -152,7 +151,6 @@ def test_arith_frame_with_scalar(self, data, all_arithmetic_operators, request):
)
super().test_arith_frame_with_scalar(data, op_name)

@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
def test_arith_series_with_scalar(self, data, all_arithmetic_operators, request):
op_name = all_arithmetic_operators
if op_name == "__rmod__":
Expand Down
7 changes: 0 additions & 7 deletions pandas/tests/extension/test_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import numpy as np
import pytest

from pandas._config import using_string_dtype

from pandas.core.dtypes.dtypes import NumpyEADtype

import pandas as pd
Expand Down Expand Up @@ -257,15 +255,13 @@ def test_insert_invalid(self, data, invalid_scalar):
frame_scalar_exc = None
series_array_exc = None

@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
def test_divmod(self, data):
divmod_exc = None
if data.dtype.kind == "O":
divmod_exc = TypeError
self.divmod_exc = divmod_exc
super().test_divmod(data)

@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
def test_divmod_series_array(self, data):
ser = pd.Series(data)
exc = None
Expand All @@ -274,7 +270,6 @@ def test_divmod_series_array(self, data):
self.divmod_exc = exc
self._check_divmod_op(ser, divmod, data)

@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
def test_arith_series_with_scalar(self, data, all_arithmetic_operators, request):
opname = all_arithmetic_operators
series_scalar_exc = None
Expand All @@ -288,7 +283,6 @@ def test_arith_series_with_scalar(self, data, all_arithmetic_operators, request)
self.series_scalar_exc = series_scalar_exc
super().test_arith_series_with_scalar(data, all_arithmetic_operators)

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

@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)", strict=False)
def test_arith_frame_with_scalar(self, data, all_arithmetic_operators, request):
opname = all_arithmetic_operators
frame_scalar_exc = None
Expand Down

0 comments on commit 988a7c8

Please sign in to comment.