(
self, da, center, min_periods, name, compute_backend
)
| 326 | @pytest.mark.parametrize("min_periods", (None, 1)) |
| 327 | @pytest.mark.parametrize("name", ("sum", "mean", "max")) |
| 328 | def test_ndrolling_reduce( |
| 329 | self, da, center, min_periods, name, compute_backend |
| 330 | ) -> None: |
| 331 | rolling_obj = da.rolling(time=3, x=2, center=center, min_periods=min_periods) |
| 332 | |
| 333 | actual = getattr(rolling_obj, name)() |
| 334 | expected = getattr( |
| 335 | getattr( |
| 336 | da.rolling(time=3, center=center, min_periods=min_periods), name |
| 337 | )().rolling(x=2, center=center, min_periods=min_periods), |
| 338 | name, |
| 339 | )() |
| 340 | |
| 341 | assert_allclose(actual, expected) |
| 342 | assert actual.sizes == expected.sizes |
| 343 | |
| 344 | if name == "mean": |
| 345 | # test our reimplementation of nanmean using np.nanmean |
| 346 | expected = getattr(rolling_obj.construct({"time": "tw", "x": "xw"}), name)( |
| 347 | ["tw", "xw"] |
| 348 | ) |
| 349 | count = rolling_obj.count() |
| 350 | if min_periods is None: |
| 351 | min_periods = 1 |
| 352 | assert_allclose(actual, expected.where(count >= min_periods)) |
| 353 | |
| 354 | @pytest.mark.parametrize("center", (True, False, (True, False))) |
| 355 | @pytest.mark.parametrize("fill_value", (np.nan, 0.0)) |
nothing calls this directly
no test coverage detected