From 93e786b53ffed69f07ccbb1e6394a9efbce81b75 Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Thu, 19 Sep 2024 20:27:18 -0600 Subject: [PATCH] Add test for #757 --- xarray/tests/test_groupby.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/xarray/tests/test_groupby.py b/xarray/tests/test_groupby.py index 8b8d01baee3..2a81dd460e2 100644 --- a/xarray/tests/test_groupby.py +++ b/xarray/tests/test_groupby.py @@ -3004,6 +3004,15 @@ def test_lazy_int_bins_error(): _ = BinGrouper(bins=4).factorize(DataArray(dask.array.arange(3))) +def test_time_grouping_seasons_specified(): + time = xr.date_range("2001-01-01", "2002-01-01", freq="D") + ds = xr.Dataset({"foo": np.arange(time.size)}, coords={"time": ("time", time)}) + labels = ["DJF", "MAM", "JJA", "SON"] + actual = ds.groupby({"time.season": UniqueGrouper(labels=labels)}).sum() + expected = ds.groupby("time.season").sum() + assert_identical(actual, expected.reindex(season=labels)) + + # Possible property tests # 1. lambda x: x # 2. grouped-reduce on unique coords is identical to array