Skip to content
forked from pydata/xarray

Commit

Permalink
bad merge
Browse files Browse the repository at this point in the history
  • Loading branch information
dcherian committed Sep 17, 2024
1 parent 63b3e77 commit 7dc5dd1
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions xarray/tests/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -2759,6 +2759,36 @@ def test_weather_data_resample(use_flox):
assert expected.location.attrs == ds.location.attrs


@pytest.mark.parametrize("as_dataset", [True, False])
def test_multiple_groupers_string(as_dataset) -> None:
obj = DataArray(
np.array([1, 2, 3, 0, 2, np.nan]),
dims="d",
coords=dict(
labels1=("d", np.array(["a", "b", "c", "c", "b", "a"])),
labels2=("d", np.array(["x", "y", "z", "z", "y", "x"])),
),
name="foo",
)

if as_dataset:
obj = obj.to_dataset() # type: ignore[assignment]

expected = obj.groupby(labels1=UniqueGrouper(), labels2=UniqueGrouper()).mean()
actual = obj.groupby(("labels1", "labels2")).mean()
assert_identical(expected, actual)

# Passes `"labels2"` to squeeze; will raise an error around kwargs rather than the
# warning & type error in the future
with pytest.warns(FutureWarning):
with pytest.raises(TypeError):
obj.groupby("labels1", "labels2") # type: ignore[arg-type, misc]
with pytest.raises(ValueError):
obj.groupby("labels1", foo="bar") # type: ignore[arg-type]
with pytest.raises(ValueError):
obj.groupby("labels1", foo=UniqueGrouper())


@pytest.mark.parametrize("shuffle", [True, False])
@pytest.mark.parametrize("use_flox", [True, False])
def test_multiple_groupers(use_flox: bool, shuffle: bool) -> None:
Expand Down

0 comments on commit 7dc5dd1

Please sign in to comment.