Skip to content

Commit 7f1d2a3

Browse files
committed
test(rolling): undo test modifications for degenerate windows
1 parent 5cc8b60 commit 7f1d2a3

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

pandas/tests/window/test_rolling.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1843,17 +1843,16 @@ 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")
18471846
def test_rolling_skew_kurt_floating_artifacts():
18481847
# GH 42064 46431
18491848

18501849
sr = Series([1 / 3, 4, 0, 0, 0, 0, 0])
18511850
r = sr.rolling(4)
18521851
result = r.skew()
1853-
expected = Series([np.nan, np.nan, np.nan, 1.9619045191072484, 2.0, np.nan, np.nan])
1852+
expected = Series([np.nan, np.nan, np.nan, 1.9619045191072484, 2.0, 0.0, 0.0])
18541853
tm.assert_series_equal(result, expected)
18551854
result = r.kurt()
1856-
expected = Series([np.nan, np.nan, np.nan, 3.8636048803878786, 4.0, np.nan, np.nan])
1855+
expected = Series([np.nan, np.nan, np.nan, 3.8636048803878786, 4.0, -3.0, -3.0])
18571856
tm.assert_series_equal(result, expected)
18581857

18591858

pandas/tests/window/test_rolling_skew_kurt.py

Lines changed: 5 additions & 4 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] * 5)[::step]
173+
expected = Series([np.nan] * 4 + [0.0])[::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 NaN as it contains 5 same obs (variance 0)
177+
# index 4 should be 0 as it contains 5 same obs
178178
tm.assert_series_equal(expected, x)
179179

180180
expected = Series([np.nan] * 5)[::step]
@@ -213,9 +213,10 @@ 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
216217
a = Series([1.1] * 15).rolling(window=10, step=step).skew()
217-
expected = Series([np.nan] * 15)[::step]
218-
tm.assert_series_equal(expected, a)
218+
assert (a[a.index >= 9] == 0).all()
219+
assert a[a.index < 9].isna().all()
219220

220221

221222
def test_rolling_kurt_eq_value_fperr(step):

0 commit comments

Comments
 (0)