From 941ca21a36486687bbd9f669e4630247f9785604 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Mon, 31 May 2021 08:47:15 -0700 Subject: [PATCH 1/2] Backport PR #41730: CI: suppress npdev warnings --- pandas/conftest.py | 11 +++++++++++ pandas/tests/arithmetic/test_interval.py | 2 +- pandas/tests/frame/methods/test_to_records.py | 14 ++++++++++++-- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/pandas/conftest.py b/pandas/conftest.py index 6b26f855c36f0..3ae05e1c7b937 100644 --- a/pandas/conftest.py +++ b/pandas/conftest.py @@ -41,11 +41,17 @@ from pandas.core import ops from pandas.core.indexes.api import Index, MultiIndex +# Until https://github.com/numpy/numpy/issues/19078 is sorted out, just suppress +suppress_npdev_promotion_warning = pytest.mark.filterwarnings( + "ignore:Promotion of numbers and bools:FutureWarning" +) # ---------------------------------------------------------------- # Configuration / Settings # ---------------------------------------------------------------- # pytest + + def pytest_configure(config): # Register marks to avoid warnings in pandas.test() # sync with setup.cfg @@ -96,6 +102,11 @@ def pytest_runtest_setup(item): pytest.skip("skipping high memory test since --run-high-memory was not set") +def pytest_collection_modifyitems(items): + for item in items: + item.add_marker(suppress_npdev_promotion_warning) + + # Hypothesis hypothesis.settings.register_profile( "ci", diff --git a/pandas/tests/arithmetic/test_interval.py b/pandas/tests/arithmetic/test_interval.py index 6dc3b3b13dd0c..4473d86fa04a1 100644 --- a/pandas/tests/arithmetic/test_interval.py +++ b/pandas/tests/arithmetic/test_interval.py @@ -235,7 +235,7 @@ def test_compare_list_like_nan(self, op, array, nulls_fixture, request): Categorical(list("abab")), Categorical(date_range("2017-01-01", periods=4)), pd.array(list("abcd")), - pd.array(["foo", 3.14, None, object()]), + pd.array(["foo", 3.14, None, object()], dtype=object), ], ids=lambda x: str(x.dtype), ) diff --git a/pandas/tests/frame/methods/test_to_records.py b/pandas/tests/frame/methods/test_to_records.py index e83882be9c680..0b710d7ebf7d7 100644 --- a/pandas/tests/frame/methods/test_to_records.py +++ b/pandas/tests/frame/methods/test_to_records.py @@ -3,6 +3,8 @@ import numpy as np import pytest +from pandas.compat.numpy import is_numpy_dev + from pandas import ( CategoricalDtype, DataFrame, @@ -162,20 +164,28 @@ def test_to_records_with_categorical(self): ), ), # Pass in a type instance. - ( + pytest.param( {"column_dtypes": str}, np.rec.array( [("0", "1", "0.2", "a"), ("1", "2", "1.5", "bc")], dtype=[("index", " Date: Tue, 1 Jun 2021 20:09:01 +0100 Subject: [PATCH 2/2] fixup --- ci/azure/posix.yml | 2 +- pandas/conftest.py | 11 ----------- pandas/tests/arithmetic/common.py | 1 + pandas/tests/frame/test_arithmetic.py | 1 + 4 files changed, 3 insertions(+), 12 deletions(-) diff --git a/ci/azure/posix.yml b/ci/azure/posix.yml index 4cb4eaf95f6f5..2bb348a11655c 100644 --- a/ci/azure/posix.yml +++ b/ci/azure/posix.yml @@ -62,7 +62,7 @@ jobs: ENV_FILE: ci/deps/azure-38-numpydev.yaml CONDA_PY: "38" PATTERN: "not slow and not network" - TEST_ARGS: "-W error" + TEST_ARGS: "-W error -W \"ignore:Promotion of numbers and bools:FutureWarning\"" PANDAS_TESTING_MODE: "deprecate" EXTRA_APT: "xsel" diff --git a/pandas/conftest.py b/pandas/conftest.py index 3ae05e1c7b937..6b26f855c36f0 100644 --- a/pandas/conftest.py +++ b/pandas/conftest.py @@ -41,17 +41,11 @@ from pandas.core import ops from pandas.core.indexes.api import Index, MultiIndex -# Until https://github.com/numpy/numpy/issues/19078 is sorted out, just suppress -suppress_npdev_promotion_warning = pytest.mark.filterwarnings( - "ignore:Promotion of numbers and bools:FutureWarning" -) # ---------------------------------------------------------------- # Configuration / Settings # ---------------------------------------------------------------- # pytest - - def pytest_configure(config): # Register marks to avoid warnings in pandas.test() # sync with setup.cfg @@ -102,11 +96,6 @@ def pytest_runtest_setup(item): pytest.skip("skipping high memory test since --run-high-memory was not set") -def pytest_collection_modifyitems(items): - for item in items: - item.add_marker(suppress_npdev_promotion_warning) - - # Hypothesis hypothesis.settings.register_profile( "ci", diff --git a/pandas/tests/arithmetic/common.py b/pandas/tests/arithmetic/common.py index e26bb513838a5..d42da39ec8ff0 100644 --- a/pandas/tests/arithmetic/common.py +++ b/pandas/tests/arithmetic/common.py @@ -83,6 +83,7 @@ def xbox2(x): "Invalid comparison between", "Cannot compare type", "not supported between", + "could not be promoted", "invalid type promotion", ( # GH#36706 npdev 1.20.0 2020-09-28 diff --git a/pandas/tests/frame/test_arithmetic.py b/pandas/tests/frame/test_arithmetic.py index e5ec3c5641bd2..51420859dc1bd 100644 --- a/pandas/tests/frame/test_arithmetic.py +++ b/pandas/tests/frame/test_arithmetic.py @@ -79,6 +79,7 @@ def check(df, df2): msgs = [ r"Invalid comparison between dtype=datetime64\[ns\] and ndarray", "invalid type promotion", + "could not be promoted", ( # npdev 1.20.0 r"The DTypes and "