Skip to content

CI: Enable pytest -W:::pandas on some builds #50354

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 2 commits into from
Dec 21, 2022
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
1 change: 1 addition & 0 deletions .github/workflows/macos-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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') }}
Expand Down
21 changes: 15 additions & 6 deletions pandas/_libs/tslibs/timedeltas.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import collections
import warnings

cimport cython
from cpython.object cimport (
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion pandas/core/arrays/masked.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion pandas/tests/frame/indexing/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from pandas._libs import iNaT
from pandas.errors import (
InvalidIndexError,
PerformanceWarning,
SettingWithCopyError,
)
import pandas.util._test_decorators as td
Expand Down Expand Up @@ -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)
)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/datetimes/methods/test_astype.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions pandas/tests/io/parser/test_parse_dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
1 change: 1 addition & 0 deletions pandas/tests/io/pytables/test_round_trip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 4 additions & 1 deletion pandas/tests/tslibs/test_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down