Skip to content

Commit e2e4fb6

Browse files
committed
parametrized expected df; removed float16
1 parent a0a531e commit e2e4fb6

File tree

2 files changed

+41
-25
lines changed

2 files changed

+41
-25
lines changed

pandas/core/frame.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4283,7 +4283,7 @@ def check_int_infer_dtype(dtypes):
42834283
elif dtype == "float":
42844284
# GH#42452 : np.dtype("float") coerces to np.float64 from Numpy 1.20
42854285
converted_dtypes.extend(
4286-
[np.float64, np.float32, np.float16] # type: ignore[list-item]
4286+
[np.float64, np.float32] # type: ignore[list-item]
42874287
)
42884288
else:
42894289
# error: Argument 1 to "append" of "list" has incompatible type

pandas/tests/window/test_ewm.py

+40-24
Original file line numberDiff line numberDiff line change
@@ -183,33 +183,49 @@ def test_ewma_times_adjust_false_raises():
183183
)
184184

185185

186-
@pytest.mark.parametrize("func", ["mean", "std", "var"])
187-
def test_float_dtype_ewma(func, float_dtype):
186+
@pytest.mark.parametrize(
187+
"func, expected",
188+
[
189+
[
190+
"mean",
191+
DataFrame(
192+
{
193+
0: range(5),
194+
1: range(4, 9),
195+
2: [7.428571, 9, 10.571429, 12.142857, 13.714286],
196+
},
197+
dtype=float,
198+
),
199+
],
200+
[
201+
"std",
202+
DataFrame(
203+
{
204+
0: [np.nan] * 5,
205+
1: [4.242641] * 5,
206+
2: [4.6291, 5.196152, 5.781745, 6.380775, 6.989788],
207+
}
208+
),
209+
],
210+
[
211+
"var",
212+
DataFrame(
213+
{
214+
0: [np.nan] * 5,
215+
1: [18.0] * 5,
216+
2: [21.428571, 27, 33.428571, 40.714286, 48.857143],
217+
}
218+
),
219+
],
220+
],
221+
)
222+
def test_float_dtype_ewma(func, expected, float_dtype):
188223
# GH#42452
189-
expected_mean = DataFrame(
190-
{
191-
0: range(5),
192-
1: range(4, 9),
193-
2: [7.428571, 9, 10.571429, 12.142857, 13.714286],
194-
},
195-
dtype=float,
196-
)
197-
expected_std = DataFrame(
198-
{
199-
0: [np.nan] * 5,
200-
1: [4.242641] * 5,
201-
2: [4.6291, 5.196152, 5.781745, 6.380775, 6.989788],
202-
}
203-
)
204-
expected_var = expected_std ** 2
224+
205225
df = DataFrame(
206226
{0: range(5), 1: range(6, 11), 2: range(10, 20, 2)}, dtype=float_dtype
207227
)
208228
e = df.ewm(alpha=0.5, axis=1)
209229
result = getattr(e, func)()
210-
expected = {
211-
"expected_var": expected_var,
212-
"expected_mean": expected_mean,
213-
"expected_std": expected_std,
214-
}
215-
tm.assert_frame_equal(result, expected[f"expected_{func}"])
230+
231+
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)