Skip to content

Commit

Permalink
typing
Browse files Browse the repository at this point in the history
  • Loading branch information
dcherian committed Jan 27, 2025
1 parent 8d2d7ad commit 1ad2e51
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions xarray/core/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -1357,7 +1357,12 @@ def where(self, cond, other=dtypes.NA) -> T_Xarray:
"""
return ops.where_method(self, cond, other)

def _first_or_last(self, op: str, skipna: bool | None, keep_attrs: bool | None):
def _first_or_last(
self,
op: Literal["first" | "last"],
skipna: bool | None,
keep_attrs: bool | None,
):
if all(
isinstance(maybe_slice, slice)
and (maybe_slice.stop == maybe_slice.start + 1)
Expand All @@ -1369,13 +1374,12 @@ def _first_or_last(self, op: str, skipna: bool | None, keep_attrs: bool | None):
if keep_attrs is None:
keep_attrs = _get_keep_attrs(default=True)
if (
skipna
and module_available("flox", minversion="0.9.16")
module_available("flox", minversion="0.9.16")
and OPTIONS["use_flox"]
and contains_only_chunked_or_numpy(self._obj)
):
result, *_ = self._flox_reduce(
dim=None, func=f"nan{op}" if skipna else op, keep_attrs=keep_attrs
dim=None, func=op, skipna=skipna, keep_attrs=keep_attrs
)
else:
result = self.reduce(
Expand Down

0 comments on commit 1ad2e51

Please sign in to comment.