Skip to content

Commit 01a93c8

Browse files
committed
back
1 parent dfc6a4a commit 01a93c8

File tree

2 files changed

+19
-24
lines changed

2 files changed

+19
-24
lines changed

pandas/tests/base/test_misc.py

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -147,29 +147,24 @@ def test_searchsorted(request, index_or_series_obj):
147147
# See gh-12238
148148
obj = index_or_series_obj
149149

150-
# 1. Check for multi-index
150+
if any(isinstance(x, str) for x in obj) and any(isinstance(x, int) for x in obj):
151+
request.applymarker(
152+
pytest.mark.xfail(reason="Cannot compare mixed types (str and int)")
153+
)
154+
151155
if isinstance(obj, pd.MultiIndex):
152-
request.applymarker(pytest.mark.xfail(reason="GH 14833", strict=False))
153-
return
154-
155-
# 2. Check for Index and subtypes
156-
if isinstance(obj, Index):
157-
# 2a. Mixed types
158-
if obj.inferred_type in ["mixed", "mixed-integer"]:
159-
try:
160-
obj = obj.astype(str)
161-
except (TypeError, ValueError):
162-
request.applymarker(
163-
pytest.mark.xfail(reason="Mixed types", strict=False)
164-
)
165-
return
166-
167-
# 2b. Complex types
168-
elif obj.dtype.kind == "c":
169-
request.applymarker(pytest.mark.xfail(reason="Complex types", strict=False))
170-
return
171-
172-
# 3. Run test ONLY if there isn't mixed/complex types
156+
# See gh-14833
157+
request.applymarker(
158+
pytest.mark.xfail(
159+
reason="np.searchsorted doesn't work on pd.MultiIndex: GH 14833"
160+
)
161+
)
162+
elif obj.dtype.kind == "c" and isinstance(obj, Index):
163+
# TODO: Should Series cases also raise? Looks like they use numpy
164+
# comparison semantics https://github.com/numpy/numpy/issues/15981
165+
mark = pytest.mark.xfail(reason="complex objects are not comparable")
166+
request.applymarker(mark)
167+
173168
max_obj = max(obj, default=0)
174169
index = np.searchsorted(obj, max_obj)
175170
assert 0 <= index <= len(obj)

pandas/tests/indexes/test_setops.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def test_set_ops_error_cases(self, case, method, index):
210210
@pytest.mark.filterwarnings(r"ignore:PeriodDtype\[B\] is deprecated:FutureWarning")
211211
def test_intersection_base(self, index):
212212
if isinstance(index, CategoricalIndex):
213-
pytest.mark.xfail(reason="Not relevant for CategoricalIndex")
213+
pytest.skip(f"Not relevant for {type(index).__name__}")
214214

215215
first = index[:5].unique()
216216
second = index[:3].unique()
@@ -236,7 +236,7 @@ def test_intersection_base(self, index):
236236
@pytest.mark.filterwarnings(r"ignore:PeriodDtype\[B\] is deprecated:FutureWarning")
237237
def test_union_base(self, index):
238238
if index.inferred_type in ["mixed", "mixed-integer"]:
239-
pytest.mark.xfail(reason="Not relevant for mixed types")
239+
pytest.skip("Mixed-type Index not orderable; union fails")
240240

241241
index = index.unique()
242242

0 commit comments

Comments
 (0)