Skip to content
forked from pydata/xarray

Commit

Permalink
Add tests for pydata#8263
Browse files Browse the repository at this point in the history
  • Loading branch information
dcherian committed Dec 22, 2023
1 parent 0ab4eb6 commit 94c1c1f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions xarray/core/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def check_reduce_dims(reduce_dims, dimensions):
raise ValueError(
f"cannot reduce over dimensions {reduce_dims!r}. expected either '...' "
f"to reduce over all dimensions or one or more of {dimensions!r}."
f" Try passing .groupby(..., squeeze=False)"
)


Expand Down
12 changes: 12 additions & 0 deletions xarray/tests/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -2483,3 +2483,15 @@ def test_groupby_math_auto_chunk():
)
actual = da.chunk(x=1, y=2).groupby("label") - sub
assert actual.chunksizes == {"x": (1, 1, 1), "y": (2, 1)}


@pytest.mark.parametrize("use_flox", [True, False])
def test_groupby_dim_no_dim_equal(use_flox):
# https://github.com/pydata/xarray/issues/8263
da = DataArray(
data=[1, 2, 3, 4], dims="lat", coords={"lat": np.linspace(0, 1.01, 4)}
)
with xr.set_options(use_flox=use_flox):
actual1 = da.drop_vars("lat").groupby("lat", squeeze=False).sum()
actual2 = da.groupby("lat", squeeze=False).sum()
assert_identical(actual1, actual2.drop_vars("lat"))

0 comments on commit 94c1c1f

Please sign in to comment.