diff --git a/.github/workflows/macos-windows.yml b/.github/workflows/macos-windows.yml index 81c798c9d86c3..ca6fd63d749ee 100644 --- a/.github/workflows/macos-windows.yml +++ b/.github/workflows/macos-windows.yml @@ -16,6 +16,7 @@ env: PANDAS_CI: 1 PYTEST_TARGET: pandas PATTERN: "not slow and not db and not network and not single_cpu" + TEST_ARGS: "-W error:::pandas" permissions: diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 7b4d9235f7ee1..007de6385dd69 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -38,6 +38,7 @@ jobs: - name: "Minimum Versions" env_file: actions-38-minimum_versions.yaml pattern: "not slow and not network and not single_cpu" + test_args: "" - name: "Locale: it_IT" env_file: actions-38.yaml pattern: "not slow and not network and not single_cpu" @@ -62,10 +63,12 @@ jobs: env_file: actions-310.yaml pattern: "not slow and not network and not single_cpu" pandas_copy_on_write: "1" + test_args: "" - name: "Data Manager" env_file: actions-38.yaml pattern: "not slow and not network and not single_cpu" pandas_data_manager: "array" + test_args: "" - name: "Pypy" env_file: actions-pypy-38.yaml pattern: "not slow and not network and not single_cpu" @@ -93,7 +96,7 @@ jobs: LC_ALL: ${{ matrix.lc_all || '' }} PANDAS_DATA_MANAGER: ${{ matrix.pandas_data_manager || 'block' }} PANDAS_COPY_ON_WRITE: ${{ matrix.pandas_copy_on_write || '0' }} - TEST_ARGS: ${{ matrix.test_args || '' }} + TEST_ARGS: ${{ matrix.test_args || '-W error:::pandas' }} PYTEST_WORKERS: ${{ contains(matrix.pattern, 'not single_cpu') && 'auto' || '1' }} PYTEST_TARGET: ${{ matrix.pytest_target || 'pandas' }} IS_PYPY: ${{ contains(matrix.env_file, 'pypy') }} diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index 9284980ac2f65..7810bc9f75e66 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1,4 +1,5 @@ import collections +import warnings cimport cython from cpython.object cimport ( @@ -1947,9 +1948,13 @@ class Timedelta(_Timedelta): if other.dtype.kind == "m": # also timedelta-like - # TODO: could suppress - # RuntimeWarning: invalid value encountered in floor_divide - result = self.asm8 // other + with warnings.catch_warnings(): + warnings.filterwarnings( + "ignore", + "invalid value encountered in floor_divide", + RuntimeWarning + ) + result = self.asm8 // other mask = other.view("i8") == NPY_NAT if mask.any(): # We differ from numpy here @@ -1987,9 +1992,13 @@ class Timedelta(_Timedelta): if other.dtype.kind == "m": # also timedelta-like - # TODO: could suppress - # RuntimeWarning: invalid value encountered in floor_divide - result = other // self.asm8 + with warnings.catch_warnings(): + warnings.filterwarnings( + "ignore", + "invalid value encountered in floor_divide", + RuntimeWarning + ) + result = other // self.asm8 mask = other.view("i8") == NPY_NAT if mask.any(): # We differ from numpy here diff --git a/pandas/core/arrays/masked.py b/pandas/core/arrays/masked.py index 198a6d6e285be..b3e4afc70a8fd 100644 --- a/pandas/core/arrays/masked.py +++ b/pandas/core/arrays/masked.py @@ -727,12 +727,13 @@ def _cmp_method(self, other, op) -> BooleanArray: mask = np.ones(self._data.shape, dtype="bool") else: with warnings.catch_warnings(): - # numpy may show a FutureWarning: + # numpy may show a FutureWarning or DeprecationWarning: # elementwise comparison failed; returning scalar instead, # but in the future will perform elementwise comparison # before returning NotImplemented. We fall back to the correct # behavior today, so that should be fine to ignore. warnings.filterwarnings("ignore", "elementwise", FutureWarning) + warnings.filterwarnings("ignore", "elementwise", DeprecationWarning) with np.errstate(all="ignore"): method = getattr(self._data, f"__{op.__name__}__") result = method(other) diff --git a/pandas/tests/frame/indexing/test_indexing.py b/pandas/tests/frame/indexing/test_indexing.py index 5ce8800de1f67..86f7c59b961b5 100644 --- a/pandas/tests/frame/indexing/test_indexing.py +++ b/pandas/tests/frame/indexing/test_indexing.py @@ -11,6 +11,7 @@ from pandas._libs import iNaT from pandas.errors import ( InvalidIndexError, + PerformanceWarning, SettingWithCopyError, ) import pandas.util._test_decorators as td @@ -1471,7 +1472,8 @@ def test_loc_bool_multiindex(self, dtype, indexer): names=["a", "b"], ) df = DataFrame({"c": [1, 2, 3, 4]}, index=midx) - result = df.loc[indexer] + with tm.maybe_produces_warning(PerformanceWarning, isinstance(indexer, tuple)): + result = df.loc[indexer] expected = DataFrame( {"c": [1, 2]}, index=Index([True, False], name="b", dtype=dtype) ) diff --git a/pandas/tests/indexes/datetimes/methods/test_astype.py b/pandas/tests/indexes/datetimes/methods/test_astype.py index ccbfd9217373b..6e14570795095 100644 --- a/pandas/tests/indexes/datetimes/methods/test_astype.py +++ b/pandas/tests/indexes/datetimes/methods/test_astype.py @@ -32,7 +32,7 @@ def test_astype(self): ) tm.assert_index_equal(result, expected) - result = idx.astype(int) + result = idx.astype(np.int64) expected = Int64Index( [1463356800000000000] + [-9223372036854775808] * 3, dtype=np.int64, diff --git a/pandas/tests/io/parser/test_parse_dates.py b/pandas/tests/io/parser/test_parse_dates.py index c366613c2815f..b24c4830a7d31 100644 --- a/pandas/tests/io/parser/test_parse_dates.py +++ b/pandas/tests/io/parser/test_parse_dates.py @@ -1454,6 +1454,8 @@ def test_parse_date_time(all_parsers, data, kwargs, expected): @xfail_pyarrow +# From date_parser fallback behavior +@pytest.mark.filterwarnings("ignore:elementwise comparison:FutureWarning") def test_parse_date_fields(all_parsers): parser = all_parsers data = "year,month,day,a\n2001,01,10,10.\n2001,02,1,11." diff --git a/pandas/tests/io/pytables/test_round_trip.py b/pandas/tests/io/pytables/test_round_trip.py index e76f85c0c69d0..53be06cd491ef 100644 --- a/pandas/tests/io/pytables/test_round_trip.py +++ b/pandas/tests/io/pytables/test_round_trip.py @@ -259,6 +259,7 @@ def test_table_values_dtypes_roundtrip(setup_path): tm.assert_series_equal(result, expected) +@pytest.mark.filterwarnings("ignore::pandas.errors.PerformanceWarning") def test_series(setup_path): s = tm.makeStringSeries() diff --git a/pandas/tests/tslibs/test_parsing.py b/pandas/tests/tslibs/test_parsing.py index a4c79e77d2eed..f4f95123aff66 100644 --- a/pandas/tests/tslibs/test_parsing.py +++ b/pandas/tests/tslibs/test_parsing.py @@ -182,7 +182,10 @@ def test_parsers_month_freq(date_str, expected): ], ) def test_guess_datetime_format_with_parseable_formats(string, fmt): - result = parsing.guess_datetime_format(string) + with tm.maybe_produces_warning( + UserWarning, fmt is not None and re.search(r"%d.*%m", fmt) + ): + result = parsing.guess_datetime_format(string) assert result == fmt