|
9 | 9 | from . import raise_if_dask_computes
|
10 | 10 |
|
11 | 11 | mpl.use("Agg")
|
12 |
| -ds = xr.tutorial.open_dataset("air_temperature").isel(time=slice(4)) |
| 12 | +ds = xr.tutorial.open_dataset("air_temperature").isel(time=slice(4), lon=slice(50)) |
13 | 13 | datasets = [ds, ds.chunk({"lat": 5})]
|
14 | 14 | dataarrays = [ds.air, ds.air.chunk({"lat": 5})]
|
15 | 15 | objects = datasets + dataarrays
|
16 | 16 |
|
17 | 17 |
|
18 | 18 | @pytest.mark.parametrize("obj", objects)
|
19 |
| -def test_wrapped_classes(obj): |
| 19 | +@pytest.mark.parametrize( |
| 20 | + "attr, xrkwargs, cfkwargs", |
| 21 | + ( |
| 22 | + ("resample", {"time": "M"}, {"T": "M"}), |
| 23 | + ("rolling", {"lat": 5}, {"Y": 5}), |
| 24 | + ("coarsen", {"lon": 2, "lat": 5}, {"X": 2, "Y": 5}), |
| 25 | + # groupby |
| 26 | + # groupby_bins |
| 27 | + # weighted |
| 28 | + ), |
| 29 | +) |
| 30 | +def test_wrapped_classes(obj, attr, xrkwargs, cfkwargs): |
20 | 31 | with raise_if_dask_computes():
|
21 |
| - expected = obj.resample(time="M").mean() |
22 |
| - actual = obj.cf.resample(T="M").mean() |
| 32 | + expected = getattr(obj, attr)(**xrkwargs).mean() |
| 33 | + actual = getattr(obj.cf, attr)(**cfkwargs).mean() |
23 | 34 | assert_identical(expected, actual)
|
24 | 35 |
|
25 |
| - # groupby |
26 |
| - # rolling |
27 |
| - # coarsen |
28 |
| - # weighted |
29 |
| - |
30 | 36 |
|
31 | 37 | @pytest.mark.parametrize("obj", objects)
|
32 | 38 | def test_other_methods(obj):
|
|
0 commit comments