Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions doc/api-hidden.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
core.rolling.DatasetCoarsen.var
core.rolling.DatasetCoarsen.boundary
core.rolling.DatasetCoarsen.coord_func
core.rolling.DatasetCoarsen.keep_attrs
core.rolling.DatasetCoarsen.obj
core.rolling.DatasetCoarsen.side
core.rolling.DatasetCoarsen.trim_excess
Expand Down Expand Up @@ -120,7 +119,6 @@
core.rolling.DatasetRolling.var
core.rolling.DatasetRolling.center
core.rolling.DatasetRolling.dim
core.rolling.DatasetRolling.keep_attrs
core.rolling.DatasetRolling.min_periods
core.rolling.DatasetRolling.obj
core.rolling.DatasetRolling.rollings
Expand Down Expand Up @@ -199,7 +197,6 @@
core.rolling.DataArrayCoarsen.var
core.rolling.DataArrayCoarsen.boundary
core.rolling.DataArrayCoarsen.coord_func
core.rolling.DataArrayCoarsen.keep_attrs
core.rolling.DataArrayCoarsen.obj
core.rolling.DataArrayCoarsen.side
core.rolling.DataArrayCoarsen.trim_excess
Expand Down Expand Up @@ -263,7 +260,6 @@
core.rolling.DataArrayRolling.var
core.rolling.DataArrayRolling.center
core.rolling.DataArrayRolling.dim
core.rolling.DataArrayRolling.keep_attrs
core.rolling.DataArrayRolling.min_periods
core.rolling.DataArrayRolling.obj
core.rolling.DataArrayRolling.window
Expand Down
7 changes: 7 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ Breaking changes
Deprecations
~~~~~~~~~~~~

- Removed the deprecated ``dim`` kwarg to :py:func:`DataArray.integrate` (:pull:`5630`)
- Removed the deprecated ``keep_attrs`` kwarg to :py:func:`DataArray.rolling` (:pull:`5630`)
- Removed the deprecated ``keep_attrs`` kwarg to :py:func:`DataArray.coarsen` (:pull:`5630`)
- Completed deprecation of passing an ``xarray.DataArray`` to :py:func:`Variable` - will now raise a ``TypeError`` (:pull:`5630`)
- Removed the deprecated return value of :py:func:`Dataset.update` (:pull:`5630`)
- Removed the deprecated lock kwarg to :py:func:`DataArray.open_dataset` (:pull:`5630`)
- Removed the deprecated datasets argument to :py:func:`combine_by_coords` (:pull:`5630`)

Bug fixes
~~~~~~~~~
Expand Down
13 changes: 1 addition & 12 deletions xarray/core/combine.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import itertools
import warnings
from collections import Counter

