From 62f999b58f24d719e44dcabc7941ed3e84e1a032 Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Sat, 15 Feb 2020 14:42:45 +0000 Subject: [PATCH 1/3] CI: silence numpy-dev failures --- pandas/tests/frame/test_cumulative.py | 9 +++++++ pandas/tests/groupby/test_transform.py | 3 +++ .../tests/scalar/timedelta/test_arithmetic.py | 24 ++++++++++++++----- pandas/tests/series/test_cumulative.py | 8 +++++++ 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/pandas/tests/frame/test_cumulative.py b/pandas/tests/frame/test_cumulative.py index b545d6aa8afd3..973c63dfa9c90 100644 --- a/pandas/tests/frame/test_cumulative.py +++ b/pandas/tests/frame/test_cumulative.py @@ -7,6 +7,9 @@ """ import numpy as np +import pytest + +from pandas.compat.numpy import _is_numpy_dev from pandas import DataFrame, Series import pandas._testing as tm @@ -73,6 +76,9 @@ def test_cumprod(self, datetime_frame): df.cumprod(0) df.cumprod(1) + @pytest.mark.xfail( + _is_numpy_dev, reason="https://github.com/pandas-dev/pandas/issues/31992" + ) def test_cummin(self, datetime_frame): datetime_frame.loc[5:10, 0] = np.nan datetime_frame.loc[10:15, 1] = np.nan @@ -96,6 +102,9 @@ def test_cummin(self, datetime_frame): cummin_xs = datetime_frame.cummin(axis=1) assert np.shape(cummin_xs) == np.shape(datetime_frame) + @pytest.mark.xfail( + _is_numpy_dev, reason="https://github.com/pandas-dev/pandas/issues/31992" + ) def test_cummax(self, datetime_frame): datetime_frame.loc[5:10, 0] = np.nan datetime_frame.loc[10:15, 1] = np.nan diff --git a/pandas/tests/groupby/test_transform.py b/pandas/tests/groupby/test_transform.py index 0ad829dd4de7a..122881ee54577 100644 --- a/pandas/tests/groupby/test_transform.py +++ b/pandas/tests/groupby/test_transform.py @@ -5,6 +5,7 @@ import pytest from pandas._libs import groupby +from pandas.compat.numpy import _is_numpy_dev from pandas.core.dtypes.common import ensure_platform_int, is_timedelta64_dtype @@ -329,6 +330,8 @@ def test_transform_transformation_func(transformation_func): if transformation_func in ["pad", "backfill", "tshift", "corrwith", "cumcount"]: # These transformation functions are not yet covered in this test pytest.xfail("See GH 31269 and GH 31270") + elif _is_numpy_dev and transformation_func in ["cummin"]: + pytest.xfail("https://github.com/pandas-dev/pandas/issues/31992") elif transformation_func == "fillna": test_op = lambda x: x.transform("fillna", value=0) mock_op = lambda x: x.fillna(value=0) diff --git a/pandas/tests/scalar/timedelta/test_arithmetic.py b/pandas/tests/scalar/timedelta/test_arithmetic.py index 60e278f47d0f8..58178a5750969 100644 --- a/pandas/tests/scalar/timedelta/test_arithmetic.py +++ b/pandas/tests/scalar/timedelta/test_arithmetic.py @@ -7,6 +7,8 @@ import numpy as np import pytest +from pandas.compat.numpy import _is_numpy_dev + import pandas as pd from pandas import NaT, Timedelta, Timestamp, offsets import pandas._testing as tm @@ -377,18 +379,28 @@ def test_td_div_numeric_scalar(self): assert isinstance(result, Timedelta) assert result == Timedelta(days=2) - @pytest.mark.parametrize("nan", [np.nan, np.float64("NaN"), float("nan")]) + @pytest.mark.parametrize( + "nan", + [ + np.nan, + pytest.param( + np.float64("NaN"), + marks=pytest.mark.xfail( + _is_numpy_dev, + reason="https://github.com/pandas-dev/pandas/issues/31992", + ), + ), + float("nan"), + ], + ) def test_td_div_nan(self, nan): # np.float64('NaN') has a 'dtype' attr, avoid treating as array td = Timedelta(10, unit="d") result = td / nan assert result is NaT - # TODO: Don't leave commented, this is just a temporary fix for - # https://github.com/pandas-dev/pandas/issues/31992 - - # result = td // nan - # assert result is NaT + result = td // nan + assert result is NaT # --------------------------------------------------------------- # Timedelta.__rdiv__ diff --git a/pandas/tests/series/test_cumulative.py b/pandas/tests/series/test_cumulative.py index 885b5bf0476f2..54906b119f7fd 100644 --- a/pandas/tests/series/test_cumulative.py +++ b/pandas/tests/series/test_cumulative.py @@ -10,6 +10,8 @@ import numpy as np import pytest +from pandas.compat.numpy import _is_numpy_dev + import pandas as pd import pandas._testing as tm @@ -37,6 +39,9 @@ def test_cumsum(self, datetime_series): def test_cumprod(self, datetime_series): _check_accum_op("cumprod", datetime_series) + @pytest.mark.xfail( + _is_numpy_dev, reason="https://github.com/pandas-dev/pandas/issues/31992" + ) def test_cummin(self, datetime_series): tm.assert_numpy_array_equal( datetime_series.cummin().values, @@ -49,6 +54,9 @@ def test_cummin(self, datetime_series): tm.assert_series_equal(result, expected) + @pytest.mark.xfail( + _is_numpy_dev, reason="https://github.com/pandas-dev/pandas/issues/31992" + ) def test_cummax(self, datetime_series): tm.assert_numpy_array_equal( datetime_series.cummax().values, From d91b182cb7beffef0c69047025766743e3cbc30d Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Sat, 15 Feb 2020 15:17:16 +0000 Subject: [PATCH 2/3] missed one. --- pandas/tests/groupby/test_function.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pandas/tests/groupby/test_function.py b/pandas/tests/groupby/test_function.py index 73e36cb5e6c84..8578b2acec42f 100644 --- a/pandas/tests/groupby/test_function.py +++ b/pandas/tests/groupby/test_function.py @@ -7,6 +7,7 @@ import numpy as np import pytest +from pandas.compat.numpy import _is_numpy_dev from pandas.errors import UnsupportedFunctionCall import pandas as pd @@ -685,6 +686,9 @@ def test_numpy_compat(func): getattr(g, func)(foo=1) +@pytest.mark.xfail( + _is_numpy_dev, reason="https://github.com/pandas-dev/pandas/issues/31992" +) def test_cummin_cummax(): # GH 15048 num_types = [np.int32, np.int64, np.float32, np.float64] From 3aacffa1143d700f32728b04d8c4ad10ef88d4e1 Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Sat, 15 Feb 2020 15:32:48 +0000 Subject: [PATCH 3/3] import _is_numpy_dev from pd namespace --- pandas/__init__.py | 1 + pandas/tests/api/test_api.py | 1 + pandas/tests/frame/test_cumulative.py | 4 +--- pandas/tests/groupby/test_function.py | 2 +- pandas/tests/groupby/test_transform.py | 2 +- pandas/tests/scalar/timedelta/test_arithmetic.py | 4 +--- pandas/tests/series/test_cumulative.py | 3 +-- 7 files changed, 7 insertions(+), 10 deletions(-) diff --git a/pandas/__init__.py b/pandas/__init__.py index d526531b159b2..2d3d3f7d92a9c 100644 --- a/pandas/__init__.py +++ b/pandas/__init__.py @@ -25,6 +25,7 @@ _np_version_under1p16, _np_version_under1p17, _np_version_under1p18, + _is_numpy_dev, ) try: diff --git a/pandas/tests/api/test_api.py b/pandas/tests/api/test_api.py index 406d5f055797d..5aab5b814bae7 100644 --- a/pandas/tests/api/test_api.py +++ b/pandas/tests/api/test_api.py @@ -198,6 +198,7 @@ class TestPDApi(Base): "_np_version_under1p16", "_np_version_under1p17", "_np_version_under1p18", + "_is_numpy_dev", "_testing", "_tslib", "_typing", diff --git a/pandas/tests/frame/test_cumulative.py b/pandas/tests/frame/test_cumulative.py index 973c63dfa9c90..2466547e2948b 100644 --- a/pandas/tests/frame/test_cumulative.py +++ b/pandas/tests/frame/test_cumulative.py @@ -9,9 +9,7 @@ import numpy as np import pytest -from pandas.compat.numpy import _is_numpy_dev - -from pandas import DataFrame, Series +from pandas import DataFrame, Series, _is_numpy_dev import pandas._testing as tm diff --git a/pandas/tests/groupby/test_function.py b/pandas/tests/groupby/test_function.py index 8578b2acec42f..8830b84a52421 100644 --- a/pandas/tests/groupby/test_function.py +++ b/pandas/tests/groupby/test_function.py @@ -7,7 +7,6 @@ import numpy as np import pytest -from pandas.compat.numpy import _is_numpy_dev from pandas.errors import UnsupportedFunctionCall import pandas as pd @@ -18,6 +17,7 @@ NaT, Series, Timestamp, + _is_numpy_dev, date_range, isna, ) diff --git a/pandas/tests/groupby/test_transform.py b/pandas/tests/groupby/test_transform.py index 122881ee54577..740103eec185a 100644 --- a/pandas/tests/groupby/test_transform.py +++ b/pandas/tests/groupby/test_transform.py @@ -5,7 +5,6 @@ import pytest from pandas._libs import groupby -from pandas.compat.numpy import _is_numpy_dev from pandas.core.dtypes.common import ensure_platform_int, is_timedelta64_dtype @@ -16,6 +15,7 @@ MultiIndex, Series, Timestamp, + _is_numpy_dev, concat, date_range, ) diff --git a/pandas/tests/scalar/timedelta/test_arithmetic.py b/pandas/tests/scalar/timedelta/test_arithmetic.py index 58178a5750969..f0ad5fa70471b 100644 --- a/pandas/tests/scalar/timedelta/test_arithmetic.py +++ b/pandas/tests/scalar/timedelta/test_arithmetic.py @@ -7,10 +7,8 @@ import numpy as np import pytest -from pandas.compat.numpy import _is_numpy_dev - import pandas as pd -from pandas import NaT, Timedelta, Timestamp, offsets +from pandas import NaT, Timedelta, Timestamp, _is_numpy_dev, offsets import pandas._testing as tm from pandas.core import ops diff --git a/pandas/tests/series/test_cumulative.py b/pandas/tests/series/test_cumulative.py index 54906b119f7fd..b0065992b850a 100644 --- a/pandas/tests/series/test_cumulative.py +++ b/pandas/tests/series/test_cumulative.py @@ -10,9 +10,8 @@ import numpy as np import pytest -from pandas.compat.numpy import _is_numpy_dev - import pandas as pd +from pandas import _is_numpy_dev import pandas._testing as tm