Skip to content

Commit 1142663

Browse files
committed
Try to fix typing
1 parent 205c2a7 commit 1142663

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

doc/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@
158158
"Variable": "~xarray.Variable",
159159
"DatasetGroupBy": "~xarray.core.groupby.DatasetGroupBy",
160160
"DataArrayGroupBy": "~xarray.core.groupby.DataArrayGroupBy",
161+
"Grouper": "~xarray.core.groupers.Grouper",
162+
"Resampler": "~xarray.core.groupers.Resampler",
161163
# objects without namespace: numpy
162164
"ndarray": "~numpy.ndarray",
163165
"MaskedArray": "~numpy.ma.MaskedArray",

xarray/core/dataarray.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6684,7 +6684,7 @@ def interp_calendar(
66846684
def groupby(
66856685
self,
66866686
group: (
6687-
Hashable | DataArray | IndexVariable | Mapping[Hashable, Grouper] | None
6687+
Hashable | DataArray | IndexVariable | Mapping[Any, Grouper] | None
66886688
) = None,
66896689
squeeze: bool | None = None,
66906690
restore_coord_dims: bool = False,
@@ -6694,18 +6694,19 @@ def groupby(
66946694
66956695
Parameters
66966696
----------
6697-
group : Hashable, DataArray or IndexVariable
6697+
group : Hashable or DataArray or IndexVariable or mapping of Hashable to Grouper
66986698
Array whose unique values should be used to group this array. If a
6699-
Hashable, must be the name of a coordinate contained in this dataarray.
6699+
Hashable, must be the name of a coordinate contained in this dataarray. If a dictionary,
6700+
must map an existing variable name to a :py:class:`Grouper` instance.
67006701
squeeze : bool, default: True
67016702
If "group" is a dimension of any arrays in this dataset, `squeeze`
67026703
controls whether the subarrays have a dimension of length 1 along
67036704
that dimension or if the dimension is squeezed out.
67046705
restore_coord_dims : bool, default: False
67056706
If True, also restore the dimension order of multi-dimensional
67066707
coordinates.
6707-
**groupers : Mapping of hashable to Grouper or Resampler
6708-
Mapping of variable name to group by to ``Grouper`` or ``Resampler`` object.
6708+
**groupers : Mapping of str to Grouper or Resampler
6709+
Mapping of variable name to group by to :py:class:`Grouper` or :py:class:`Resampler` object.
67096710
One of ``group`` or ``groupers`` must be provided.
67106711
Only a single ``grouper`` is allowed at present.
67116712
@@ -6775,7 +6776,7 @@ def groupby(
67756776
_validate_groupby_squeeze(squeeze)
67766777

67776778
if isinstance(group, Mapping):
6778-
groupers = either_dict_or_kwargs(group, groupers, "groupby")
6779+
groupers = either_dict_or_kwargs(group, groupers, "groupby") # type: ignore
67796780
group = None
67806781

67816782
grouper: Grouper

xarray/core/dataset.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10258,7 +10258,7 @@ def interp_calendar(
1025810258
def groupby(
1025910259
self,
1026010260
group: (
10261-
Hashable | DataArray | IndexVariable | Mapping[Hashable, Grouper] | None
10261+
Hashable | DataArray | IndexVariable | Mapping[Any, Grouper] | None
1026210262
) = None,
1026310263
squeeze: bool | None = None,
1026410264
restore_coord_dims: bool = False,
@@ -10268,18 +10268,19 @@ def groupby(
1026810268
1026910269
Parameters
1027010270
----------
10271-
group : Hashable, DataArray or IndexVariable
10271+
group : Hashable or DataArray or IndexVariable or mapping of Hashable to Grouper
1027210272
Array whose unique values should be used to group this array. If a
10273-
string, must be the name of a variable contained in this dataset.
10273+
Hashable, must be the name of a coordinate contained in this dataarray. If a dictionary,
10274+
must map an existing variable name to a :py:class:`Grouper` instance.
1027410275
squeeze : bool, default: True
1027510276
If "group" is a dimension of any arrays in this dataset, `squeeze`
1027610277
controls whether the subarrays have a dimension of length 1 along
1027710278
that dimension or if the dimension is squeezed out.
1027810279
restore_coord_dims : bool, default: False
1027910280
If True, also restore the dimension order of multi-dimensional
1028010281
coordinates.
10281-
**groupers : Mapping of hashable to Grouper or Resampler
10282-
Mapping of variable name to group by to ``Grouper`` or ``Resampler`` object.
10282+
**groupers : Mapping of str to Grouper or Resampler
10283+
Mapping of variable name to group by to :py:class:`Grouper` or :py:class:`Resampler` object.
1028310284
One of ``group`` or ``groupers`` must be provided.
1028410285
Only a single ``grouper`` is allowed at present.
1028510286
@@ -10318,7 +10319,7 @@ def groupby(
1031810319
_validate_groupby_squeeze(squeeze)
1031910320

1032010321
if isinstance(group, Mapping):
10321-
groupers = either_dict_or_kwargs(group, groupers, "groupby")
10322+
groupers = either_dict_or_kwargs(group, groupers, "groupby") # type: ignore
1032210323
group = None
1032310324

1032410325
if group is not None:
@@ -10613,7 +10614,7 @@ def coarsen(
1061310614

1061410615
def resample(
1061510616
self,
10616-
indexer: Mapping[Hashable, str | Resampler] | None = None,
10617+
indexer: Mapping[Any, str | Resampler] | None = None,
1061710618
skipna: bool | None = None,
1061810619
closed: SideOptions | None = None,
1061910620
label: SideOptions | None = None,

0 commit comments

Comments
 (0)