Skip to content

Commit

Permalink
more typing
Browse files Browse the repository at this point in the history
  • Loading branch information
dcherian committed Jun 13, 2024
1 parent f00d9d2 commit 235b553
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
6 changes: 4 additions & 2 deletions xarray/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

from xarray.core.dataarray import DataArray
from xarray.core.dataset import Dataset
from xarray.core.groupers import Resampler
from xarray.core.indexes import Index
from xarray.core.resample import Resample
from xarray.core.rolling_exp import RollingExp
Expand Down Expand Up @@ -876,7 +877,7 @@ def rolling_exp(
def _resample(
self,
resample_cls: type[T_Resample],
indexer: Mapping[Any, str] | None,
indexer: Mapping[Hashable, str | Resampler] | None,
skipna: bool | None,
closed: SideOptions | None,
label: SideOptions | None,
Expand All @@ -885,7 +886,7 @@ def _resample(
origin: str | DatetimeLike,
loffset: datetime.timedelta | str | None,
restore_coord_dims: bool | None,
**indexer_kwargs: str,
**indexer_kwargs: str | Resampler,
) -> T_Resample:
"""Returns a Resample object for performing resampling operations.
Expand Down Expand Up @@ -1098,6 +1099,7 @@ def _resample(
name=RESAMPLE_DIM,
)

grouper: Resampler
if isinstance(freq, str):
grouper = TimeResampler(
freq=freq,
Expand Down
6 changes: 3 additions & 3 deletions xarray/core/dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
from xarray.backends import ZarrStore
from xarray.backends.api import T_NetcdfEngine, T_NetcdfTypes
from xarray.core.groupby import DataArrayGroupBy
from xarray.core.groupers import Grouper
from xarray.core.groupers import Grouper, Resampler
from xarray.core.resample import DataArrayResample
from xarray.core.rolling import DataArrayCoarsen, DataArrayRolling
from xarray.core.types import (
Expand Down Expand Up @@ -7216,7 +7216,7 @@ def coarsen(

def resample(
self,
indexer: Mapping[Any, str] | None = None,
indexer: Mapping[Hashable, str | Resampler] | None = None,
skipna: bool | None = None,
closed: SideOptions | None = None,
label: SideOptions | None = None,
Expand All @@ -7225,7 +7225,7 @@ def resample(
origin: str | DatetimeLike = "start_day",
loffset: datetime.timedelta | str | None = None,
restore_coord_dims: bool | None = None,
**indexer_kwargs: str,
**indexer_kwargs: str | Resampler,
) -> DataArrayResample:
"""Returns a Resample object for performing resampling operations.
Expand Down
6 changes: 3 additions & 3 deletions xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
from xarray.backends.api import T_NetcdfEngine, T_NetcdfTypes
from xarray.core.dataarray import DataArray
from xarray.core.groupby import DatasetGroupBy
from xarray.core.groupers import Grouper
from xarray.core.groupers import Grouper, Resampler
from xarray.core.merge import CoercibleMapping, CoercibleValue, _MergeResult
from xarray.core.resample import DatasetResample
from xarray.core.rolling import DatasetCoarsen, DatasetRolling
Expand Down Expand Up @@ -10600,7 +10600,7 @@ def coarsen(

def resample(
self,
indexer: Mapping[Any, str] | None = None,
indexer: Mapping[Hashable, str | Resampler] | None = None,
skipna: bool | None = None,
closed: SideOptions | None = None,
label: SideOptions | None = None,
Expand All @@ -10609,7 +10609,7 @@ def resample(
origin: str | DatetimeLike = "start_day",
loffset: datetime.timedelta | str | None = None,
restore_coord_dims: bool | None = None,
**indexer_kwargs: str,
**indexer_kwargs: str | Resampler,
) -> DatasetResample:
"""Returns a Resample object for performing resampling operations.
Expand Down

0 comments on commit 235b553

Please sign in to comment.