Skip to content

Commit

Permalink
groupby, resample: Deprecate some positional args (#9236)
Browse files Browse the repository at this point in the history
* groupby, resample: Deprecate some positional args

* Change version to 2024.07.0
  • Loading branch information
dcherian authored Jul 19, 2024
1 parent 39d5b39 commit 07307b4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions xarray/core/dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -6694,11 +6694,13 @@ def interp_calendar(
"""
return interp_calendar(self, target, dim=dim)

@_deprecate_positional_args("v2024.07.0")
def groupby(
self,
group: (
Hashable | DataArray | IndexVariable | Mapping[Any, Grouper] | None
) = None,
*,
squeeze: bool | None = None,
restore_coord_dims: bool = False,
**groupers: Grouper,
Expand Down Expand Up @@ -6815,6 +6817,7 @@ def groupby(
restore_coord_dims=restore_coord_dims,
)

@_deprecate_positional_args("v2024.07.0")
def groupby_bins(
self,
group: Hashable | DataArray | IndexVariable,
Expand Down Expand Up @@ -7239,9 +7242,11 @@ def coarsen(
coord_func=coord_func,
)

@_deprecate_positional_args("v2024.07.0")
def resample(
self,
indexer: Mapping[Hashable, str | Resampler] | None = None,
*,
skipna: bool | None = None,
closed: SideOptions | None = None,
label: SideOptions | None = None,
Expand Down
5 changes: 5 additions & 0 deletions xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -10268,11 +10268,13 @@ def interp_calendar(
"""
return interp_calendar(self, target, dim=dim)

@_deprecate_positional_args("v2024.07.0")
def groupby(
self,
group: (
Hashable | DataArray | IndexVariable | Mapping[Any, Grouper] | None
) = None,
*,
squeeze: bool | None = None,
restore_coord_dims: bool = False,
**groupers: Grouper,
Expand Down Expand Up @@ -10356,6 +10358,7 @@ def groupby(
restore_coord_dims=restore_coord_dims,
)

@_deprecate_positional_args("v2024.07.0")
def groupby_bins(
self,
group: Hashable | DataArray | IndexVariable,
Expand Down Expand Up @@ -10625,9 +10628,11 @@ def coarsen(
coord_func=coord_func,
)

@_deprecate_positional_args("v2024.07.0")
def resample(
self,
indexer: Mapping[Any, str | Resampler] | None = None,
*,
skipna: bool | None = None,
closed: SideOptions | None = None,
label: SideOptions | None = None,
Expand Down
2 changes: 1 addition & 1 deletion xarray/tests/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ def test_groupby_reduce_dimension_error(array) -> None:

def test_groupby_multiple_string_args(array) -> None:
with pytest.raises(TypeError):
array.groupby("x", "y")
array.groupby("x", squeeze="y")


def test_groupby_bins_timeseries() -> None:
Expand Down

0 comments on commit 07307b4

Please sign in to comment.