Skip to content

Commit fac3b21

Browse files
authored
CLN: xfails, FIXMEs (#44804)
1 parent 8f8e3a8 commit fac3b21

File tree

14 files changed

+49
-69
lines changed

14 files changed

+49
-69
lines changed

pandas/_testing/_warnings.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,14 @@ def _assert_caught_no_extra_warnings(
149149
if _is_unexpected_warning(actual_warning, expected_warning):
150150
# GH 44732: Don't make the CI flaky by filtering SSL-related
151151
# ResourceWarning from dependencies
152+
# GH#38630 pytest.filterwarnings does not suppress these.
152153
unclosed_ssl = (
153154
"unclosed transport <asyncio.sslproto._SSLProtocolTransport",
154155
"unclosed <ssl.SSLSocket",
155156
)
156157
if actual_warning.category == ResourceWarning and any(
157158
msg in str(actual_warning.message) for msg in unclosed_ssl
158159
):
159-
# FIXME(GH#38630): kludge because pytest.filterwarnings does not
160-
# suppress these
161160
continue
162161

163162
extra_warnings.append(

pandas/core/arraylike.py

+2
Original file line numberDiff line numberDiff line change
@@ -367,10 +367,12 @@ def reconstruct(result):
367367
return result
368368

369369
if "out" in kwargs:
370+
# e.g. test_multiindex_get_loc
370371
result = dispatch_ufunc_with_out(self, ufunc, method, *inputs, **kwargs)
371372
return reconstruct(result)
372373

373374
if method == "reduce":
375+
# e.g. test.series.test_ufunc.test_reduce
374376
result = dispatch_reduction_ufunc(self, ufunc, method, *inputs, **kwargs)
375377
if result is not NotImplemented:
376378
return result

pandas/core/arrays/interval.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -800,10 +800,12 @@ def min(self, *, axis: int | None = None, skipna: bool = True):
800800
if mask.any():
801801
if not skipna:
802802
return self._na_value
803-
return self[~mask].min()
803+
obj = self[~mask]
804+
else:
805+
obj = self
804806

805-
indexer = self.argsort()[0]
806-
return self[indexer]
807+
indexer = obj.argsort()[0]
808+
return obj[indexer]
807809

808810
def max(self, *, axis: int | None = None, skipna: bool = True):
809811
nv.validate_minmax_axis(axis, self.ndim)
@@ -815,10 +817,12 @@ def max(self, *, axis: int | None = None, skipna: bool = True):
815817
if mask.any():
816818
if not skipna:
817819
return self._na_value
818-
return self[~mask].max()
820+
obj = self[~mask]
821+
else:
822+
obj = self
819823

820-
indexer = self.argsort()[-1]
821-
return self[indexer]
824+
indexer = obj.argsort()[-1]
825+
return obj[indexer]
822826

823827
def fillna(
824828
self: IntervalArrayT, value=None, method=None, limit=None

pandas/core/arrays/numpy_.py

+6-17
Original file line numberDiff line numberDiff line change
@@ -137,23 +137,12 @@ def __array_ufunc__(self, ufunc: np.ufunc, method: str, *inputs, **kwargs):
137137
# The primary modification is not boxing scalar return values
138138
# in PandasArray, since pandas' ExtensionArrays are 1-d.
139139
out = kwargs.get("out", ())
140-
for x in inputs + out:
141-
# Only support operations with instances of _HANDLED_TYPES.
142-
# Use PandasArray instead of type(self) for isinstance to
143-
# allow subclasses that don't override __array_ufunc__ to
144-
# handle PandasArray objects.
145-
if not isinstance(x, self._HANDLED_TYPES + (PandasArray,)):
146-
return NotImplemented
147-
148-
if ufunc not in [np.logical_or, np.bitwise_or, np.bitwise_xor]:
149-
# For binary ops, use our custom dunder methods
150-
# We haven't implemented logical dunder funcs, so exclude these
151-
# to avoid RecursionError
152-
result = ops.maybe_dispatch_ufunc_to_dunder_op(
153-
self, ufunc, method, *inputs, **kwargs
154-
)
155-
if result is not NotImplemented:
156-
return result
140+
141+
result = ops.maybe_dispatch_ufunc_to_dunder_op(
142+
self, ufunc, method, *inputs, **kwargs
143+
)
144+
if result is not NotImplemented:
145+
return result
157146

158147
# Defer to the implementation of the ufunc on unwrapped values.
159148
inputs = tuple(x._ndarray if isinstance(x, PandasArray) else x for x in inputs)

pandas/core/indexes/period.py

+4
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ def __new__(
230230

231231
if data is None and ordinal is None:
232232
# range-based.
233+
if not fields:
234+
# test_pickle_compat_construction
235+
raise cls._scalar_data_error(None)
236+
233237
data, freq2 = PeriodArray._generate_range(None, None, None, freq, fields)
234238
# PeriodArray._generate range does validation that fields is
235239
# empty when really using the range-based constructor.

pandas/tests/frame/methods/test_fillna.py

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import numpy as np
22
import pytest
33

4-
import pandas.util._test_decorators as td
5-
64
from pandas import (
75
Categorical,
86
DataFrame,
@@ -281,7 +279,6 @@ def test_fillna_dtype_conversion_equiv_replace(self, val):
281279
result = df.fillna(val)
282280
tm.assert_frame_equal(result, expected)
283281

284-
@td.skip_array_manager_invalid_test
285282
def test_fillna_datetime_columns(self):
286283
# GH#7095
287284
df = DataFrame(

pandas/tests/indexes/datetimelike_/test_equals.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,17 @@ def test_equals2(self):
166166
assert not idx.equals(pd.Series(idx2))
167167

168168
# Check that we dont raise OverflowError on comparisons outside the
169-
# implementation range
169+
# implementation range GH#28532
170170
oob = Index([timedelta(days=10 ** 6)] * 3, dtype=object)
171171
assert not idx.equals(oob)
172172
assert not idx2.equals(oob)
173173

174-
# FIXME: oob.apply(np.timedelta64) incorrectly overflows
175174
oob2 = Index([np.timedelta64(x) for x in oob], dtype=object)
175+
assert (oob == oob2).all()
176176
assert not idx.equals(oob2)
177177
assert not idx2.equals(oob2)
178+
179+
oob3 = oob.map(np.timedelta64)
180+
assert (oob3 == oob).all()
181+
assert not idx.equals(oob3)
182+
assert not idx2.equals(oob3)

pandas/tests/indexes/multi/test_setops.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,7 @@ def test_union_sort_other_empty(slice_):
361361
# default, sort=None
362362
other = idx[slice_]
363363
tm.assert_index_equal(idx.union(other), idx)
364-
# MultiIndex does not special case empty.union(idx)
365-
# FIXME: don't leave commented-out
366-
# tm.assert_index_equal(other.union(idx), idx)
364+
tm.assert_index_equal(other.union(idx), idx)
367365

368366
# sort=False
369367
tm.assert_index_equal(idx.union(other, sort=False), idx)

pandas/tests/indexes/period/test_period.py

-4
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ def simple_index(self) -> Index:
3434
def index(self, request):
3535
return request.param
3636

37-
@pytest.mark.xfail(reason="Goes through a generate_range path")
38-
def test_pickle_compat_construction(self):
39-
super().test_pickle_compat_construction()
40-
4137
def test_where(self):
4238
# This is handled in test_indexing
4339
pass

pandas/tests/indexes/test_base.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -816,14 +816,17 @@ def test_isin_nan_common_object(self, request, nulls_fixture, nulls_fixture2):
816816
)
817817

818818
def test_isin_nan_common_float64(self, request, nulls_fixture):
819-
if nulls_fixture is pd.NaT:
820-
pytest.skip("pd.NaT not compatible with Float64Index")
821819

822-
# Float64Index overrides isin, so must be checked separately
823-
if nulls_fixture is pd.NA:
824-
request.node.add_marker(
825-
pytest.mark.xfail(reason="Float64Index cannot contain pd.NA")
826-
)
820+
if nulls_fixture is pd.NaT or nulls_fixture is pd.NA:
821+
# Check 1) that we cannot construct a Float64Index with this value
822+
# and 2) that with an NaN we do not have .isin(nulls_fixture)
823+
msg = "data is not compatible with Float64Index"
824+
with pytest.raises(ValueError, match=msg):
825+
Float64Index([1.0, nulls_fixture])
826+
827+
idx = Float64Index([1.0, np.nan])
828+
assert not idx.isin([nulls_fixture]).any()
829+
return
827830

828831
idx = Float64Index([1.0, nulls_fixture])
829832
res = idx.isin([np.nan])

pandas/tests/io/parser/common/test_chunksize.py

+3-19
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def test_chunks_have_consistent_numerical_type(all_parsers):
176176
assert result.a.dtype == float
177177

178178

179-
def test_warn_if_chunks_have_mismatched_type(all_parsers, request):
179+
def test_warn_if_chunks_have_mismatched_type(all_parsers):
180180
warning_type = None
181181
parser = all_parsers
182182
size = 10000
@@ -193,24 +193,8 @@ def test_warn_if_chunks_have_mismatched_type(all_parsers, request):
193193

194194
buf = StringIO(data)
195195

196-
try:
197-
with tm.assert_produces_warning(warning_type):
198-
df = parser.read_csv(buf)
199-
except AssertionError as err:
200-
# 2021-02-21 this occasionally fails on the CI with an unexpected
201-
# ResourceWarning that we have been unable to track down,
202-
# see GH#38630
203-
if "ResourceWarning" not in str(err) or parser.engine != "python":
204-
raise
205-
206-
# Check the main assertion of the test before re-raising
207-
assert df.a.dtype == object
208-
209-
mark = pytest.mark.xfail(
210-
reason="ResourceWarning for unclosed SSL Socket, GH#38630"
211-
)
212-
request.node.add_marker(mark)
213-
raise
196+
with tm.assert_produces_warning(warning_type):
197+
df = parser.read_csv(buf)
214198

215199
assert df.a.dtype == object
216200

pandas/tests/io/test_html.py

+4
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,10 @@ def test_displayed_only(self, displayed_only, exp0, exp1):
11661166
else:
11671167
assert len(dfs) == 1 # Should not parse hidden table
11681168

1169+
@pytest.mark.filterwarnings(
1170+
"ignore:You provided Unicode markup but also provided a value for "
1171+
"from_encoding.*:UserWarning"
1172+
)
11691173
def test_encode(self, html_encoding_file):
11701174
base_path = os.path.basename(html_encoding_file)
11711175
root = os.path.splitext(base_path)[0]

pandas/tests/plotting/test_series.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ def test_custom_business_day_freq(self):
720720

721721
_check_plot_works(s.plot)
722722

723-
@pytest.mark.xfail(reason="TODO: reason?")
723+
@pytest.mark.xfail(reason="GH#24426")
724724
def test_plot_accessor_updates_on_inplace(self):
725725
ser = Series([1, 2, 3, 4])
726726
_, ax = self.plt.subplots()

pandas/tests/series/indexing/test_setitem.py

-5
Original file line numberDiff line numberDiff line change
@@ -658,11 +658,6 @@ def test_index_where(self, obj, key, expected, val, request):
658658
mask = np.zeros(obj.shape, dtype=bool)
659659
mask[key] = True
660660

661-
if obj.dtype == bool:
662-
msg = "Index/Series casting behavior inconsistent GH#38692"
663-
mark = pytest.mark.xfail(reason=msg)
664-
request.node.add_marker(mark)
665-
666661
res = Index(obj).where(~mask, val)
667662
tm.assert_index_equal(res, Index(expected))
668663

0 commit comments

Comments
 (0)