Skip to content

Commit

Permalink
TST: numpy RuntimeWarning with Series.round() (#25432)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonjayhawkins authored and jreback committed Feb 27, 2019
1 parent aa08416 commit fe1654f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
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

0 comments on commit fe1654f

Please sign in to comment.