Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST: numpy RuntimeWarning with Series.round() #25432

Merged
merged 8 commits into from
Feb 27, 2019
Merged
13 changes: 12 additions & 1 deletion pandas/tests/frame/test_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import numpy as np
import pytest

from pandas.compat import PY35, lrange
from pandas.compat import PY2, PY35, is_platform_windows, lrange
import pandas.util._test_decorators as td

import pandas as pd
Expand Down Expand Up @@ -1842,6 +1842,17 @@ def test_numpy_round(self):
with pytest.raises(ValueError, match=msg):
np.round(df, decimals=0, out=df)

@pytest.mark.xfail(
PY2 and is_platform_windows(), reason="numpy/numpy#7882",
raises=AssertionError, strict=True)
def test_numpy_round_nan(self):
# See gh-14197
df = Series([1.53, np.nan, 0.06]).to_frame()
with tm.assert_produces_warning(None):
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],
Expand Down
13 changes: 12 additions & 1 deletion pandas/tests/series/test_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -285,6 +285,17 @@ def test_numpy_round(self):
with pytest.raises(ValueError, match=msg):
np.round(s, decimals=0, out=s)

@pytest.mark.xfail(
PY2 and is_platform_windows(), reason="numpy/numpy#7882",
raises=AssertionError, strict=True)
def test_numpy_round_nan(self):
# See gh-14197
s = Series([1.53, np.nan, 0.06])
with tm.assert_produces_warning(None):
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(
Expand Down