diff --git a/xarray/core/dataarray.py b/xarray/core/dataarray.py index ccfab2650a9..f91ab8c0b16 100644 --- a/xarray/core/dataarray.py +++ b/xarray/core/dataarray.py @@ -6694,11 +6694,13 @@ def interp_calendar( """ return interp_calendar(self, target, dim=dim) + @_deprecate_positional_args("v2024.08.0") def groupby( self, group: ( Hashable | DataArray | IndexVariable | Mapping[Any, Grouper] | None ) = None, + *, squeeze: bool | None = None, restore_coord_dims: bool = False, **groupers: Grouper, @@ -6815,6 +6817,7 @@ def groupby( restore_coord_dims=restore_coord_dims, ) + @_deprecate_positional_args("v2024.08.0") def groupby_bins( self, group: Hashable | DataArray | IndexVariable, @@ -7239,9 +7242,11 @@ def coarsen( coord_func=coord_func, ) + @_deprecate_positional_args("v2024.08.0") def resample( self, indexer: Mapping[Hashable, str | Resampler] | None = None, + *, skipna: bool | None = None, closed: SideOptions | None = None, label: SideOptions | None = None, diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py index 0540744739a..53b58928430 100644 --- a/xarray/core/dataset.py +++ b/xarray/core/dataset.py @@ -10263,11 +10263,13 @@ def interp_calendar( """ return interp_calendar(self, target, dim=dim) + @_deprecate_positional_args("v2024.08.0") def groupby( self, group: ( Hashable | DataArray | IndexVariable | Mapping[Any, Grouper] | None ) = None, + *, squeeze: bool | None = None, restore_coord_dims: bool = False, **groupers: Grouper, @@ -10351,6 +10353,7 @@ def groupby( restore_coord_dims=restore_coord_dims, ) + @_deprecate_positional_args("v2024.08.0") def groupby_bins( self, group: Hashable | DataArray | IndexVariable, @@ -10620,9 +10623,11 @@ def coarsen( coord_func=coord_func, ) + @_deprecate_positional_args("v2024.08.0") def resample( self, indexer: Mapping[Any, str | Resampler] | None = None, + *, skipna: bool | None = None, closed: SideOptions | None = None, label: SideOptions | None = None, diff --git a/xarray/tests/test_groupby.py b/xarray/tests/test_groupby.py index bd612decc52..6251580454d 100644 --- a/xarray/tests/test_groupby.py +++ b/xarray/tests/test_groupby.py @@ -722,7 +722,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: @@ -2408,25 +2408,6 @@ def test_resample_drop_nondim_coords(self) -> None: actual = ds.resample(time="1h").interpolate("linear") assert "tc" not in actual.coords - def test_resample_old_api(self) -> None: - times = pd.date_range("2000-01-01", freq="6h", periods=10) - ds = Dataset( - { - "foo": (["time", "x", "y"], np.random.randn(10, 5, 3)), - "bar": ("time", np.random.randn(10), {"meta": "data"}), - "time": times, - } - ) - - with pytest.raises(TypeError, match=r"resample\(\) no longer supports"): - ds.resample("1D", "time") # type: ignore[arg-type] - - with pytest.raises(TypeError, match=r"resample\(\) no longer supports"): - ds.resample("1D", dim="time", how="mean") # type: ignore[arg-type] - - with pytest.raises(TypeError, match=r"resample\(\) no longer supports"): - ds.resample("1D", dim="time") # type: ignore[arg-type] - def test_resample_ds_da_are_the_same(self) -> None: time = pd.date_range("2000-01-01", freq="6h", periods=365 * 4) ds = xr.Dataset(