From 7994f6a0980df4191c5cb759bbd9787e13d9a03f Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Sun, 24 Feb 2019 15:54:49 +0000 Subject: [PATCH 1/7] TST: numpy RuntimeWarning with Series.round() --- pandas/tests/frame/test_analytics.py | 8 ++++++++ pandas/tests/series/test_analytics.py | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/pandas/tests/frame/test_analytics.py b/pandas/tests/frame/test_analytics.py index 2e690ebbfa121..f949cc1e5e788 100644 --- a/pandas/tests/frame/test_analytics.py +++ b/pandas/tests/frame/test_analytics.py @@ -1842,6 +1842,14 @@ def test_numpy_round(self): with pytest.raises(ValueError, match=msg): np.round(df, decimals=0, out=df) + def test_numpy_round_nan(self): + # See gh-14197 + df = Series([1.53, np.nan, 0.06]).to_frame() + with np.errstate(invalid='raise'): + result = df.round() + expected = Series([2., np.nan, 0.]).to_frame() + tm.assert_frame_equal(result, expected) + def test_round_mixed_type(self): # GH 11885 df = DataFrame({'col1': [1.1, 2.2, 3.3, 4.4], diff --git a/pandas/tests/series/test_analytics.py b/pandas/tests/series/test_analytics.py index 6811e370726b2..a041ed15baeaf 100644 --- a/pandas/tests/series/test_analytics.py +++ b/pandas/tests/series/test_analytics.py @@ -285,6 +285,14 @@ def test_numpy_round(self): with pytest.raises(ValueError, match=msg): np.round(s, decimals=0, out=s) + def test_numpy_round_nan(self): + # See gh-14197 + s = Series([1.53, np.nan, 0.06]) + with np.errstate(invalid='raise'): + result = s.round() + expected = Series([2., np.nan, 0.]) + assert_series_equal(result, expected) + def test_built_in_round(self): if not compat.PY3: pytest.skip( From 103647a12c6ff0f9981ec314cb6a23818ddc7ec8 Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Sun, 24 Feb 2019 16:43:15 +0000 Subject: [PATCH 2/7] add skipif PY2 and is_platform_windows --- pandas/tests/frame/test_analytics.py | 4 +++- pandas/tests/series/test_analytics.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pandas/tests/frame/test_analytics.py b/pandas/tests/frame/test_analytics.py index f949cc1e5e788..06b9179220a46 100644 --- a/pandas/tests/frame/test_analytics.py +++ b/pandas/tests/frame/test_analytics.py @@ -8,7 +8,7 @@ import numpy as np import pytest -from pandas.compat import PY35, lrange +from pandas.compat import PY2, PY35, lrange, is_platform_windows import pandas.util._test_decorators as td import pandas as pd @@ -1842,6 +1842,8 @@ def test_numpy_round(self): with pytest.raises(ValueError, match=msg): np.round(df, decimals=0, out=df) + @pytest.mark.skipif( + PY2 and is_platform_windows(), reason="numpy/numpy#7882") def test_numpy_round_nan(self): # See gh-14197 df = Series([1.53, np.nan, 0.06]).to_frame() diff --git a/pandas/tests/series/test_analytics.py b/pandas/tests/series/test_analytics.py index a041ed15baeaf..45560390be01e 100644 --- a/pandas/tests/series/test_analytics.py +++ b/pandas/tests/series/test_analytics.py @@ -9,7 +9,7 @@ from numpy import nan import pytest -from pandas.compat import PY35, lrange, range +from pandas.compat import PY2, PY35, is_platform_windows, lrange, range import pandas.util._test_decorators as td import pandas as pd @@ -285,6 +285,8 @@ def test_numpy_round(self): with pytest.raises(ValueError, match=msg): np.round(s, decimals=0, out=s) + @pytest.mark.skipif( + PY2 and is_platform_windows(), reason="numpy/numpy#7882") def test_numpy_round_nan(self): # See gh-14197 s = Series([1.53, np.nan, 0.06]) From 36760e74df053a4119d4c676b8fd4ca2ad46c236 Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Sun, 24 Feb 2019 17:21:43 +0000 Subject: [PATCH 3/7] isort imports --- pandas/tests/frame/test_analytics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/frame/test_analytics.py b/pandas/tests/frame/test_analytics.py index 06b9179220a46..4527569dc06f8 100644 --- a/pandas/tests/frame/test_analytics.py +++ b/pandas/tests/frame/test_analytics.py @@ -8,7 +8,7 @@ import numpy as np import pytest -from pandas.compat import PY2, PY35, lrange, is_platform_windows +from pandas.compat import PY2, PY35, is_platform_windows, lrange import pandas.util._test_decorators as td import pandas as pd From 82643188dee6072e4c3215845a460d6019f43054 Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Sun, 24 Feb 2019 19:24:11 +0000 Subject: [PATCH 4/7] change test from skip to xfail --- pandas/tests/frame/test_analytics.py | 5 +++-- pandas/tests/series/test_analytics.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pandas/tests/frame/test_analytics.py b/pandas/tests/frame/test_analytics.py index 4527569dc06f8..b662456b6cf4f 100644 --- a/pandas/tests/frame/test_analytics.py +++ b/pandas/tests/frame/test_analytics.py @@ -1842,8 +1842,9 @@ def test_numpy_round(self): with pytest.raises(ValueError, match=msg): np.round(df, decimals=0, out=df) - @pytest.mark.skipif( - PY2 and is_platform_windows(), reason="numpy/numpy#7882") + @pytest.mark.xfail( + PY2 and is_platform_windows(), reason="numpy/numpy#7882", + raises=FloatingPointError, strict=True) def test_numpy_round_nan(self): # See gh-14197 df = Series([1.53, np.nan, 0.06]).to_frame() diff --git a/pandas/tests/series/test_analytics.py b/pandas/tests/series/test_analytics.py index 45560390be01e..7201ee7c8f3a2 100644 --- a/pandas/tests/series/test_analytics.py +++ b/pandas/tests/series/test_analytics.py @@ -285,8 +285,9 @@ def test_numpy_round(self): with pytest.raises(ValueError, match=msg): np.round(s, decimals=0, out=s) - @pytest.mark.skipif( - PY2 and is_platform_windows(), reason="numpy/numpy#7882") + @pytest.mark.xfail( + PY2 and is_platform_windows(), reason="numpy/numpy#7882", + raises=FloatingPointError, strict=True) def test_numpy_round_nan(self): # See gh-14197 s = Series([1.53, np.nan, 0.06]) From 698f96b583d1598a3c1863257049a809a0099554 Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Sun, 24 Feb 2019 20:04:20 +0000 Subject: [PATCH 5/7] add tm.assert_produces_warning(None) --- pandas/tests/frame/test_analytics.py | 3 ++- pandas/tests/series/test_analytics.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pandas/tests/frame/test_analytics.py b/pandas/tests/frame/test_analytics.py index b662456b6cf4f..db9fbd25728d1 100644 --- a/pandas/tests/frame/test_analytics.py +++ b/pandas/tests/frame/test_analytics.py @@ -1849,7 +1849,8 @@ def test_numpy_round_nan(self): # See gh-14197 df = Series([1.53, np.nan, 0.06]).to_frame() with np.errstate(invalid='raise'): - result = df.round() + with tm.assert_produces_warning(None): + result = df.round() expected = Series([2., np.nan, 0.]).to_frame() tm.assert_frame_equal(result, expected) diff --git a/pandas/tests/series/test_analytics.py b/pandas/tests/series/test_analytics.py index 7201ee7c8f3a2..7794ea5281f0d 100644 --- a/pandas/tests/series/test_analytics.py +++ b/pandas/tests/series/test_analytics.py @@ -292,7 +292,8 @@ def test_numpy_round_nan(self): # See gh-14197 s = Series([1.53, np.nan, 0.06]) with np.errstate(invalid='raise'): - result = s.round() + with tm.assert_produces_warning(None): + result = s.round() expected = Series([2., np.nan, 0.]) assert_series_equal(result, expected) From 9fe55fc4020fa56922b1d0328a443e4a71fa8c83 Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Sun, 24 Feb 2019 20:41:20 +0000 Subject: [PATCH 6/7] remove with np.errstate(invalid='raise'): --- pandas/tests/frame/test_analytics.py | 7 +++---- pandas/tests/series/test_analytics.py | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/pandas/tests/frame/test_analytics.py b/pandas/tests/frame/test_analytics.py index db9fbd25728d1..43a45bb915819 100644 --- a/pandas/tests/frame/test_analytics.py +++ b/pandas/tests/frame/test_analytics.py @@ -1844,13 +1844,12 @@ def test_numpy_round(self): @pytest.mark.xfail( PY2 and is_platform_windows(), reason="numpy/numpy#7882", - raises=FloatingPointError, strict=True) + raises=AssertionError, strict=True) def test_numpy_round_nan(self): # See gh-14197 df = Series([1.53, np.nan, 0.06]).to_frame() - with np.errstate(invalid='raise'): - with tm.assert_produces_warning(None): - result = df.round() + with tm.assert_produces_warning(None): + result = df.round() expected = Series([2., np.nan, 0.]).to_frame() tm.assert_frame_equal(result, expected) diff --git a/pandas/tests/series/test_analytics.py b/pandas/tests/series/test_analytics.py index 7794ea5281f0d..1f265d574da15 100644 --- a/pandas/tests/series/test_analytics.py +++ b/pandas/tests/series/test_analytics.py @@ -287,13 +287,12 @@ def test_numpy_round(self): @pytest.mark.xfail( PY2 and is_platform_windows(), reason="numpy/numpy#7882", - raises=FloatingPointError, strict=True) + raises=AssertionError, strict=True) def test_numpy_round_nan(self): # See gh-14197 s = Series([1.53, np.nan, 0.06]) - with np.errstate(invalid='raise'): - with tm.assert_produces_warning(None): - result = s.round() + with tm.assert_produces_warning(None): + result = s.round() expected = Series([2., np.nan, 0.]) assert_series_equal(result, expected) From cb0fde0f9de8ee47d6ccabb44df150ea0e5fc57d Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Sun, 24 Feb 2019 21:00:25 +0000 Subject: [PATCH 7/7] restart ci