Skip to content

Commit

Permalink
fix some mypy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rhkleijn committed Aug 17, 2023
1 parent 56bf01c commit 379bf9d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions xarray/core/rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import itertools
import math
import warnings
from collections.abc import Hashable, Iterator, Mapping
from collections.abc import Hashable, Iterator, Mapping, Sequence
from typing import TYPE_CHECKING, Any, Callable, Generic, TypeVar

import numpy as np
Expand Down Expand Up @@ -467,9 +467,8 @@ def reduce(
obj, rolling_dim, keep_attrs=keep_attrs, fill_value=fillna
)

result = windows.reduce(
func, dim=list(rolling_dim.values()), keep_attrs=keep_attrs, **kwargs
)
dim: Sequence[Hashable] = list(rolling_dim.values())
result = windows.reduce(func, dim=dim, keep_attrs=keep_attrs, **kwargs)

# Find valid windows based on count.
counts = self._counts(keep_attrs=False)
Expand All @@ -486,14 +485,15 @@ def _counts(self, keep_attrs: bool | None) -> DataArray:
# array is faster to be reduced than object array.
# The use of skipna==False is also faster since it does not need to
# copy the strided array.
dim: Sequence[Hashable] = list(rolling_dim.values())
counts = (
self.obj.notnull(keep_attrs=keep_attrs)
.rolling(
{d: w for d, w in zip(self.dim, self.window)},
center={d: self.center[i] for i, d in enumerate(self.dim)},
)
.construct(rolling_dim, fill_value=False, keep_attrs=keep_attrs)
.sum(dim=list(rolling_dim.values()), skipna=False, keep_attrs=keep_attrs)
.sum(dim=dim, skipna=False, keep_attrs=keep_attrs)
)
return counts

Expand Down

0 comments on commit 379bf9d

Please sign in to comment.