MCPcopy Index your code
hub / github.com/pydata/xarray / test_ndrolling_reduce

Method test_ndrolling_reduce

xarray/tests/test_rolling.py:328–352  ·  view source on GitHub ↗
(
        self, da, center, min_periods, name, compute_backend
    )

Source from the content-addressed store, hash-verified

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))

Callers

nothing calls this directly

Calls 5

assert_allcloseFunction · 0.90
rollingMethod · 0.45
constructMethod · 0.45
countMethod · 0.45
whereMethod · 0.45

Tested by

no test coverage detected