Skip to content

Commit 3bac500

Browse files
simonjayhawkinsPingviinituutti
authored andcommitted
TST: numpy RuntimeWarning with Series.round() (pandas-dev#25432)
1 parent 4229ea0 commit 3bac500

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

pandas/tests/frame/test_analytics.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import numpy as np
99
import pytest
1010

11-
from pandas.compat import PY35, lrange
11+
from pandas.compat import PY2, PY35, is_platform_windows, lrange
1212
import pandas.util._test_decorators as td
1313

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

1845+
@pytest.mark.xfail(
1846+
PY2 and is_platform_windows(), reason="numpy/numpy#7882",
1847+
raises=AssertionError, strict=True)
1848+
def test_numpy_round_nan(self):
1849+
# See gh-14197
1850+
df = Series([1.53, np.nan, 0.06]).to_frame()
1851+
with tm.assert_produces_warning(None):
1852+
result = df.round()
1853+
expected = Series([2., np.nan, 0.]).to_frame()
1854+
tm.assert_frame_equal(result, expected)
1855+
18451856
def test_round_mixed_type(self):
18461857
# GH 11885
18471858
df = DataFrame({'col1': [1.1, 2.2, 3.3, 4.4],

pandas/tests/series/test_analytics.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from numpy import nan
1010
import pytest
1111

12-
from pandas.compat import PY35, lrange, range
12+
from pandas.compat import PY2, PY35, is_platform_windows, lrange, range
1313
import pandas.util._test_decorators as td
1414

1515
import pandas as pd
@@ -285,6 +285,17 @@ def test_numpy_round(self):
285285
with pytest.raises(ValueError, match=msg):
286286
np.round(s, decimals=0, out=s)
287287

288+
@pytest.mark.xfail(
289+
PY2 and is_platform_windows(), reason="numpy/numpy#7882",
290+
raises=AssertionError, strict=True)
291+
def test_numpy_round_nan(self):
292+
# See gh-14197
293+
s = Series([1.53, np.nan, 0.06])
294+
with tm.assert_produces_warning(None):
295+
result = s.round()
296+
expected = Series([2., np.nan, 0.])
297+
assert_series_equal(result, expected)
298+
288299
def test_built_in_round(self):
289300
if not compat.PY3:
290301
pytest.skip(

0 commit comments

Comments
 (0)