MCPcopy
hub / github.com/pydata/xarray / test_ndrolling_construct

Method test_ndrolling_construct

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

Source from the content-addressed store, hash-verified

846 @pytest.mark.parametrize("fill_value", (np.nan, 0.0))
847 @pytest.mark.parametrize("dask", (True, False))
848 def test_ndrolling_construct(self, center, fill_value, dask) -> None:
849 da = DataArray(
850 np.arange(5 * 6 * 7).reshape(5, 6, 7).astype(float),
851 dims=["x", "y", "z"],
852 coords={"x": ["a", "b", "c", "d", "e"], "y": np.arange(6)},
853 )
854 ds = xr.Dataset({"da": da})
855 if dask and has_dask:
856 ds = ds.chunk({"x": 4})
857
858 actual = ds.rolling(x=3, z=2, center=center).construct(
859 x="x1", z="z1", fill_value=fill_value
860 )
861 if not isinstance(center, tuple):
862 center = (center, center)
863 expected = (
864 ds.rolling(x=3, center=center[0])
865 .construct(x="x1", fill_value=fill_value)
866 .rolling(z=2, center=center[1])
867 .construct(z="z1", fill_value=fill_value)
868 )
869 assert_allclose(actual, expected)
870
871 @requires_dask
872 @pytest.mark.filterwarnings("error")

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected