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

Method test_ndrolling_construct

xarray/tests/test_rolling.py:356–373  ·  view source on GitHub ↗
(self, center, fill_value)

Source from the content-addressed store, hash-verified

354 @pytest.mark.parametrize("center", (True, False, (True, False)))
355 @pytest.mark.parametrize("fill_value", (np.nan, 0.0))
356 def test_ndrolling_construct(self, center, fill_value) -> None:
357 da = DataArray(
358 np.arange(5 * 6 * 7).reshape(5, 6, 7).astype(float),
359 dims=["x", "y", "z"],
360 coords={"x": ["a", "b", "c", "d", "e"], "y": np.arange(6)},
361 )
362 actual = da.rolling(x=3, z=2, center=center).construct(
363 x="x1", z="z1", fill_value=fill_value
364 )
365 if not isinstance(center, tuple):
366 center = (center, center)
367 expected = (
368 da.rolling(x=3, center=center[0])
369 .construct(x="x1", fill_value=fill_value)
370 .rolling(z=2, center=center[1])
371 .construct(z="z1", fill_value=fill_value)
372 )
373 assert_allclose(actual, expected)
374
375 @pytest.mark.parametrize(
376 "funcname, argument",

Callers

nothing calls this directly

Calls 7

rollingMethod · 0.95
DataArrayClass · 0.90
assert_allcloseFunction · 0.90
arangeMethod · 0.80
astypeMethod · 0.45
constructMethod · 0.45
rollingMethod · 0.45

Tested by

no test coverage detected