Skip to content

Commit 2e80a5b

Browse files
authored
CLN: remove no-longer-needed warning filters (#58025)
1 parent 1f4c56b commit 2e80a5b

File tree

12 files changed

+6
-53
lines changed

12 files changed

+6
-53
lines changed

pandas/core/generic.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -9660,13 +9660,7 @@ def _where(
96609660

96619661
# make sure we are boolean
96629662
fill_value = bool(inplace)
9663-
with warnings.catch_warnings():
9664-
warnings.filterwarnings(
9665-
"ignore",
9666-
"Downcasting object dtype arrays",
9667-
category=FutureWarning,
9668-
)
9669-
cond = cond.fillna(fill_value)
9663+
cond = cond.fillna(fill_value)
96709664
cond = cond.infer_objects()
96719665

96729666
msg = "Boolean array expected for the condition, not {dtype}"

pandas/io/formats/xml.py

+1-8
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
Any,
1212
final,
1313
)
14-
import warnings
1514

1615
from pandas.errors import AbstractMethodError
1716
from pandas.util._decorators import (
@@ -208,13 +207,7 @@ def _process_dataframe(self) -> dict[int | str, dict[str, Any]]:
208207
df = df.reset_index()
209208

210209
if self.na_rep is not None:
211-
with warnings.catch_warnings():
212-
warnings.filterwarnings(
213-
"ignore",
214-
"Downcasting object dtype arrays",
215-
category=FutureWarning,
216-
)
217-
df = df.fillna(self.na_rep)
210+
df = df.fillna(self.na_rep)
218211

219212
return df.to_dict(orient="index")
220213

pandas/io/json/_json.py

+1-8
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
final,
1717
overload,
1818
)
19-
import warnings
2019

2120
import numpy as np
2221

@@ -1173,13 +1172,7 @@ def _try_convert_data(
11731172
if all(notna(data)):
11741173
return data, False
11751174

1176-
with warnings.catch_warnings():
1177-
warnings.filterwarnings(
1178-
"ignore",
1179-
"Downcasting object dtype arrays",
1180-
category=FutureWarning,
1181-
)
1182-
filled = data.fillna(np.nan)
1175+
filled = data.fillna(np.nan)
11831176

11841177
return filled, True
11851178

pandas/io/stata.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -2887,13 +2887,7 @@ def _prepare_data(self) -> np.rec.recarray:
28872887
for i, col in enumerate(data):
28882888
typ = typlist[i]
28892889
if typ <= self._max_string_length:
2890-
with warnings.catch_warnings():
2891-
warnings.filterwarnings(
2892-
"ignore",
2893-
"Downcasting object dtype arrays",
2894-
category=FutureWarning,
2895-
)
2896-
dc = data[col].fillna("")
2890+
dc = data[col].fillna("")
28972891
data[col] = dc.apply(_pad_bytes, args=(typ,))
28982892
stype = f"S{typ}"
28992893
dtypes[col] = stype

pandas/plotting/_matplotlib/core.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -1725,13 +1725,7 @@ def _kind(self) -> Literal["area"]:
17251725

17261726
def __init__(self, data, **kwargs) -> None:
17271727
kwargs.setdefault("stacked", True)
1728-
with warnings.catch_warnings():
1729-
warnings.filterwarnings(
1730-
"ignore",
1731-
"Downcasting object dtype arrays",
1732-
category=FutureWarning,
1733-
)
1734-
data = data.fillna(value=0)
1728+
data = data.fillna(value=0)
17351729
LinePlot.__init__(self, data, **kwargs)
17361730

17371731
if not self.stacked:

pandas/tests/extension/test_masked.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
1515
"""
1616

17-
import warnings
18-
1917
import numpy as np
2018
import pytest
2119

@@ -215,13 +213,7 @@ def _cast_pointwise_result(self, op_name: str, obj, other, pointwise_result):
215213

216214
if sdtype.kind in "iu":
217215
if op_name in ("__rtruediv__", "__truediv__", "__div__"):
218-
with warnings.catch_warnings():
219-
warnings.filterwarnings(
220-
"ignore",
221-
"Downcasting object dtype arrays",
222-
category=FutureWarning,
223-
)
224-
filled = expected.fillna(np.nan)
216+
filled = expected.fillna(np.nan)
225217
expected = filled.astype("Float64")
226218
else:
227219
# combine method result in 'biggest' (int64) dtype

pandas/tests/frame/indexing/test_where.py

-2
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ def test_where_upcasting(self):
9696

9797
tm.assert_series_equal(result, expected)
9898

99-
@pytest.mark.filterwarnings("ignore:Downcasting object dtype arrays:FutureWarning")
10099
def test_where_alignment(self, where_frame, float_string_frame):
101100
# aligning
102101
def _check_align(df, cond, other, check_dtypes=True):
@@ -171,7 +170,6 @@ def test_where_invalid(self):
171170
with pytest.raises(ValueError, match=msg):
172171
df.mask(0)
173172

174-
@pytest.mark.filterwarnings("ignore:Downcasting object dtype arrays:FutureWarning")
175173
def test_where_set(self, where_frame, float_string_frame, mixed_int_frame):
176174
# where inplace
177175

pandas/tests/frame/test_reductions.py

-1
Original file line numberDiff line numberDiff line change
@@ -1272,7 +1272,6 @@ def test_any_all_bool_with_na(
12721272
):
12731273
getattr(bool_frame_with_na, all_boolean_reductions)(axis=axis, bool_only=False)
12741274

1275-
@pytest.mark.filterwarnings("ignore:Downcasting object dtype arrays:FutureWarning")
12761275
def test_any_all_bool_frame(self, all_boolean_reductions, bool_frame_with_na):
12771276
# GH#12863: numpy gives back non-boolean data for object type
12781277
# so fill NaNs to compare with pandas behavior

pandas/tests/frame/test_stack_unstack.py

-1
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,6 @@ def test_stack_preserve_categorical_dtype_values(self, future_stack):
12231223
@pytest.mark.filterwarnings(
12241224
"ignore:The previous implementation of stack is deprecated"
12251225
)
1226-
@pytest.mark.filterwarnings("ignore:Downcasting object dtype arrays:FutureWarning")
12271226
@pytest.mark.parametrize(
12281227
"index",
12291228
[

pandas/tests/groupby/test_numeric_only.py

-1
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,6 @@ def test_numeric_only(kernel, has_arg, numeric_only, keys):
310310
method(*args, **kwargs)
311311

312312

313-
@pytest.mark.filterwarnings("ignore:Downcasting object dtype arrays:FutureWarning")
314313
@pytest.mark.parametrize("dtype", [bool, int, float, object])
315314
def test_deprecate_numeric_only_series(dtype, groupby_func, request):
316315
# GH#46560

pandas/tests/series/test_api.py

-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ def test_series_datetimelike_attribute_access_invalid(self):
195195
with pytest.raises(AttributeError, match=msg):
196196
ser.weekday
197197

198-
@pytest.mark.filterwarnings("ignore:Downcasting object dtype arrays:FutureWarning")
199198
@pytest.mark.parametrize(
200199
"kernel, has_numeric_only",
201200
[

pandas/tests/series/test_logical_ops.py

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616

1717
class TestSeriesLogicalOps:
18-
@pytest.mark.filterwarnings("ignore:Downcasting object dtype arrays:FutureWarning")
1918
@pytest.mark.parametrize("bool_op", [operator.and_, operator.or_, operator.xor])
2019
def test_bool_operators_with_nas(self, bool_op):
2120
# boolean &, |, ^ should work with object arrays and propagate NAs

0 commit comments

Comments
 (0)