Skip to content

Commit 488e99e

Browse files
committed
test: change tested behavior
1 parent 23345cf commit 488e99e

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

pandas/tests/window/test_rolling.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1843,15 +1843,18 @@ def test_rolling_mean_sum_floating_artifacts():
18431843
assert (result[-3:] == 0).all()
18441844

18451845

1846+
@pytest.mark.xfail(reason="Series.rolling.kurt computes -3 to degenerate distribution")
18461847
def test_rolling_skew_kurt_floating_artifacts():
18471848
# GH 42064 46431
18481849

18491850
sr = Series([1 / 3, 4, 0, 0, 0, 0, 0])
18501851
r = sr.rolling(4)
18511852
result = r.skew()
1852-
assert (result[-2:] == 0).all()
1853+
expected = Series([np.nan, np.nan, np.nan, 1.9619045191072484, 2.0, np.nan, np.nan])
1854+
tm.assert_series_equal(result, expected)
18531855
result = r.kurt()
1854-
assert (result[-2:] == -3).all()
1856+
expected = Series([np.nan, np.nan, np.nan, 3.8636048803878786, 4.0, np.nan, np.nan])
1857+
tm.assert_series_equal(result, expected)
18551858

18561859

18571860
def test_numeric_only_frame(arithmetic_win_operators, numeric_only):

pandas/tests/window/test_rolling_skew_kurt.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,11 @@ def test_center_reindex_frame(frame, roll_func):
170170

171171

172172
def test_rolling_skew_edge_cases(step):
173-
expected = Series([np.nan] * 4 + [0.0])[::step]
173+
expected = Series([np.nan] * 5)[::step]
174174
# yields all NaN (0 variance)
175175
d = Series([1] * 5)
176176
x = d.rolling(window=5, step=step).skew()
177-
# index 4 should be 0 as it contains 5 same obs
177+
# index 4 should be NaN as it contains 5 same obs (variance 0)
178178
tm.assert_series_equal(expected, x)
179179

180180
expected = Series([np.nan] * 5)[::step]
@@ -213,10 +213,9 @@ def test_rolling_kurt_edge_cases(step):
213213

214214
def test_rolling_skew_eq_value_fperr(step):
215215
# #18804 all rolling skew for all equal values should return Nan
216-
# #46717 update: all equal values should return 0 instead of NaN
217216
a = Series([1.1] * 15).rolling(window=10, step=step).skew()
218-
assert (a[a.index >= 9] == 0).all()
219-
assert a[a.index < 9].isna().all()
217+
expected = Series([np.nan] * 15)[::step]
218+
tm.assert_series_equal(expected, a)
220219

221220

222221
def test_rolling_kurt_eq_value_fperr(step):

0 commit comments

Comments
 (0)