Skip to content

CLN: Remove 3rd party warning filters #50674

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 6 commits into from
Jan 13, 2023
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
3 changes: 0 additions & 3 deletions pandas/io/parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,6 @@ def write(
**kwargs,
) -> None:
self.validate_dataframe(df)
# thriftpy/protocol/compact.py:339:
# DeprecationWarning: tostring() is deprecated.
# Use tobytes() instead.

if "partition_on" in kwargs and partition_cols is not None:
raise ValueError(
Expand Down
5 changes: 4 additions & 1 deletion pandas/tests/frame/test_unary.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ def test_pos_object(self, df):
[
pytest.param(
pd.DataFrame({"a": ["a", "b"]}),
marks=[pytest.mark.filterwarnings("ignore")],
# filterwarnings removable once min numpy version is 1.25
marks=[
pytest.mark.filterwarnings("ignore:Applying:DeprecationWarning")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment on where this comes from and maybe condition under which we can stop filtering? (im guessing numpy>x.y.z)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC I don't think there's necessarily a version timeline of when deprecation warnings are enforced (unless that's in scope of numpy 2.0?) cc @seberg

Copy link
Contributor

@seberg seberg Jan 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ummm, not sure I want to tie cleaning out all deprecations to NumPy 2.0, but I guess it is safe. If it helps, you can also put 1.25 and I will just do it, heh...

(We need to clean up expired deprecations a bit more systematically...)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I'll just note that it will be changing in 1.25 so we can maybe be more proactive in changing this behavior

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just did it for 1.25/main, thanks.

],
),
],
)
Expand Down
20 changes: 0 additions & 20 deletions pandas/tests/io/__init__.py
Original file line number Diff line number Diff line change
@@ -1,20 +0,0 @@
import pytest

pytestmark = [
# fastparquet
pytest.mark.filterwarnings(
"ignore:PY_SSIZE_T_CLEAN will be required.*:DeprecationWarning"
),
pytest.mark.filterwarnings(
r"ignore:`np\.bool` is a deprecated alias:DeprecationWarning"
),
# xlrd
pytest.mark.filterwarnings(
"ignore:This method will be removed in future versions:DeprecationWarning"
),
pytest.mark.filterwarnings(
"ignore:This method will be removed in future versions. "
r"Use 'tree.iter\(\)' or 'list\(tree.iter\(\)\)' instead."
":PendingDeprecationWarning"
),
]
12 changes: 0 additions & 12 deletions pandas/tests/io/excel/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +0,0 @@
import pytest

pytestmark = [
pytest.mark.filterwarnings(
# Looks like tree.getiterator is deprecated in favor of tree.iter
"ignore:This method will be removed in future versions:"
"PendingDeprecationWarning"
),
pytest.mark.filterwarnings(
"ignore:This method will be removed in future versions:DeprecationWarning"
),
]
1 change: 0 additions & 1 deletion pandas/tests/io/excel/test_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"openpyxl",
marks=[
td.skip_if_no("openpyxl"),
pytest.mark.filterwarnings("ignore:.*html argument"),
],
),
pytest.param(
Expand Down
14 changes: 0 additions & 14 deletions pandas/tests/io/pytables/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +0,0 @@
import pytest

pytestmark = [
# pytables https://github.com/PyTables/PyTables/issues/822
pytest.mark.filterwarnings(
"ignore:a closed node found in the registry:UserWarning"
),
pytest.mark.filterwarnings(
r"ignore:`np\.object` is a deprecated alias.*:DeprecationWarning"
),
pytest.mark.filterwarnings(
r"ignore:`np\.bool` is a deprecated alias.*:DeprecationWarning"
),
]
4 changes: 0 additions & 4 deletions pandas/tests/io/pytables/test_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@

pytestmark = [
pytest.mark.single_cpu,
# pytables https://github.com/PyTables/PyTables/issues/822
pytest.mark.filterwarnings(
"ignore:a closed node found in the registry:UserWarning"
),
]


Expand Down
3 changes: 0 additions & 3 deletions pandas/tests/io/pytables/test_subclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
)

pytest.importorskip("tables")
pytestmark = pytest.mark.filterwarnings(
"ignore:`np.object` is a deprecated alias:DeprecationWarning"
)


class TestHDFStoreSubclass:
Expand Down
1 change: 0 additions & 1 deletion pandas/tests/io/sas/test_sas7bdat.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ def data_test_ix(request, dirpath):


# https://github.com/cython/cython/issues/1720
@pytest.mark.filterwarnings("ignore:can't resolve package:ImportWarning")
class TestSAS7BDAT:
@pytest.mark.slow
def test_from_file(self, dirpath, data_test_ix):
Expand Down
7 changes: 0 additions & 7 deletions pandas/tests/io/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def __fspath__(self):