import pandas as pd
Expand Down Expand Up @@ -635,16 +634,14 @@ def _combine_single_variable_hypercube(
return concatenated


# TODO remove empty list default param after version 0.19, see PR4696
def combine_by_coords(
data_objects=[],
data_objects,
compat="no_conflicts",
data_vars="all",
coords="different",
fill_value=dtypes.NA,
join="outer",
combine_attrs="no_conflicts",
datasets=None,
):
"""
Attempt to auto-magically combine the given datasets (or data arrays)
Expand Down Expand Up @@ -849,14 +846,6 @@ def combine_by_coords(
precipitation (y, x) float64 0.4376 0.8918 0.9637 ... 0.5684 0.01879 0.6176
"""

# TODO remove after version 0.19, see PR4696
if datasets is not None:
warnings.warn(
"The datasets argument has been renamed to `data_objects`."
" In future passing a value for datasets will raise an error."
)
data_objects = datasets

if not data_objects:
return Dataset()

Expand Down
7 changes: 1 addition & 6 deletions xarray/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,6 @@ def rolling(
dim: Mapping[Hashable, int] = None,
min_periods: int = None,
center: Union[bool, Mapping[Hashable, bool]] = False,
keep_attrs: bool = None,
**window_kwargs: int,
):
"""
Expand Down Expand Up @@ -889,9 +888,7 @@ def rolling(
"""

dim = either_dict_or_kwargs(dim, window_kwargs, "rolling")
return self._rolling_cls(
self, dim, min_periods=min_periods, center=center, keep_attrs=keep_attrs
)
return self._rolling_cls(self, dim, min_periods=min_periods, center=center)

def rolling_exp(
self,
Expand Down Expand Up @@ -940,7 +937,6 @@ def coarsen(
boundary: str = "exact",
side: Union[str, Mapping[Hashable, str]] = "left",
coord_func: str = "mean",
keep_attrs: bool = None,
**window_kwargs: int,
):
"""
Expand Down Expand Up @@ -1009,7 +1005,6 @@ def coarsen(
boundary=boundary,
side=side,
coord_func=coord_func,
keep_attrs=keep_attrs,
)

def resample(
Expand Down
19 changes: 0 additions & 19 deletions xarray/core/dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -3540,8 +3540,6 @@ def integrate(
self,
coord: Union[Hashable, Sequence[Hashable]] = None,
datetime_unit: str = None,
*,
dim: Union[Hashable, Sequence[Hashable]] = None,
) -> "DataArray":
"""Integrate along the given coordinate using the trapezoidal rule.

Expand All @@ -3553,8 +3551,6 @@ def integrate(
----------
coord : hashable, or sequence of hashable
Coordinate(s) used for the integration.
dim : hashable, or sequence of hashable
Coordinate(s) used for the integration.
datetime_unit : {'Y', 'M', 'W', 'D', 'h', 'm', 's', 'ms', 'us', 'ns', \
'ps', 'fs', 'as'}, optional
Specify the unit if a datetime coordinate is used.
Expand Down Expand Up @@ -3591,21 +3587,6 @@ def integrate(
array([5.4, 6.6, 7.8])
Dimensions without coordinates: y
"""
if dim is not None and coord is not None:
raise ValueError(
"Cannot pass both 'dim' and 'coord'. Please pass only 'coord' instead."
)

if dim is not None and coord is None:
coord = dim
msg = (
"The `dim` keyword argument to `DataArray.integrate` is "
"being replaced with `coord`, for consistency with "
"`Dataset.integrate`. Please pass `coord` instead."
" `dim` will be removed in version 0.19.0."
)
warnings.warn(msg, FutureWarning, stacklevel=2)

ds = self._to_temp_dataset().integrate(coord, datetime_unit)
return self._from_temp_dataset(ds)

Expand Down
12 changes: 2 additions & 10 deletions xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -4157,7 +4157,7 @@ def unstack(
result = result._unstack_once(dim, fill_value)
return result

def update(self, other: "CoercibleMapping") -> "Dataset":
def update(self, other: "CoercibleMapping") -> None:
"""Update this dataset's variables with those from another dataset.

Just like :py:meth:`dict.update` this is a in-place operation.
Expand All @@ -4173,14 +4173,6 @@ def update(self, other: "CoercibleMapping") -> "Dataset":
- mapping {var name: (dimension name, array-like)}
- mapping {var name: (tuple of dimension names, array-like)}

Returns
-------
updated : Dataset
Updated dataset. Note that since the update is in-place this is the input
dataset.

It is deprecated since version 0.17 and scheduled to be removed in 0.19.

Raises
------
ValueError
Expand All @@ -4192,7 +4184,7 @@ def update(self, other: "CoercibleMapping") -> "Dataset":
Dataset.assign
"""
merge_result = dataset_update_method(self, other)
return self._replace(inplace=True, **merge_result._asdict())
self._replace(inplace=True, **merge_result._asdict())

def merge(
self,
Expand Down
57 changes: 10 additions & 47 deletions xarray/core/rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ class Rolling:
xarray.DataArray.rolling
"""

__slots__ = ("obj", "window", "min_periods", "center", "dim", "keep_attrs")
_attributes = ("window", "min_periods", "center", "dim", "keep_attrs")
__slots__ = ("obj", "window", "min_periods", "center", "dim")
_attributes = ("window", "min_periods", "center", "dim")

def __init__(self, obj, windows, min_periods=None, center=False, keep_attrs=None):
def __init__(self, obj, windows, min_periods=None, center=False):
"""
Moving window object.

Expand Down Expand Up @@ -89,15 +89,6 @@ def __init__(self, obj, windows, min_periods=None, center=False, keep_attrs=None

self.min_periods = np.prod(self.window) if min_periods is None else min_periods

if keep_attrs is not None:
warnings.warn(
"Passing ``keep_attrs`` to ``rolling`` is deprecated and will raise an"
" error in xarray 0.18. Please pass ``keep_attrs`` directly to the"
" applied function. Note that keep_attrs is now True per default.",
FutureWarning,
)
self.keep_attrs = keep_attrs

def __repr__(self):
"""provide a nice str repr of our rolling object"""

Expand Down Expand Up @@ -188,23 +179,16 @@ def _mapping_to_list(
)

def _get_keep_attrs(self, keep_attrs):

if keep_attrs is None:
# TODO: uncomment the next line and remove the others after the deprecation
# keep_attrs = _get_keep_attrs(default=True)

if self.keep_attrs is None:
keep_attrs = _get_keep_attrs(default=True)
else:
keep_attrs = self.keep_attrs
keep_attrs = _get_keep_attrs(default=True)

return keep_attrs


class DataArrayRolling(Rolling):
__slots__ = ("window_labels",)

def __init__(self, obj, windows, min_periods=None, center=False, keep_attrs=None):
def __init__(self, obj, windows, min_periods=None, center=False):
"""
Moving window object for DataArray.
You should use DataArray.rolling() method to construct this object
Expand Down Expand Up @@ -235,9 +219,7 @@ def __init__(self, obj, windows, min_periods=None, center=False, keep_attrs=None
xarray.Dataset.rolling
xarray.Dataset.groupby
"""
super().__init__(
obj, windows, min_periods=min_periods, center=center, keep_attrs=keep_attrs
)
super().__init__(obj, windows, min_periods=min_periods, center=center)

# TODO legacy attribute
self.window_labels = self.obj[self.dim[0]]
Expand Down Expand Up @@ -561,7 +543,7 @@ def _numpy_or_bottleneck_reduce(
class DatasetRolling(Rolling):
__slots__ = ("rollings",)

def __init__(self, obj, windows, min_periods=None, center=False, keep_attrs=None):
def __init__(self, obj, windows, min_periods=None, center=False):
"""
Moving window object for Dataset.
You should use Dataset.rolling() method to construct this object
Expand Down Expand Up @@ -592,7 +574,7 @@ def __init__(self, obj, windows, min_periods=None, center=False, keep_attrs=None
xarray.Dataset.groupby
xarray.DataArray.groupby
"""
super().__init__(obj, windows, min_periods, center, keep_attrs)
super().__init__(obj, windows, min_periods, center)
if any(d not in self.obj.dims for d in self.dim):
raise KeyError(self.dim)
# Keep each Rolling object as a dictionary
Expand Down Expand Up @@ -768,11 +750,10 @@ class Coarsen(CoarsenArithmetic):
"windows",
"side",
"trim_excess",
"keep_attrs",
)
_attributes = ("windows", "side", "trim_excess")

def __init__(self, obj, windows, boundary, side, coord_func, keep_attrs):
def __init__(self, obj, windows, boundary, side, coord_func):
"""
Moving window object.

Expand All @@ -799,17 +780,6 @@ def __init__(self, obj, windows, boundary, side, coord_func, keep_attrs):
self.side = side
self.boundary = boundary

if keep_attrs is not None:
warnings.warn(
"Passing ``keep_attrs`` to ``coarsen`` is deprecated and will raise an"
" error in xarray 0.19. Please pass ``keep_attrs`` directly to the"
" applied function, i.e. use ``ds.coarsen(...).mean(keep_attrs=False)``"
" instead of ``ds.coarsen(..., keep_attrs=False).mean()``"
" Note that keep_attrs is now True per default.",
FutureWarning,
)
self.keep_attrs = keep_attrs

absent_dims = [dim for dim in windows.keys() if dim not in self.obj.dims]
if absent_dims:
raise ValueError(
Expand All @@ -823,15 +793,8 @@ def __init__(self, obj, windows, boundary, side, coord_func, keep_attrs):
self.coord_func = coord_func

def _get_keep_attrs(self, keep_attrs):

if keep_attrs is None:
# TODO: uncomment the next line and remove the others after the deprecation
# keep_attrs = _get_keep_attrs(default=True)

if self.keep_attrs is None:
keep_attrs = _get_keep_attrs(default=True)
else:
keep_attrs = self.keep_attrs
keep_attrs = _get_keep_attrs(default=True)

return keep_attrs

Expand Down
11 changes: 3 additions & 8 deletions xarray/core/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,9 @@ def as_variable(obj, name=None) -> "Union[Variable, IndexVariable]":
obj = obj.copy(deep=False)
elif isinstance(obj, tuple):
if isinstance(obj[1], DataArray):
# TODO: change into TypeError
warnings.warn(
(
"Using a DataArray object to construct a variable is"
" ambiguous, please extract the data using the .data property."
" This will raise a TypeError in 0.19.0."
),
DeprecationWarning,
raise TypeError(
"Using a DataArray object to construct a variable is"
" ambiguous, please extract the data using the .data property."
)
try:
obj = Variable(*obj)
Expand Down
Loading