From 29c6fd6ffaac7fc70d0b6f4069931b2daac50a5a Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Tue, 26 Nov 2019 07:28:35 -0800 Subject: [PATCH 1/4] COMPAT: fix numpy_compat test on npdev 1.18 --- pandas/tests/indexes/test_numpy_compat.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/tests/indexes/test_numpy_compat.py b/pandas/tests/indexes/test_numpy_compat.py index 6626ccf4a29f8..228818ba2ca01 100644 --- a/pandas/tests/indexes/test_numpy_compat.py +++ b/pandas/tests/indexes/test_numpy_compat.py @@ -6,6 +6,7 @@ Float64Index, Index, Int64Index, + PeriodIndex, TimedeltaIndex, UInt64Index, _np_version_under1p17, @@ -81,17 +82,16 @@ def test_numpy_ufuncs_other(indices, func): if isinstance(idx, (DatetimeIndex, TimedeltaIndex)): # ok under numpy >= 1.17 - if not _np_version_under1p17 and func in [np.isfinite]: + if not _np_version_under1p17 and func in [np.isfinite, np.isinf, np.isnan]: # Results in bool array result = func(idx) assert isinstance(result, np.ndarray) - assert not isinstance(result, Index) else: # raise TypeError or ValueError (PeriodIndex) with pytest.raises(Exception): func(idx) - elif isinstance(idx, DatetimeIndexOpsMixin): + elif isinstance(idx, PeriodIndex): # raise TypeError or ValueError (PeriodIndex) with pytest.raises(Exception): func(idx) From a2b55f9179e8236d451e15fd2cf4bd942e07df8e Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Tue, 26 Nov 2019 07:30:16 -0800 Subject: [PATCH 2/4] TST: catch FutureWarnings --- pandas/tests/reshape/test_concat.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pandas/tests/reshape/test_concat.py b/pandas/tests/reshape/test_concat.py index 667fe689861be..bb8339439d339 100644 --- a/pandas/tests/reshape/test_concat.py +++ b/pandas/tests/reshape/test_concat.py @@ -765,13 +765,15 @@ def test_concat_join_axes_deprecated(self, axis): ) expected = pd.concat([one, two], axis=1, sort=False).reindex(index=two.index) - result = pd.concat([one, two], axis=1, sort=False, join_axes=[two.index]) + with tm.assert_produces_warning(FutureWarning): + result = pd.concat([one, two], axis=1, sort=False, join_axes=[two.index]) tm.assert_frame_equal(result, expected) expected = pd.concat([one, two], axis=0, sort=False).reindex( columns=two.columns ) - result = pd.concat([one, two], axis=0, sort=False, join_axes=[two.columns]) + with tm.assert_produces_warning(FutureWarning): + result = pd.concat([one, two], axis=0, sort=False, join_axes=[two.columns]) tm.assert_frame_equal(result, expected) From 85da1ea07eb0b5495595ccf9fc48ee1b76499341 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Tue, 26 Nov 2019 09:01:26 -0800 Subject: [PATCH 3/4] specific catch for 1.18 --- pandas/__init__.py | 1 + pandas/tests/indexes/test_numpy_compat.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pandas/__init__.py b/pandas/__init__.py index cd697b757a26a..d6f3458b4d604 100644 --- a/pandas/__init__.py +++ b/pandas/__init__.py @@ -24,6 +24,7 @@ _np_version_under1p15, _np_version_under1p16, _np_version_under1p17, + _np_version_under1p18, ) try: diff --git a/pandas/tests/indexes/test_numpy_compat.py b/pandas/tests/indexes/test_numpy_compat.py index 228818ba2ca01..3d24c70afdda2 100644 --- a/pandas/tests/indexes/test_numpy_compat.py +++ b/pandas/tests/indexes/test_numpy_compat.py @@ -10,6 +10,7 @@ TimedeltaIndex, UInt64Index, _np_version_under1p17, + _np_version_under1p18, ) from pandas.core.indexes.datetimelike import DatetimeIndexOpsMixin import pandas.util.testing as tm @@ -81,8 +82,13 @@ def test_numpy_ufuncs_other(indices, func): idx = indices if isinstance(idx, (DatetimeIndex, TimedeltaIndex)): - # ok under numpy >= 1.17 - if not _np_version_under1p17 and func in [np.isfinite, np.isinf, np.isnan]: + if not _np_version_under1p18 and func in [np.isfinite, np.isinf, np.isnan]: + # numpy 1.18(dev) changed isinf and isnan to not raise on dt64/tfd64 + result = func(idx) + assert isinstance(result, np.ndarray) + + elif not _np_version_under1p17 and func in [np.isfinite]: + # ok under numpy >= 1.17 # Results in bool array result = func(idx) assert isinstance(result, np.ndarray) From 18337490f55bac37c8fda4986af83b17c68fa667 Mon Sep 17 00:00:00 2001 From: jbrockmendel Date: Tue, 26 Nov 2019 10:44:23 -0800 Subject: [PATCH 4/4] fix api test --- pandas/tests/api/test_api.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/tests/api/test_api.py b/pandas/tests/api/test_api.py index 1282aa6edd538..85e38d58a6c57 100644 --- a/pandas/tests/api/test_api.py +++ b/pandas/tests/api/test_api.py @@ -189,6 +189,7 @@ class TestPDApi(Base): "_np_version_under1p15", "_np_version_under1p16", "_np_version_under1p17", + "_np_version_under1p18", "_tslib", "_typing", "_version",