Skip to content

Commit f21d4d3

Browse files
committed
added constant data in test
1 parent a89faf6 commit f21d4d3

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

pandas/tests/window/test_ewm.py

+24-4
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,28 @@ def test_ewma_times_adjust_false_raises():
187187
@pytest.mark.parametrize("dtype", [np.float32, np.float16, np.float64, float, "float"])
188188
def test_float_dtype_ewma(dtype, func):
189189
# GH#42452
190-
df = DataFrame(np.random.rand(20, 3), dtype=dtype)
190+
expected_mean = DataFrame(
191+
{
192+
0: range(5),
193+
1: range(4, 9),
194+
2: [7.428571, 9, 10.571429, 12.142857, 13.714286],
195+
},
196+
dtype=float,
197+
)
198+
expected_std = DataFrame(
199+
{
200+
0: [np.nan] * 5,
201+
1: [4.242641] * 5,
202+
2: [4.6291, 5.196152, 5.781745, 6.380775, 6.989788],
203+
}
204+
)
205+
expected_var = expected_std ** 2
206+
df = DataFrame({0: range(5), 1: range(6, 11), 2: range(10, 20, 2)}, dtype=dtype)
191207
e = df.ewm(alpha=0.5, axis=1)
192-
result = getattr(e, func)().shape
193-
expected = (20, 3)
194-
assert result == expected, f"Shape of ewm {func} must match dataframe"
208+
result = getattr(e, func)()
209+
expected = {
210+
"expected_var": expected_var,
211+
"expected_mean": expected_mean,
212+
"expected_std": expected_std,
213+
}
214+
tm.assert_frame_equal(result, expected[f"expected_{func}"])

0 commit comments

Comments
 (0)