MCPcopy
hub / github.com/pydata/xarray / test_rolling_iter

Method test_rolling_iter

xarray/tests/test_rolling.py:56–69  ·  view source on GitHub ↗
(self, da: DataArray, center: bool, size: int)

Source from the content-addressed store, hash-verified

54 @pytest.mark.parametrize("center", [True, False])
55 @pytest.mark.parametrize("size", [1, 2, 3, 7])
56 def test_rolling_iter(self, da: DataArray, center: bool, size: int) -> None:
57 rolling_obj = da.rolling(time=size, center=center)
58 rolling_obj_mean = rolling_obj.mean()
59
60 assert len(rolling_obj.window_labels) == len(da["time"])
61 assert_identical(rolling_obj.window_labels, da["time"])
62
63 for i, (label, window_da) in enumerate(rolling_obj):
64 assert label == da["time"].isel(time=i)
65
66 actual = rolling_obj_mean.isel(time=i)
67 expected = window_da.mean("time")
68
69 np.testing.assert_allclose(actual.values, expected.values)
70
71 @pytest.mark.parametrize("da", (1,), indirect=True)
72 def test_rolling_repr(self, da) -> None:

Callers

nothing calls this directly

Calls 4

assert_identicalFunction · 0.90
rollingMethod · 0.45
meanMethod · 0.45
iselMethod · 0.45

Tested by

no test coverage detected