Skip to content

CLN: remove no-longer-needed warning filters #58025

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -9660,13 +9660,7 @@ def _where(

# make sure we are boolean
fill_value = bool(inplace)
with warnings.catch_warnings():
warnings.filterwarnings(
"ignore",
"Downcasting object dtype arrays",
category=FutureWarning,
)
cond = cond.fillna(fill_value)
cond = cond.fillna(fill_value)
cond = cond.infer_objects()

msg = "Boolean array expected for the condition, not {dtype}"
Expand Down
9 changes: 1 addition & 8 deletions pandas/io/formats/xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
Any,
final,
)
import warnings

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

if self.na_rep is not None:
with warnings.catch_warnings():
warnings.filterwarnings(
"ignore",
"Downcasting object dtype arrays",
category=FutureWarning,
)
df = df.fillna(self.na_rep)
df = df.fillna(self.na_rep)

return df.to_dict(orient="index")

Expand Down
9 changes: 1 addition & 8 deletions pandas/io/json/_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
final,
overload,
)
import warnings

import numpy as np

Expand Down Expand Up @@ -1173,13 +1172,7 @@ def _try_convert_data(
if all(notna(data)):
return data, False

with warnings.catch_warnings():
warnings.filterwarnings(
"ignore",
"Downcasting object dtype arrays",
category=FutureWarning,
)
filled = data.fillna(np.nan)
filled = data.fillna(np.nan)

return filled, True

Expand Down
8 changes: 1 addition & 7 deletions pandas/io/stata.py
Original file line number Diff line number Diff line change
Expand Up @@ -2887,13 +2887,7 @@ def _prepare_data(self) -> np.rec.recarray:
for i, col in enumerate(data):
typ = typlist[i]
if typ <= self._max_string_length:
with warnings.catch_warnings():
warnings.filterwarnings(
"ignore",
"Downcasting object dtype arrays",
category=FutureWarning,
)
dc = data[col].fillna("")
dc = data[col].fillna("")
data[col] = dc.apply(_pad_bytes, args=(typ,))
stype = f"S{typ}"
dtypes[col] = stype
Expand Down
8 changes: 1 addition & 7 deletions pandas/plotting/_matplotlib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1725,13 +1725,7 @@ def _kind(self) -> Literal["area"]:

def __init__(self, data, **kwargs) -> None:
kwargs.setdefault("stacked", True)
with warnings.catch_warnings():
warnings.filterwarnings(
"ignore",
"Downcasting object dtype arrays",
category=FutureWarning,
)
data = data.fillna(value=0)
data = data.fillna(value=0)
LinePlot.__init__(self, data, **kwargs)

if not self.stacked:
Expand Down
10 changes: 1 addition & 9 deletions pandas/tests/extension/test_masked.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

"""

import warnings

import numpy as np
import pytest

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

if sdtype.kind in "iu":
if op_name in ("__rtruediv__", "__truediv__", "__div__"):
with warnings.catch_warnings():
warnings.filterwarnings(
"ignore",
"Downcasting object dtype arrays",
category=FutureWarning,
)
filled = expected.fillna(np.nan)
filled = expected.fillna(np.nan)
expected = filled.astype("Float64")
else:
# combine method result in 'biggest' (int64) dtype
Expand Down
2 changes: 0 additions & 2 deletions pandas/tests/frame/indexing/test_where.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def test_where_upcasting(self):

tm.assert_series_equal(result, expected)

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

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

Expand Down
1 change: 0 additions & 1 deletion pandas/tests/frame/test_reductions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,6 @@ def test_any_all_bool_with_na(
):
getattr(bool_frame_with_na, all_boolean_reductions)(axis=axis, bool_only=False)

@pytest.mark.filterwarnings("ignore:Downcasting object dtype arrays:FutureWarning")
def test_any_all_bool_frame(self, all_boolean_reductions, bool_frame_with_na):
# GH#12863: numpy gives back non-boolean data for object type
# so fill NaNs to compare with pandas behavior
Expand Down
1 change: 0 additions & 1 deletion pandas/tests/frame/test_stack_unstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,6 @@ def test_stack_preserve_categorical_dtype_values(self, future_stack):
@pytest.mark.filterwarnings(
"ignore:The previous implementation of stack is deprecated"
)
@pytest.mark.filterwarnings("ignore:Downcasting object dtype arrays:FutureWarning")
@pytest.mark.parametrize(
"index",
[
Expand Down
1 change: 0 additions & 1 deletion pandas/tests/groupby/test_numeric_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,6 @@ def test_numeric_only(kernel, has_arg, numeric_only, keys):
method(*args, **kwargs)


@pytest.mark.filterwarnings("ignore:Downcasting object dtype arrays:FutureWarning")
@pytest.mark.parametrize("dtype", [bool, int, float, object])
def test_deprecate_numeric_only_series(dtype, groupby_func, request):
# GH#46560
Expand Down
1 change: 0 additions & 1 deletion pandas/tests/series/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ def test_series_datetimelike_attribute_access_invalid(self):
with pytest.raises(AttributeError, match=msg):
ser.weekday

@pytest.mark.filterwarnings("ignore:Downcasting object dtype arrays:FutureWarning")
@pytest.mark.parametrize(
"kernel, has_numeric_only",
[
Expand Down
1 change: 0 additions & 1 deletion pandas/tests/series/test_logical_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@


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