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

Function test_weighted_lazy_resample

xarray/tests/test_weighted.py:62–78  ·  view source on GitHub ↗
(time_chunks, resample_spec)

Source from the content-addressed store, hash-verified

60@pytest.mark.parametrize("time_chunks", (1, 5))
61@pytest.mark.parametrize("resample_spec", ("1YS", "5YS", "10YS"))
62def test_weighted_lazy_resample(time_chunks, resample_spec):
63 # https://github.com/pydata/xarray/issues/4625
64
65 # simple customized weighted mean function
66 def mean_func(ds):
67 return ds.weighted(ds.weights).mean("time")
68
69 # example dataset
70 t = xr.date_range(start="2000", periods=20, freq="1YS", use_cftime=True)
71 weights = xr.DataArray(np.random.rand(len(t)), dims=["time"], coords={"time": t})
72 data = xr.DataArray(
73 np.random.rand(len(t)), dims=["time"], coords={"time": t, "weights": weights}
74 )
75 ds = xr.Dataset({"data": data}).chunk({"time": time_chunks})
76
77 with raise_if_dask_computes():
78 ds.resample(time=resample_spec).map(mean_func)
79
80
81@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 4

raise_if_dask_computesFunction · 0.90
chunkMethod · 0.45
mapMethod · 0.45
resampleMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…