(self)
| 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)) |
| 990 | |
| 991 | kwargs = dict(dim="x", window=3, window_dim="xw") |
| 992 | actual = x.rolling_window(**kwargs, center=True, fill_value=np.nan) |
| 993 | expected = Variable( |
| 994 | ("x", "xw"), |
| 995 | np.array( |
| 996 | [[np.nan, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, np.nan]], dtype=float |
| 997 | ), |
| 998 | ) |
| 999 | assert_equal(actual, expected) |
| 1000 | |
| 1001 | actual = x.rolling_window(**kwargs, center=False, fill_value=0.0) |
| 1002 | expected = self.cls( |
| 1003 | ("x", "xw"), |
| 1004 | np.array([[0, 0, 1], [0, 1, 2], [1, 2, 3], [2, 3, 4]], dtype=float), |
| 1005 | ) |
| 1006 | assert_equal(actual, expected) |
| 1007 | |
| 1008 | x = self.cls(("y", "x"), np.stack([x, x * 1.1])) |
| 1009 | actual = x.rolling_window(**kwargs, center=False, fill_value=0.0) |
| 1010 | expected = self.cls( |
| 1011 | ("y", "x", "xw"), np.stack([expected.data, expected.data * 1.1], axis=0) |
| 1012 | ) |
| 1013 | assert_equal(actual, expected) |
| 1014 | |
| 1015 | @pytest.mark.parametrize("center", [[True, True], [False, False]]) |
| 1016 | @pytest.mark.parametrize("dims", [("x", "y"), ("y", "z"), ("z", "x")]) |
nothing calls this directly
no test coverage detected