Skip to content
forked from pydata/xarray

Commit 94c1c1f

Browse files
committed
Add tests for pydata#8263
1 parent 0ab4eb6 commit 94c1c1f

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

xarray/core/groupby.py

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def check_reduce_dims(reduce_dims, dimensions):
7171
raise ValueError(
7272
f"cannot reduce over dimensions {reduce_dims!r}. expected either '...' "
7373
f"to reduce over all dimensions or one or more of {dimensions!r}."
74+
f" Try passing .groupby(..., squeeze=False)"
7475
)
7576

7677

xarray/tests/test_groupby.py

+12
Original file line numberDiff line numberDiff line change
@@ -2483,3 +2483,15 @@ def test_groupby_math_auto_chunk():
24832483
)
24842484
actual = da.chunk(x=1, y=2).groupby("label") - sub
24852485
assert actual.chunksizes == {"x": (1, 1, 1), "y": (2, 1)}
2486+
2487+
2488+
@pytest.mark.parametrize("use_flox", [True, False])
2489+
def test_groupby_dim_no_dim_equal(use_flox):
2490+
# https://github.com/pydata/xarray/issues/8263
2491+
da = DataArray(
2492+
data=[1, 2, 3, 4], dims="lat", coords={"lat": np.linspace(0, 1.01, 4)}
2493+
)
2494+
with xr.set_options(use_flox=use_flox):
2495+
actual1 = da.drop_vars("lat").groupby("lat", squeeze=False).sum()
2496+
actual2 = da.groupby("lat", squeeze=False).sum()
2497+
assert_identical(actual1, actual2.drop_vars("lat"))

0 commit comments

Comments
 (0)