# https://github.com/cython/cython/issues/1720
@pytest.mark.filterwarnings("ignore:can't resolve package:ImportWarning")
class TestCommonIOCapabilities:
data1 = """index,A,B,C,D
foo,2,3,4,5
Expand Down Expand Up @@ -317,9 +316,6 @@ def test_read_expands_user_home_dir(
),
],
)
@pytest.mark.filterwarnings( # pytables np.object_ usage
"ignore:`np.object` is a deprecated alias:DeprecationWarning"
)
def test_read_fspath_all(self, reader, module, path, datapath):
pytest.importorskip(module)
path = datapath(*path)
Expand Down Expand Up @@ -372,9 +368,6 @@ def test_write_fspath_all(self, writer_name, writer_kwargs, module):
expected = f_path.read()
assert result == expected

@pytest.mark.filterwarnings( # pytables np.object_ usage
"ignore:`np.object` is a deprecated alias:DeprecationWarning"
)
def test_write_fspath_hdf5(self):
# Same test as write_fspath_all, except HDF5 files aren't
# necessarily byte-for-byte identical for a given dataframe, so we'll
Expand Down
13 changes: 2 additions & 11 deletions pandas/tests/io/test_parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
from io import BytesIO
import os
import pathlib
from warnings import (
catch_warnings,
filterwarnings,
)
from warnings import catch_warnings

import numpy as np
import pytest
Expand Down Expand Up @@ -40,13 +37,7 @@
_HAVE_PYARROW = False

try:
with catch_warnings():
# `np.bool` is a deprecated alias...
filterwarnings("ignore", "`np.bool`", category=DeprecationWarning)
# accessing pd.Int64Index in pd namespace
filterwarnings("ignore", ".*Int64Index.*", category=FutureWarning)

import fastparquet
import fastparquet

_HAVE_FASTPARQUET = True
except ImportError:
Expand Down
88 changes: 41 additions & 47 deletions pandas/tests/io/test_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@
import shutil
import tarfile
import uuid
from warnings import (
catch_warnings,
simplefilter,
)
from warnings import catch_warnings
import zipfile

import numpy as np
Expand Down Expand Up @@ -132,49 +129,46 @@ def test_pickles(legacy_pickle):
if not is_platform_little_endian():
pytest.skip("known failure on non-little endian")

with catch_warnings(record=True):
simplefilter("ignore")

data = pd.read_pickle(legacy_pickle)

for typ, dv in data.items():
for dt, result in dv.items():
expected = data[typ][dt]

if typ == "series" and dt == "ts":
# GH 7748
tm.assert_series_equal(result, expected)
assert result.index.freq == expected.index.freq
assert not result.index.freq.normalize
tm.assert_series_equal(result > 0, expected > 0)

# GH 9291
freq = result.index.freq
assert freq + Day(1) == Day(2)

res = freq + pd.Timedelta(hours=1)
assert isinstance(res, pd.Timedelta)
assert res == pd.Timedelta(days=1, hours=1)

res = freq + pd.Timedelta(nanoseconds=1)
assert isinstance(res, pd.Timedelta)
assert res == pd.Timedelta(days=1, nanoseconds=1)
elif typ == "index" and dt == "period":
tm.assert_index_equal(result, expected)
assert isinstance(result.freq, MonthEnd)
assert result.freq == MonthEnd()
assert result.freqstr == "M"
tm.assert_index_equal(result.shift(2), expected.shift(2))
elif typ == "series" and dt in ("dt_tz", "cat"):
tm.assert_series_equal(result, expected)
elif typ == "frame" and dt in (
"dt_mixed_tzs",
"cat_onecol",
"cat_and_float",
):
tm.assert_frame_equal(result, expected)
else:
compare_element(result, expected, typ)
data = pd.read_pickle(legacy_pickle)

for typ, dv in data.items():
for dt, result in dv.items():
expected = data[typ][dt]

if typ == "series" and dt == "ts":
# GH 7748
tm.assert_series_equal(result, expected)
assert result.index.freq == expected.index.freq
assert not result.index.freq.normalize
tm.assert_series_equal(result > 0, expected > 0)

# GH 9291
freq = result.index.freq
assert freq + Day(1) == Day(2)

res = freq + pd.Timedelta(hours=1)
assert isinstance(res, pd.Timedelta)
assert res == pd.Timedelta(days=1, hours=1)

res = freq + pd.Timedelta(nanoseconds=1)
assert isinstance(res, pd.Timedelta)
assert res == pd.Timedelta(days=1, nanoseconds=1)
elif typ == "index" and dt == "period":
tm.assert_index_equal(result, expected)
assert isinstance(result.freq, MonthEnd)
assert result.freq == MonthEnd()
assert result.freqstr == "M"
tm.assert_index_equal(result.shift(2), expected.shift(2))
elif typ == "series" and dt in ("dt_tz", "cat"):
tm.assert_series_equal(result, expected)
elif typ == "frame" and dt in (
"dt_mixed_tzs",
"cat_onecol",
"cat_and_float",
):
tm.assert_frame_equal(result, expected)
else:
compare_element(result, expected, typ)


def python_pickler(obj, path):
Expand Down
21 changes: 5 additions & 16 deletions pandas/tests/plotting/frame/test_frame_color.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
""" Test cases for DataFrame.plot """
import re
import warnings

import numpy as np
import pytest
Expand All @@ -18,23 +17,13 @@

@td.skip_if_no_mpl
class TestDataFrameColor(TestPlotBase):
def test_mpl2_color_cycle_str(self):
@pytest.mark.parametrize(
"color", ["C0", "C1", "C2", "C3", "C4", "C5", "C6", "C7", "C8", "C9"]
)
def test_mpl2_color_cycle_str(self, color):
# GH 15516
df = DataFrame(np.random.randn(10, 3), columns=["a", "b", "c"])
colors = ["C0", "C1", "C2", "C3", "C4", "C5", "C6", "C7", "C8", "C9"]
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always", "MatplotlibDeprecationWarning")

for color in colors:
_check_plot_works(df.plot, color=color)

# if warning is raised, check that it is the exact problematic one
# GH 36972
if w:
match = "Support for uppercase single-letter colors is deprecated"
warning_message = str(w[0].message)
msg = "MatplotlibDeprecationWarning related to CN colors was raised"
assert match not in warning_message, msg
_check_plot_works(df.plot, color=color)

def test_color_single_series_list(self):
# GH 3486
Expand Down
17 changes: 0 additions & 17 deletions pandas/tests/test_downstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@
)
import pandas._testing as tm

# xarray, fsspec, fastparquet all produce these
pytestmark = pytest.mark.filterwarnings(
"ignore:distutils Version classes are deprecated.*:DeprecationWarning"
)


def import_module(name):
# we *only* want to skip if the module is truly not available
Expand Down Expand Up @@ -148,12 +143,6 @@ def test_oo_optimized_datetime_index_unpickle():

@pytest.mark.network
@tm.network
# Cython import warning
@pytest.mark.filterwarnings("ignore:can't:ImportWarning")
@pytest.mark.filterwarnings(
# patsy needs to update their imports
"ignore:Using or importing the ABCs from 'collections:DeprecationWarning"
)
def test_statsmodels():

statsmodels = import_module("statsmodels") # noqa:F841
Expand All @@ -164,8 +153,6 @@ def test_statsmodels():
smf.ols("Lottery ~ Literacy + np.log(Pop1831)", data=df).fit()


# Cython import warning
@pytest.mark.filterwarnings("ignore:can't:ImportWarning")
def test_scikit_learn():

sklearn = import_module("sklearn") # noqa:F841
Expand All @@ -180,10 +167,8 @@ def test_scikit_learn():
clf.predict(digits.data[-1:])


# Cython import warning and traitlets
@pytest.mark.network
@tm.network
@pytest.mark.filterwarnings("ignore")
def test_seaborn():

seaborn = import_module("seaborn")
Expand All @@ -210,8 +195,6 @@ def test_pandas_datareader():
pandas_datareader.DataReader("F", "quandl", "2017-01-01", "2017-02-01")


# Cython import warning
@pytest.mark.filterwarnings("ignore:can't resolve:ImportWarning")
def test_pyarrow(df):

pyarrow = import_module("pyarrow")
Expand Down
15 changes: 0 additions & 15 deletions pandas/tests/util/test_show_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import os
import re

import pytest

from pandas.util._print_versions import (
_get_dependency_info,
_get_sys_info,
Expand All @@ -12,19 +10,6 @@
import pandas as pd


@pytest.mark.filterwarnings(
# openpyxl
"ignore:defusedxml.lxml is no longer supported:DeprecationWarning"
)
@pytest.mark.filterwarnings(
# html5lib
"ignore:Using or importing the ABCs from:DeprecationWarning"
)
@pytest.mark.filterwarnings(
# https://github.com/pandas-dev/pandas/issues/35252
"ignore:Distutils:UserWarning"
)
@pytest.mark.filterwarnings("ignore:Setuptools is replacing distutils:UserWarning")
def test_show_versions(tmpdir):
# GH39701
as_json = os.path.join(tmpdir, "test_output.json")
Expand Down
8 changes: 0 additions & 8 deletions pandas/tests/window/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +0,0 @@
import pytest

pytestmark = [
# 2021-02-01 needed until numba updates their usage
pytest.mark.filterwarnings(
r"ignore:`np\.int` is a deprecated alias:DeprecationWarning"
),
]
Loading