From 568c2583c754b18dd98ab242c7eb570ecb1c06f3 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Fri, 10 Feb 2023 11:31:17 -0800 Subject: [PATCH 01/16] CI/TST: Enable -W error:::pandas in pyproject.toml --- .github/workflows/macos-windows.yml | 2 -- .github/workflows/ubuntu.yml | 5 ----- ci/run_tests.sh | 7 ------- pandas/tests/frame/test_query_eval.py | 2 +- pandas/tests/series/test_arithmetic.py | 9 ++++++--- pyproject.toml | 1 + 6 files changed, 8 insertions(+), 18 deletions(-) diff --git a/.github/workflows/macos-windows.yml b/.github/workflows/macos-windows.yml index ac5fd4aa7d4a4..bc3512a6f512b 100644 --- a/.github/workflows/macos-windows.yml +++ b/.github/workflows/macos-windows.yml @@ -16,8 +16,6 @@ env: PANDAS_CI: 1 PYTEST_TARGET: pandas PATTERN: "not slow and not db and not network and not single_cpu" - ERROR_ON_WARNINGS: "1" - permissions: contents: read diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index cb07c67dda2df..12632264bc3b1 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -38,7 +38,6 @@ jobs: - name: "Minimum Versions" env_file: actions-38-minimum_versions.yaml pattern: "not slow and not network and not single_cpu" - error_on_warnings: "0" - name: "Locale: it_IT" env_file: actions-38.yaml pattern: "not slow and not network and not single_cpu" @@ -63,12 +62,10 @@ jobs: env_file: actions-310.yaml pattern: "not slow and not network and not single_cpu" pandas_copy_on_write: "1" - error_on_warnings: "0" - name: "Data Manager" env_file: actions-38.yaml pattern: "not slow and not network and not single_cpu" pandas_data_manager: "array" - error_on_warnings: "0" - name: "Pypy" env_file: actions-pypy-38.yaml pattern: "not slow and not network and not single_cpu" @@ -77,7 +74,6 @@ jobs: env_file: actions-310-numpydev.yaml pattern: "not slow and not network and not single_cpu" test_args: "-W error::DeprecationWarning -W error::FutureWarning" - error_on_warnings: "0" exclude: - env_file: actions-38.yaml pyarrow_version: "8" @@ -97,7 +93,6 @@ jobs: ENV_FILE: ci/deps/${{ matrix.env_file }} PATTERN: ${{ matrix.pattern }} EXTRA_APT: ${{ matrix.extra_apt || '' }} - ERROR_ON_WARNINGS: ${{ matrix.error_on_warnings || '1' }} LANG: ${{ matrix.lang || '' }} LC_ALL: ${{ matrix.lc_all || '' }} PANDAS_DATA_MANAGER: ${{ matrix.pandas_data_manager || 'block' }} diff --git a/ci/run_tests.sh b/ci/run_tests.sh index a48d6c1ad6580..e6de5caf955fc 100755 --- a/ci/run_tests.sh +++ b/ci/run_tests.sh @@ -30,13 +30,6 @@ if [[ "$PATTERN" ]]; then PYTEST_CMD="$PYTEST_CMD -m \"$PATTERN\"" fi -if [[ "$ERROR_ON_WARNINGS" == "1" ]]; then - for pth in $(find pandas -name '*.py' -not -path "pandas/tests/*" | sed -e 's/\.py//g' -e 's/\/__init__//g' -e 's/\//./g'); - do - PYTEST_CMD="$PYTEST_CMD -W error:::$pth" - done -fi - echo $PYTEST_CMD sh -c "$PYTEST_CMD" diff --git a/pandas/tests/frame/test_query_eval.py b/pandas/tests/frame/test_query_eval.py index c815b897e6a14..a22171354ff5e 100644 --- a/pandas/tests/frame/test_query_eval.py +++ b/pandas/tests/frame/test_query_eval.py @@ -1343,7 +1343,7 @@ def test_query_ea_dtypes(self, dtype): # GH#50261 df = DataFrame({"a": Series([1, 2], dtype=dtype)}) ref = {2} # noqa:F841 - result = df.query("a in @ref") + result = df.query("a in @ref", engine="python") expected = DataFrame({"a": Series([2], dtype=dtype, index=[1])}) tm.assert_frame_equal(result, expected) diff --git a/pandas/tests/series/test_arithmetic.py b/pandas/tests/series/test_arithmetic.py index 08fdad5ff1edd..90dbb0650bea0 100644 --- a/pandas/tests/series/test_arithmetic.py +++ b/pandas/tests/series/test_arithmetic.py @@ -350,14 +350,17 @@ def test_add_list_to_masked_array(self, val, dtype): result = [1, None, val] + ser tm.assert_series_equal(result, expected) - def test_add_list_to_masked_array_boolean(self): + def test_add_list_to_masked_array_boolean(self, request): # GH#22962 + min_elements = request.getfixturevalue("switch_numexpr_min_elements") ser = Series([True, None, False], dtype="boolean") - result = ser + [True, None, True] + with tm.maybe_produces_warning(UserWarning, min_elements == 0): + result = ser + [True, None, True] expected = Series([True, None, True], dtype="boolean") tm.assert_series_equal(result, expected) - result = [True, None, True] + ser + with tm.maybe_produces_warning(UserWarning, min_elements == 0): + result = [True, None, True] + ser tm.assert_series_equal(result, expected) diff --git a/pyproject.toml b/pyproject.toml index f4998fbe82722..b660cb6620070 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -373,6 +373,7 @@ doctest_optionflags = [ "ELLIPSIS", ] filterwarnings = [ + "error:::pandas", # Will be fixed in numba 0.56: https://github.com/numba/numba/issues/7758 "ignore:`np.MachAr` is deprecated:DeprecationWarning:numba", "ignore:.*urllib3:DeprecationWarning:botocore", From 294d937310c0a60024b0aa94a1d78b26d3b48ab2 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Fri, 10 Feb 2023 21:24:04 -0800 Subject: [PATCH 02/16] Address some tests --- .../io/pytables/test_retain_attributes.py | 9 ++++----- pandas/tests/tseries/offsets/test_offsets.py | 20 ++++++++++++++++--- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/pandas/tests/io/pytables/test_retain_attributes.py b/pandas/tests/io/pytables/test_retain_attributes.py index 3043cd3604e58..932c605a2f145 100644 --- a/pandas/tests/io/pytables/test_retain_attributes.py +++ b/pandas/tests/io/pytables/test_retain_attributes.py @@ -1,5 +1,3 @@ -from warnings import catch_warnings - import pytest from pandas._libs.tslibs import Timestamp @@ -9,6 +7,7 @@ Series, _testing as tm, date_range, + errors, read_hdf, ) from pandas.tests.io.pytables.common import ( @@ -40,7 +39,7 @@ def test_retain_index_attributes(setup_path): ) # try to append a table with a different frequency - with catch_warnings(record=True): + with tm.assert_produces_warning(errors.AttributeConflictWarning): df2 = DataFrame( { "A": Series( @@ -76,7 +75,7 @@ def test_retain_index_attributes(setup_path): def test_retain_index_attributes2(tmp_path, setup_path): path = tmp_path / setup_path - with catch_warnings(record=True): + with tm.assert_produces_warning(errors.AttributeConflictWarning): df = DataFrame( {"A": Series(range(3), index=date_range("2000-1-1", periods=3, freq="H"))} @@ -95,7 +94,7 @@ def test_retain_index_attributes2(tmp_path, setup_path): assert read_hdf(path, "data").index.name == "foo" - with catch_warnings(record=True): + with tm.assert_produces_warning(errors.AttributeConflictWarning): idx2 = date_range("2001-1-1", periods=3, freq="H") idx2.name = "bar" diff --git a/pandas/tests/tseries/offsets/test_offsets.py b/pandas/tests/tseries/offsets/test_offsets.py index 933723edd6e66..93c157f51ddd9 100644 --- a/pandas/tests/tseries/offsets/test_offsets.py +++ b/pandas/tests/tseries/offsets/test_offsets.py @@ -12,7 +12,6 @@ List, Tuple, ) -import warnings import numpy as np import pytest @@ -576,7 +575,22 @@ def test_add_dt64_ndarray_non_nano(self, offset_types, unit, request): arr = dti._data._ndarray.astype(f"M8[{unit}]") dta = type(dti._data)._simple_new(arr, dtype=arr.dtype) - with warnings.catch_warnings(record=True) as w: + performance_warns = isinstance( + off, + ( + CustomBusinessDay, + BusinessHour, + CustomBusinessHour, + LastWeekOfMonth, + FY5253, + FY5253Quarter, + WeekOfMonth, + Easter, + CustomBusinessMonthBegin, + CustomBusinessMonthEnd, + ), + ) + with tm.maybe_produces_warning(PerformanceWarning, performance_warns) as w: expected = dti._data + off result = dta + off @@ -586,7 +600,7 @@ def test_add_dt64_ndarray_non_nano(self, offset_types, unit, request): exp_unit = Timedelta(off).unit expected = expected.as_unit(exp_unit) - if len(w): + if w is not None and len(w): # PerformanceWarning was issued bc _apply_array raised, so we # fell back to object dtype, for which the code path does # not yet cast back to the original resolution From acfd1f5c28af34e12be4d7b68e1e362120c5f244 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Mon, 13 Feb 2023 13:11:50 -0800 Subject: [PATCH 03/16] filter more expected warnings in tests --- pandas/tests/groupby/test_groupby.py | 3 +++ pandas/tests/groupby/test_nth.py | 3 +++ pandas/tests/io/sas/test_byteswap.py | 1 + pandas/tests/test_expressions.py | 3 +++ 4 files changed, 10 insertions(+) diff --git a/pandas/tests/groupby/test_groupby.py b/pandas/tests/groupby/test_groupby.py index a0b129b65d293..a873800d9bce7 100644 --- a/pandas/tests/groupby/test_groupby.py +++ b/pandas/tests/groupby/test_groupby.py @@ -2781,6 +2781,9 @@ def test_sum_of_booleans(n): tm.assert_frame_equal(result, expected) +@pytest.mark.filterwarnings( + "ignore:invalid value encountered in remainder:RuntimeWarning" +) @pytest.mark.parametrize("method", ["head", "tail", "nth", "first", "last"]) def test_groupby_method_drop_na(method): # GH 21755 diff --git a/pandas/tests/groupby/test_nth.py b/pandas/tests/groupby/test_nth.py index 77422c28d356f..aba95d34b43c7 100644 --- a/pandas/tests/groupby/test_nth.py +++ b/pandas/tests/groupby/test_nth.py @@ -790,6 +790,9 @@ def test_nth_slices_with_column_axis( tm.assert_frame_equal(result, expected) +@pytest.mark.filterwarnings( + "ignore:invalid value encountered in remainder:RuntimeWarning" +) def test_head_tail_dropna_true(): # GH#45089 df = DataFrame( diff --git a/pandas/tests/io/sas/test_byteswap.py b/pandas/tests/io/sas/test_byteswap.py index 2c88907df3b1d..0ef4eeb54beb3 100644 --- a/pandas/tests/io/sas/test_byteswap.py +++ b/pandas/tests/io/sas/test_byteswap.py @@ -29,6 +29,7 @@ def test_int_byteswap(read_offset, number, int_type, should_byteswap): _test(number, int_type, read_offset, should_byteswap) +@pytest.mark.filterwarnings("ignore:overflow encountered:RuntimeWarning") @given(read_offset=st.integers(0, 11), number=st.floats()) @pytest.mark.parametrize("float_type", [np.float32, np.float64]) @pytest.mark.parametrize("should_byteswap", [True, False]) diff --git a/pandas/tests/test_expressions.py b/pandas/tests/test_expressions.py index a627f3172f0c6..1146942baa8e7 100644 --- a/pandas/tests/test_expressions.py +++ b/pandas/tests/test_expressions.py @@ -199,6 +199,9 @@ def test_invalid(self): result = expr._can_use_numexpr(operator.add, "+", array, array2, "evaluate") assert result + @pytest.mark.filterwarnings( + "ignore:invalid value encountered in true_divide:RuntimeWarning" + ) @pytest.mark.parametrize( "opname,op_str", [("add", "+"), ("sub", "-"), ("mul", "*"), ("truediv", "/"), ("pow", "**")], From 4ed4a1196d338db7b82f54965492e731ca7a38cd Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Mon, 13 Feb 2023 13:23:06 -0800 Subject: [PATCH 04/16] Change examples raising warnings --- pandas/core/generic.py | 8 ++++---- pandas/io/sql.py | 8 -------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index d76648558bc6e..ec9169e332f4f 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -4017,10 +4017,10 @@ class animal locomotion Get values at several indexes - >>> df.xs(('mammal', 'dog')) - num_legs num_wings - locomotion - walks 4 0 + >>> df.xs(('mammal', 'dog', 'walks')) + num_legs 4 + num_wings 0 + Name: (mammal, dog, walks), dtype: int64 Get values at specified index and level diff --git a/pandas/io/sql.py b/pandas/io/sql.py index 6764c0578bf7a..f222a329166b3 100644 --- a/pandas/io/sql.py +++ b/pandas/io/sql.py @@ -632,14 +632,6 @@ def read_sql( >>> pd.read_sql('test_data', 'postgres:///db_name') # doctest:+SKIP Apply date parsing to columns through the ``parse_dates`` argument - - >>> pd.read_sql('SELECT int_column, date_column FROM test_data', - ... conn, - ... parse_dates=["date_column"]) - int_column date_column - 0 0 2012-10-11 - 1 1 2010-12-11 - The ``parse_dates`` argument calls ``pd.to_datetime`` on the provided columns. Custom argument values for applying ``pd.to_datetime`` on a column are specified via a dictionary format: From b926b397c6387cbf0a3351e709018f16ccd8d6ec Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Mon, 13 Feb 2023 16:56:14 -0800 Subject: [PATCH 05/16] Just ignore userwarning, not point of the test --- pandas/tests/series/test_arithmetic.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pandas/tests/series/test_arithmetic.py b/pandas/tests/series/test_arithmetic.py index 90dbb0650bea0..504646856db02 100644 --- a/pandas/tests/series/test_arithmetic.py +++ b/pandas/tests/series/test_arithmetic.py @@ -350,17 +350,15 @@ def test_add_list_to_masked_array(self, val, dtype): result = [1, None, val] + ser tm.assert_series_equal(result, expected) - def test_add_list_to_masked_array_boolean(self, request): + @pytest.mark.filterwarnings("ignore:evaluating in Python space:UserWarning") + def test_add_list_to_masked_array_boolean(self): # GH#22962 - min_elements = request.getfixturevalue("switch_numexpr_min_elements") ser = Series([True, None, False], dtype="boolean") - with tm.maybe_produces_warning(UserWarning, min_elements == 0): - result = ser + [True, None, True] + result = ser + [True, None, True] expected = Series([True, None, True], dtype="boolean") tm.assert_series_equal(result, expected) - with tm.maybe_produces_warning(UserWarning, min_elements == 0): - result = [True, None, True] + ser + result = [True, None, True] + ser tm.assert_series_equal(result, expected) From 628bd013bbef2d0600d0a5f3c5fc6e5a0e336c2a Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Mon, 13 Feb 2023 17:09:55 -0800 Subject: [PATCH 06/16] remove a sql date example, ignore open plots --- pandas/io/sql.py | 13 ++----------- pyproject.toml | 2 ++ 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/pandas/io/sql.py b/pandas/io/sql.py index f222a329166b3..780b847d21ff1 100644 --- a/pandas/io/sql.py +++ b/pandas/io/sql.py @@ -635,16 +635,7 @@ def read_sql( The ``parse_dates`` argument calls ``pd.to_datetime`` on the provided columns. Custom argument values for applying ``pd.to_datetime`` on a column are specified via a dictionary format: - 1. Ignore errors while parsing the values of "date_column" - - >>> pd.read_sql('SELECT int_column, date_column FROM test_data', - ... conn, - ... parse_dates={"date_column": {"errors": "ignore"}}) - int_column date_column - 0 0 2012-10-11 - 1 1 2010-12-11 - - 2. Apply a dayfirst date parsing order on the values of "date_column" + 1. Apply a dayfirst date parsing order on the values of "date_column" >>> pd.read_sql('SELECT int_column, date_column FROM test_data', ... conn, @@ -653,7 +644,7 @@ def read_sql( 0 0 2012-11-10 1 1 2010-11-12 - 3. Apply custom formatting when date parsing the values of "date_column" + 2. Apply custom formatting when date parsing the values of "date_column" >>> pd.read_sql('SELECT int_column, date_column FROM test_data', ... conn, diff --git a/pyproject.toml b/pyproject.toml index 215a3ca041182..5d9c83f336813 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -389,6 +389,8 @@ doctest_optionflags = [ ] filterwarnings = [ "error:::pandas", + # From plotting doctests + "ignore:More than 20 figures have been opened:RuntimeWarning:matplotlib", # Will be fixed in numba 0.56: https://github.com/numba/numba/issues/7758 "ignore:`np.MachAr` is deprecated:DeprecationWarning:numba", "ignore:.*urllib3:DeprecationWarning:botocore", From 5e54f1da26a64cd753d263210acbc13400a85164 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Tue, 14 Feb 2023 13:32:38 -0800 Subject: [PATCH 07/16] Just use one example --- pandas/io/sql.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/pandas/io/sql.py b/pandas/io/sql.py index 96d93d45b8dc1..7dedd705f8c70 100644 --- a/pandas/io/sql.py +++ b/pandas/io/sql.py @@ -635,16 +635,6 @@ def read_sql( The ``parse_dates`` argument calls ``pd.to_datetime`` on the provided columns. Custom argument values for applying ``pd.to_datetime`` on a column are specified via a dictionary format: - 1. Apply a dayfirst date parsing order on the values of "date_column" - - >>> pd.read_sql('SELECT int_column, date_column FROM test_data', - ... conn, - ... parse_dates={"date_column": {"dayfirst": True}}) - int_column date_column - 0 0 2012-11-10 - 1 1 2010-11-12 - - 2. Apply custom formatting when date parsing the values of "date_column" >>> pd.read_sql('SELECT int_column, date_column FROM test_data', ... conn, From 27360c10b92d2a889eb74184f726a53bf8140df5 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Tue, 14 Feb 2023 13:34:00 -0800 Subject: [PATCH 08/16] Fix path --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c8cd15ebdc6f8..30f808ec99f35 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -391,7 +391,7 @@ doctest_optionflags = [ filterwarnings = [ "error:::pandas", # From plotting doctests - "ignore:More than 20 figures have been opened:RuntimeWarning:matplotlib", + "ignore:More than 20 figures have been opened:RuntimeWarning", # Will be fixed in numba 0.56: https://github.com/numba/numba/issues/7758 "ignore:`np.MachAr` is deprecated:DeprecationWarning:numba", "ignore:.*urllib3:DeprecationWarning:botocore", From b3ce61079e9efd1b90eab04ec8b86e2c65d49287 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Wed, 15 Feb 2023 18:23:54 -0800 Subject: [PATCH 09/16] Add comment about filtering warning --- pandas/tests/series/test_arithmetic.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/tests/series/test_arithmetic.py b/pandas/tests/series/test_arithmetic.py index 30561eca98688..6be4dc6df8653 100644 --- a/pandas/tests/series/test_arithmetic.py +++ b/pandas/tests/series/test_arithmetic.py @@ -349,6 +349,7 @@ def test_add_list_to_masked_array(self, val, dtype): result = [1, None, val] + ser tm.assert_series_equal(result, expected) + # TODO: Shouldn't the lists be wrapped before being passed to the EA method? @pytest.mark.filterwarnings("ignore:evaluating in Python space:UserWarning") def test_add_list_to_masked_array_boolean(self): # GH#22962 From 705f2302eaf8e0bb3e28ad1bd5b8edc88f2429a4 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Fri, 17 Feb 2023 17:23:18 -0800 Subject: [PATCH 10/16] Filter out expected warning? --- pandas/tests/io/parser/test_parse_dates.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/tests/io/parser/test_parse_dates.py b/pandas/tests/io/parser/test_parse_dates.py index 1106f699b80f8..7d32bf3db039b 100644 --- a/pandas/tests/io/parser/test_parse_dates.py +++ b/pandas/tests/io/parser/test_parse_dates.py @@ -2179,6 +2179,7 @@ def test_parse_dates_dict_format(all_parsers): @skip_pyarrow +@pytest.mark.filterwarnings("ignore:Parsing dates in:UserWarning") @pytest.mark.parametrize( "key, parse_dates", [("a_b", [[0, 1]]), ("foo", {"foo": [0, 1]})] ) From f345e9ab30a7c5bd86c6707a8258c0ca3790b6e5 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Sat, 18 Feb 2023 17:20:55 -0800 Subject: [PATCH 11/16] Remove unneeded filter --- pandas/tests/io/parser/test_parse_dates.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/tests/io/parser/test_parse_dates.py b/pandas/tests/io/parser/test_parse_dates.py index 7d32bf3db039b..1106f699b80f8 100644 --- a/pandas/tests/io/parser/test_parse_dates.py +++ b/pandas/tests/io/parser/test_parse_dates.py @@ -2179,7 +2179,6 @@ def test_parse_dates_dict_format(all_parsers): @skip_pyarrow -@pytest.mark.filterwarnings("ignore:Parsing dates in:UserWarning") @pytest.mark.parametrize( "key, parse_dates", [("a_b", [[0, 1]]), ("foo", {"foo": [0, 1]})] ) From 963625db6d67353602dff309d650cfa25ff9c0a9 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Mon, 20 Feb 2023 17:15:27 -0800 Subject: [PATCH 12/16] Try catching sockerwarning in pyproject toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ef88cab88e360..5204138fcd7ab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -399,7 +399,7 @@ filterwarnings = [ "error::ResourceWarning", "error::pytest.PytestUnraisableExceptionWarning", "ignore:.*ssl.SSLSocket:pytest.PytestUnraisableExceptionWarning", - "ignore:unclosed Date: Mon, 20 Feb 2023 19:23:23 -0800 Subject: [PATCH 13/16] Add back sslsocket filtering --- pandas/_testing/_warnings.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pandas/_testing/_warnings.py b/pandas/_testing/_warnings.py index 0d1076f235b1d..d88285fc20adc 100644 --- a/pandas/_testing/_warnings.py +++ b/pandas/_testing/_warnings.py @@ -163,6 +163,12 @@ def _assert_caught_no_extra_warnings( for actual_warning in caught_warnings: if _is_unexpected_warning(actual_warning, expected_warning): + # GH#38630 pytest.filterwarnings does not suppress these. + if actual_warning.category == ResourceWarning: + # GH 44732: Don't make the CI flaky by filtering SSL-related + # ResourceWarning from dependencies + if "unclosed Date: Mon, 20 Feb 2023 19:27:13 -0800 Subject: [PATCH 14/16] add back matplotlib error too --- pandas/_testing/_warnings.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pandas/_testing/_warnings.py b/pandas/_testing/_warnings.py index d88285fc20adc..201aa81183301 100644 --- a/pandas/_testing/_warnings.py +++ b/pandas/_testing/_warnings.py @@ -5,6 +5,7 @@ nullcontext, ) import re +import sys from typing import ( Generator, Literal, @@ -169,6 +170,11 @@ def _assert_caught_no_extra_warnings( # ResourceWarning from dependencies if "unclosed Date: Wed, 22 Feb 2023 09:14:47 -0800 Subject: [PATCH 15/16] include patrick's changes --- pandas/tests/frame/test_query_eval.py | 5 ++++- pandas/tests/series/test_arithmetic.py | 16 +++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/pandas/tests/frame/test_query_eval.py b/pandas/tests/frame/test_query_eval.py index 0d8183fdcda00..9490e6a9f806f 100644 --- a/pandas/tests/frame/test_query_eval.py +++ b/pandas/tests/frame/test_query_eval.py @@ -1332,7 +1332,10 @@ def test_query_ea_dtypes(self, dtype): # GH#50261 df = DataFrame({"a": Series([1, 2], dtype=dtype)}) ref = {2} # noqa:F841 - result = df.query("a in @ref", engine="python") + result = df.query("a in @ref") + warning = RuntimeWarning if dtype == "Int64" and NUMEXPR_INSTALLED else None + with tm.assert_produces_warning(warning): + result = df.query("a in @ref") expected = DataFrame({"a": Series([2], dtype=dtype, index=[1])}) tm.assert_frame_equal(result, expected) diff --git a/pandas/tests/series/test_arithmetic.py b/pandas/tests/series/test_arithmetic.py index 6be4dc6df8653..fa72bf4368b69 100644 --- a/pandas/tests/series/test_arithmetic.py +++ b/pandas/tests/series/test_arithmetic.py @@ -32,6 +32,7 @@ ops, ) from pandas.core.computation import expressions as expr +from pandas.core.computation.check import NUMEXPR_INSTALLED @pytest.fixture(autouse=True, params=[0, 1000000], ids=["numexpr", "python"]) @@ -349,16 +350,21 @@ def test_add_list_to_masked_array(self, val, dtype): result = [1, None, val] + ser tm.assert_series_equal(result, expected) - # TODO: Shouldn't the lists be wrapped before being passed to the EA method? - @pytest.mark.filterwarnings("ignore:evaluating in Python space:UserWarning") - def test_add_list_to_masked_array_boolean(self): + def test_add_list_to_masked_array_boolean(self, request): # GH#22962 + warning = ( + UserWarning + if request.node.callspec.id == "numexpr" and NUMEXPR_INSTALLED + else None + ) ser = Series([True, None, False], dtype="boolean") - result = ser + [True, None, True] + with tm.assert_produces_warning(warning): + result = ser + [True, None, True] expected = Series([True, None, True], dtype="boolean") tm.assert_series_equal(result, expected) - result = [True, None, True] + ser + with tm.assert_produces_warning(warning): + result = [True, None, True] + ser tm.assert_series_equal(result, expected) From 4c677c73cc73e8e336facc89430c3ee949144ff4 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Wed, 22 Feb 2023 12:24:34 -0800 Subject: [PATCH 16/16] Typo --- pandas/tests/frame/test_query_eval.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/tests/frame/test_query_eval.py b/pandas/tests/frame/test_query_eval.py index 9490e6a9f806f..fc0c81339de08 100644 --- a/pandas/tests/frame/test_query_eval.py +++ b/pandas/tests/frame/test_query_eval.py @@ -1332,7 +1332,6 @@ def test_query_ea_dtypes(self, dtype): # GH#50261 df = DataFrame({"a": Series([1, 2], dtype=dtype)}) ref = {2} # noqa:F841 - result = df.query("a in @ref") warning = RuntimeWarning if dtype == "Int64" and NUMEXPR_INSTALLED else None with tm.assert_produces_warning(warning): result = df.query("a in @ref")