Skip to content

Commit

Permalink
Try to fix typing
Browse files Browse the repository at this point in the history
  • Loading branch information
dcherian committed Jul 11, 2024
1 parent 205c2a7 commit 1142663
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
2 changes: 2 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@
"Variable": "~xarray.Variable",
"DatasetGroupBy": "~xarray.core.groupby.DatasetGroupBy",
"DataArrayGroupBy": "~xarray.core.groupby.DataArrayGroupBy",
"Grouper": "~xarray.core.groupers.Grouper",
"Resampler": "~xarray.core.groupers.Resampler",
# objects without namespace: numpy
"ndarray": "~numpy.ndarray",
"MaskedArray": "~numpy.ma.MaskedArray",
Expand Down
13 changes: 7 additions & 6 deletions xarray/core/dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -6684,7 +6684,7 @@ def interp_calendar(
def groupby(
self,
group: (
Hashable | DataArray | IndexVariable | Mapping[Hashable, Grouper] | None
Hashable | DataArray | IndexVariable | Mapping[Any, Grouper] | None
) = None,
squeeze: bool | None = None,
restore_coord_dims: bool = False,
Expand All @@ -6694,18 +6694,19 @@ def groupby(
Parameters
----------
group : Hashable, DataArray or IndexVariable
group : Hashable or DataArray or IndexVariable or mapping of Hashable to Grouper
Array whose unique values should be used to group this array. If a
Hashable, must be the name of a coordinate contained in this dataarray.
Hashable, must be the name of a coordinate contained in this dataarray. If a dictionary,
must map an existing variable name to a :py:class:`Grouper` instance.
squeeze : bool, default: True
If "group" is a dimension of any arrays in this dataset, `squeeze`
controls whether the subarrays have a dimension of length 1 along
that dimension or if the dimension is squeezed out.
restore_coord_dims : bool, default: False
If True, also restore the dimension order of multi-dimensional
coordinates.
**groupers : Mapping of hashable to Grouper or Resampler
Mapping of variable name to group by to ``Grouper`` or ``Resampler`` object.
**groupers : Mapping of str to Grouper or Resampler
Mapping of variable name to group by to :py:class:`Grouper` or :py:class:`Resampler` object.
One of ``group`` or ``groupers`` must be provided.
Only a single ``grouper`` is allowed at present.
Expand Down Expand Up @@ -6775,7 +6776,7 @@ def groupby(
_validate_groupby_squeeze(squeeze)

if isinstance(group, Mapping):
groupers = either_dict_or_kwargs(group, groupers, "groupby")
groupers = either_dict_or_kwargs(group, groupers, "groupby") # type: ignore
group = None

grouper: Grouper
Expand Down
15 changes: 8 additions & 7 deletions xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -10258,7 +10258,7 @@ def interp_calendar(
def groupby(
self,
group: (
Hashable | DataArray | IndexVariable | Mapping[Hashable, Grouper] | None
Hashable | DataArray | IndexVariable | Mapping[Any, Grouper] | None
) = None,
squeeze: bool | None = None,
restore_coord_dims: bool = False,
Expand All @@ -10268,18 +10268,19 @@ def groupby(
Parameters
----------
group : Hashable, DataArray or IndexVariable
group : Hashable or DataArray or IndexVariable or mapping of Hashable to Grouper
Array whose unique values should be used to group this array. If a
string, must be the name of a variable contained in this dataset.
Hashable, must be the name of a coordinate contained in this dataarray. If a dictionary,
must map an existing variable name to a :py:class:`Grouper` instance.
squeeze : bool, default: True
If "group" is a dimension of any arrays in this dataset, `squeeze`
controls whether the subarrays have a dimension of length 1 along
that dimension or if the dimension is squeezed out.
restore_coord_dims : bool, default: False
If True, also restore the dimension order of multi-dimensional
coordinates.
**groupers : Mapping of hashable to Grouper or Resampler
Mapping of variable name to group by to ``Grouper`` or ``Resampler`` object.
**groupers : Mapping of str to Grouper or Resampler
Mapping of variable name to group by to :py:class:`Grouper` or :py:class:`Resampler` object.
One of ``group`` or ``groupers`` must be provided.
Only a single ``grouper`` is allowed at present.
Expand Down Expand Up @@ -10318,7 +10319,7 @@ def groupby(
_validate_groupby_squeeze(squeeze)

if isinstance(group, Mapping):
groupers = either_dict_or_kwargs(group, groupers, "groupby")
groupers = either_dict_or_kwargs(group, groupers, "groupby") # type: ignore
group = None

if group is not None:
Expand Down Expand Up @@ -10613,7 +10614,7 @@ def coarsen(

def resample(
self,
indexer: Mapping[Hashable, str | Resampler] | None = None,
indexer: Mapping[Any, str | Resampler] | None = None,
skipna: bool | None = None,
closed: SideOptions | None = None,
label: SideOptions | None = None,
Expand Down

0 comments on commit 1142663

Please sign in to comment.