|
22 | 22 | ("resample", {"time": "M"}, {"T": "M"}),
|
23 | 23 | ("rolling", {"lat": 5}, {"Y": 5}),
|
24 | 24 | ("coarsen", {"lon": 2, "lat": 5}, {"X": 2, "Y": 5}),
|
25 |
| - # groupby |
| 25 | + ("groupby", {"group": "time"}, {"group": "T"}) |
| 26 | + # groupby("time.day")? |
26 | 27 | # groupby_bins
|
27 | 28 | # weighted
|
28 | 29 | ),
|
29 | 30 | )
|
30 | 31 | def test_wrapped_classes(obj, attr, xrkwargs, cfkwargs):
|
| 32 | + |
| 33 | + if attr in ("rolling", "coarsen"): |
| 34 | + # TODO: xarray bug, rolling and coarsen don't accept ellipsis |
| 35 | + args = () |
| 36 | + else: |
| 37 | + args = (...,) |
| 38 | + |
31 | 39 | with raise_if_dask_computes():
|
32 |
| - expected = getattr(obj, attr)(**xrkwargs).mean() |
33 |
| - actual = getattr(obj.cf, attr)(**cfkwargs).mean() |
| 40 | + expected = getattr(obj, attr)(**xrkwargs).mean(*args) |
| 41 | + actual = getattr(obj.cf, attr)(**cfkwargs).mean(*args) |
34 | 42 | assert_identical(expected, actual)
|
35 | 43 |
|
| 44 | + if attr in ("groupby", "groupby_bins"): |
| 45 | + # TODO: this should work for resample too? |
| 46 | + with raise_if_dask_computes(): |
| 47 | + expected = getattr(obj, attr)(**xrkwargs).mean("lat") |
| 48 | + actual = getattr(obj.cf, attr)(**cfkwargs).mean("Y") |
| 49 | + assert_identical(expected, actual) |
| 50 | + |
36 | 51 |
|
37 | 52 | @pytest.mark.parametrize("obj", objects)
|
38 |
| -def test_other_methods(obj): |
| 53 | +def test_kwargs_methods(obj): |
39 | 54 | with raise_if_dask_computes():
|
40 | 55 | expected = obj.isel(time=slice(2))
|
41 | 56 | actual = obj.cf.isel(T=slice(2))
|
42 | 57 | assert_identical(expected, actual)
|
43 | 58 |
|
| 59 | + |
| 60 | +@pytest.mark.parametrize("obj", objects) |
| 61 | +def test_args_methods(obj): |
44 | 62 | with raise_if_dask_computes():
|
45 | 63 | expected = obj.sum("time")
|
46 | 64 | actual = obj.cf.sum("T")
|
|
0 commit comments