Skip to content

Commit 82f3c21

Browse files
committed
Add skeleton tests
1 parent 17cc3d8 commit 82f3c21

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

xarray/tests/test_groupby.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@
1111
from packaging.version import Version
1212

1313
import xarray as xr
14-
from xarray import DataArray, Dataset, Variable
14+
from xarray import DataArray, Dataset, Variable, cftime_range
1515
from xarray.core.alignment import broadcast
1616
from xarray.core.groupby import _consolidate_slices
1717
from xarray.core.types import InterpOptions, ResampleCompatible
1818
from xarray.groupers import (
1919
BinGrouper,
2020
EncodedGroups,
2121
Grouper,
22+
SeasonResampler,
2223
TimeResampler,
2324
UniqueGrouper,
2425
season_to_month_tuple,
@@ -2944,6 +2945,24 @@ def test_season_to_month_tuple():
29442945
)
29452946

29462947

2948+
def test_season_resampler():
2949+
time = cftime_range("2001-01-01", "2002-12-30", freq="D", calendar="360_day")
2950+
da = DataArray(np.ones(time.size), dims="time", coords={"time": time})
2951+
2952+
# through resample
2953+
da.resample(time=SeasonResampler(["DJF", "MAM", "JJA", "SON"])).sum()
2954+
2955+
# through groupby
2956+
da.groupby(time=SeasonResampler(["DJF", "MAM", "JJA", "SON"])).sum()
2957+
2958+
# skip september
2959+
da.groupby(time=SeasonResampler(["DJF", "MAM", "JJA", "ON"])).sum()
2960+
2961+
# overlapping
2962+
with pytest.raises(ValueError):
2963+
da.groupby(time=SeasonResampler(["DJFM", "MAMJ", "JJAS", "SOND"])).sum()
2964+
2965+
29472966
# Possible property tests
29482967
# 1. lambda x: x
29492968
# 2. grouped-reduce on unique coords is identical to array

0 commit comments

Comments
 (0)