Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dcherian committed Dec 29, 2021
1 parent e1ba8a2 commit bdb999f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion xarray/core/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,9 @@ def _flox_reduce(self, dim, **kwargs):
# TODO: switch to xindexes after we can use is_unique
index = self._obj.indexes[self._group.name]
if index.is_unique and self._squeeze:
raise ValueError(f"cannot reduce over dimensions {self._group.name!r}")
raise ValueError(
f"Cannot reduce over absent dimensions {self._group.name!r}"
)

# TODO: only do this for resample, not general groupers...
# this creates a label DataArray since resample doesn't do that somehow
Expand Down
8 changes: 4 additions & 4 deletions xarray/tests/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,13 +514,13 @@ def test_groupby_grouping_errors() -> None:

def test_groupby_reduce_dimension_error(array) -> None:
grouped = array.groupby("y")
with pytest.raises(ValueError, match=r"cannot reduce over dimensions"):
with pytest.raises(ValueError, match=r"Cannot reduce over absent dimensions"):
grouped.mean()

with pytest.raises(ValueError, match=r"cannot reduce over dimensions"):
with pytest.raises(ValueError, match=r"Cannot reduce over absent dimensions"):
grouped.mean("huh")

with pytest.raises(ValueError, match=r"cannot reduce over dimensions"):
with pytest.raises(ValueError, match=r"Cannot reduce over absent dimensions"):
grouped.mean(("x", "y", "asd"))

grouped = array.groupby("y", squeeze=False)
Expand Down Expand Up @@ -1656,7 +1656,7 @@ def test_resample_min_count(self):
],
dim=actual["time"],
)
assert_equal(expected, actual)
assert_allclose(expected, actual)

def test_resample_by_mean_with_keep_attrs(self):
times = pd.date_range("2000-01-01", freq="6H", periods=10)
Expand Down

0 comments on commit bdb999f

Please sign in to comment.