From ee533dd78a374d8fc781512952d0881358cbd231 Mon Sep 17 00:00:00 2001 From: Marco Edward Gorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Sat, 10 Dec 2022 17:02:53 +0000 Subject: [PATCH] Backport PR #50129: CI: fix with new numpy nightly --- pandas/tests/dtypes/test_missing.py | 3 ++- pandas/tests/indexes/object/test_indexing.py | 7 +++++++ pandas/tests/series/methods/test_equals.py | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/pandas/tests/dtypes/test_missing.py b/pandas/tests/dtypes/test_missing.py index 9c8aeb050ec27..9f761c505075b 100644 --- a/pandas/tests/dtypes/test_missing.py +++ b/pandas/tests/dtypes/test_missing.py @@ -9,6 +9,7 @@ from pandas._libs import missing as libmissing from pandas._libs.tslibs import iNaT +from pandas.compat import is_numpy_dev from pandas.core.dtypes.common import ( is_float, @@ -461,7 +462,7 @@ def test_array_equivalent_series(val): cm = ( # stacklevel is chosen to make sense when called from .equals tm.assert_produces_warning(FutureWarning, match=msg, check_stacklevel=False) - if isinstance(val, str) + if isinstance(val, str) and not is_numpy_dev else nullcontext() ) with cm: diff --git a/pandas/tests/indexes/object/test_indexing.py b/pandas/tests/indexes/object/test_indexing.py index 38bd96921b991..924a33169c132 100644 --- a/pandas/tests/indexes/object/test_indexing.py +++ b/pandas/tests/indexes/object/test_indexing.py @@ -128,6 +128,13 @@ def test_get_indexer_non_unique_np_nats(self, np_nat_fixture, np_nat_fixture2): tm.assert_numpy_array_equal(missing, expected_missing) # dt64nat vs td64nat else: + try: + np_nat_fixture == np_nat_fixture2 + except (TypeError, OverflowError): + # Numpy will raise on uncomparable types, like + # np.datetime64('NaT', 'Y') and np.datetime64('NaT', 'ps') + # https://github.com/numpy/numpy/issues/22762 + return index = Index( np.array( [ diff --git a/pandas/tests/series/methods/test_equals.py b/pandas/tests/series/methods/test_equals.py index 22e27c271df88..9278d1b51e1aa 100644 --- a/pandas/tests/series/methods/test_equals.py +++ b/pandas/tests/series/methods/test_equals.py @@ -5,6 +5,7 @@ import pytest from pandas._libs.missing import is_matching_na +from pandas.compat import is_numpy_dev from pandas.core.dtypes.common import is_float @@ -50,7 +51,7 @@ def test_equals_list_array(val): cm = ( tm.assert_produces_warning(FutureWarning, check_stacklevel=False) - if isinstance(val, str) + if isinstance(val, str) and not is_numpy_dev else nullcontext() ) with cm: