(self, d, w)
| 966 | |
| 967 | @pytest.mark.parametrize("d, w", (("x", 3), ("y", 5))) |
| 968 | def test_rolling_window(self, d, w): |
| 969 | # Just a working test. See test_nputils for the algorithm validation |
| 970 | v = self.cls(["x", "y", "z"], np.arange(40 * 30 * 2).reshape(40, 30, 2)) |
| 971 | v_rolling = v.rolling_window(d, w, d + "_window") |
| 972 | assert v_rolling.dims == ("x", "y", "z", d + "_window") |
| 973 | assert v_rolling.shape == v.shape + (w,) |
| 974 | |
| 975 | v_rolling = v.rolling_window(d, w, d + "_window", center=True) |
| 976 | assert v_rolling.dims == ("x", "y", "z", d + "_window") |
| 977 | assert v_rolling.shape == v.shape + (w,) |
| 978 | |
| 979 | # dask and numpy result should be the same |
| 980 | v_loaded = v.load().rolling_window(d, w, d + "_window", center=True) |
| 981 | assert_array_equal(v_rolling, v_loaded) |
| 982 | |
| 983 | # numpy backend should not be over-written |
| 984 | if isinstance(v._data, np.ndarray): |
| 985 | with pytest.raises(ValueError): |
| 986 | v_loaded[0] = 1.0 |
| 987 | |
| 988 | def test_rolling_1d(self): |
| 989 | x = self.cls("x", np.array([1, 2, 3, 4], dtype=float)) |
nothing calls this directly
no test coverage detected