(time_chunks, resample_spec)
| 60 | @pytest.mark.parametrize("time_chunks", (1, 5)) |
| 61 | @pytest.mark.parametrize("resample_spec", ("1YS", "5YS", "10YS")) |
| 62 | def 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( |
nothing calls this directly
no test coverage detected
searching dependent graphs…