Skip to content

Commit c49733c

Browse files
authored
CI: Enable pytest -W:::pandas on some builds (#50354)
1 parent 50f19b6 commit c49733c

File tree

9 files changed

+33
-11
lines changed

9 files changed

+33
-11
lines changed

.github/workflows/macos-windows.yml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ env:
1616
PANDAS_CI: 1
1717
PYTEST_TARGET: pandas
1818
PATTERN: "not slow and not db and not network and not single_cpu"
19+
TEST_ARGS: "-W error:::pandas"
1920

2021

2122
permissions:

.github/workflows/ubuntu.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ jobs:
3838
- name: "Minimum Versions"
3939
env_file: actions-38-minimum_versions.yaml
4040
pattern: "not slow and not network and not single_cpu"
41+
test_args: ""
4142
- name: "Locale: it_IT"
4243
env_file: actions-38.yaml
4344
pattern: "not slow and not network and not single_cpu"
@@ -62,10 +63,12 @@ jobs:
6263
env_file: actions-310.yaml
6364
pattern: "not slow and not network and not single_cpu"
6465
pandas_copy_on_write: "1"
66+
test_args: ""
6567
- name: "Data Manager"
6668
env_file: actions-38.yaml
6769
pattern: "not slow and not network and not single_cpu"
6870
pandas_data_manager: "array"
71+
test_args: ""
6972
- name: "Pypy"
7073
env_file: actions-pypy-38.yaml
7174
pattern: "not slow and not network and not single_cpu"
@@ -93,7 +96,7 @@ jobs:
9396
LC_ALL: ${{ matrix.lc_all || '' }}
9497
PANDAS_DATA_MANAGER: ${{ matrix.pandas_data_manager || 'block' }}
9598
PANDAS_COPY_ON_WRITE: ${{ matrix.pandas_copy_on_write || '0' }}
96-
TEST_ARGS: ${{ matrix.test_args || '' }}
99+
TEST_ARGS: ${{ matrix.test_args || '-W error:::pandas' }}
97100
PYTEST_WORKERS: ${{ contains(matrix.pattern, 'not single_cpu') && 'auto' || '1' }}
98101
PYTEST_TARGET: ${{ matrix.pytest_target || 'pandas' }}
99102
IS_PYPY: ${{ contains(matrix.env_file, 'pypy') }}

pandas/_libs/tslibs/timedeltas.pyx

+15-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import collections
2+
import warnings
23

34
cimport cython
45
from cpython.object cimport (
@@ -1947,9 +1948,13 @@ class Timedelta(_Timedelta):
19471948

19481949
if other.dtype.kind == "m":
19491950
# also timedelta-like
1950-
# TODO: could suppress
1951-
# RuntimeWarning: invalid value encountered in floor_divide
1952-
result = self.asm8 // other
1951+
with warnings.catch_warnings():
1952+
warnings.filterwarnings(
1953+
"ignore",
1954+
"invalid value encountered in floor_divide",
1955+
RuntimeWarning
1956+
)
1957+
result = self.asm8 // other
19531958
mask = other.view("i8") == NPY_NAT
19541959
if mask.any():
19551960
# We differ from numpy here
@@ -1987,9 +1992,13 @@ class Timedelta(_Timedelta):
19871992

19881993
if other.dtype.kind == "m":
19891994
# also timedelta-like
1990-
# TODO: could suppress
1991-
# RuntimeWarning: invalid value encountered in floor_divide
1992-
result = other // self.asm8
1995+
with warnings.catch_warnings():
1996+
warnings.filterwarnings(
1997+
"ignore",
1998+
"invalid value encountered in floor_divide",
1999+
RuntimeWarning
2000+
)
2001+
result = other // self.asm8
19932002
mask = other.view("i8") == NPY_NAT
19942003
if mask.any():
19952004
# We differ from numpy here

pandas/core/arrays/masked.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -727,12 +727,13 @@ def _cmp_method(self, other, op) -> BooleanArray:
727727
mask = np.ones(self._data.shape, dtype="bool")
728728
else:
729729
with warnings.catch_warnings():
730-
# numpy may show a FutureWarning:
730+
# numpy may show a FutureWarning or DeprecationWarning:
731731
# elementwise comparison failed; returning scalar instead,
732732
# but in the future will perform elementwise comparison
733733
# before returning NotImplemented. We fall back to the correct
734734
# behavior today, so that should be fine to ignore.
735735
warnings.filterwarnings("ignore", "elementwise", FutureWarning)
736+
warnings.filterwarnings("ignore", "elementwise", DeprecationWarning)
736737
with np.errstate(all="ignore"):
737738
method = getattr(self._data, f"__{op.__name__}__")
738739
result = method(other)

pandas/tests/frame/indexing/test_indexing.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from pandas._libs import iNaT
1212
from pandas.errors import (
1313
InvalidIndexError,
14+
PerformanceWarning,
1415
SettingWithCopyError,
1516
)
1617
import pandas.util._test_decorators as td
@@ -1471,7 +1472,8 @@ def test_loc_bool_multiindex(self, dtype, indexer):
14711472
names=["a", "b"],
14721473
)
14731474
df = DataFrame({"c": [1, 2, 3, 4]}, index=midx)
1474-
result = df.loc[indexer]
1475+
with tm.maybe_produces_warning(PerformanceWarning, isinstance(indexer, tuple)):
1476+
result = df.loc[indexer]
14751477
expected = DataFrame(
14761478
{"c": [1, 2]}, index=Index([True, False], name="b", dtype=dtype)
14771479
)

pandas/tests/indexes/datetimes/methods/test_astype.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def test_astype(self):
3232
)
3333
tm.assert_index_equal(result, expected)
3434

35-
result = idx.astype(int)
35+
result = idx.astype(np.int64)
3636
expected = Int64Index(
3737
[1463356800000000000] + [-9223372036854775808] * 3,
3838
dtype=np.int64,

pandas/tests/io/parser/test_parse_dates.py

+2
Original file line numberDiff line numberDiff line change
@@ -1453,6 +1453,8 @@ def test_parse_date_time(all_parsers, data, kwargs, expected):
14531453

14541454

14551455
@xfail_pyarrow
1456+
# From date_parser fallback behavior
1457+
@pytest.mark.filterwarnings("ignore:elementwise comparison:FutureWarning")
14561458
def test_parse_date_fields(all_parsers):
14571459
parser = all_parsers
14581460
data = "year,month,day,a\n2001,01,10,10.\n2001,02,1,11."

pandas/tests/io/pytables/test_round_trip.py

+1
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ def test_table_values_dtypes_roundtrip(setup_path):
259259
tm.assert_series_equal(result, expected)
260260

261261

262+
@pytest.mark.filterwarnings("ignore::pandas.errors.PerformanceWarning")
262263
def test_series(setup_path):
263264

264265
s = tm.makeStringSeries()

pandas/tests/tslibs/test_parsing.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,10 @@ def test_parsers_month_freq(date_str, expected):
182182
],
183183
)
184184
def test_guess_datetime_format_with_parseable_formats(string, fmt):
185-
result = parsing.guess_datetime_format(string)
185+
with tm.maybe_produces_warning(
186+
UserWarning, fmt is not None and re.search(r"%d.*%m", fmt)
187+
):
188+
result = parsing.guess_datetime_format(string)
186189
assert result == fmt
187190

188191

0 commit comments

Comments
 (0)