Skip to content

Commit 674bab1

Browse files
committed
Parameterized tests
1 parent 12ab475 commit 674bab1

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

cf_xarray/tests/test_accessor.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,30 @@
99
from . import raise_if_dask_computes
1010

1111
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))
1313
datasets = [ds, ds.chunk({"lat": 5})]
1414
dataarrays = [ds.air, ds.air.chunk({"lat": 5})]
1515
objects = datasets + dataarrays
1616

1717

1818
@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):
2031
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()
2334
assert_identical(expected, actual)
2435

25-
# groupby
26-
# rolling
27-
# coarsen
28-
# weighted
29-
3036

3137
@pytest.mark.parametrize("obj", objects)
3238
def test_other_methods(obj):

0 commit comments

Comments
 (0)