Skip to content

Remove deprecated allow_lazy #4499

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 11, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 0 additions & 2 deletions xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -4271,7 +4271,6 @@ def reduce(
keep_attrs: bool = None,
keepdims: bool = False,
numeric_only: bool = False,
allow_lazy: bool = None,
**kwargs: Any,
) -> "Dataset":
"""Reduce this dataset by applying `func` along some dimension(s).
Expand Down Expand Up @@ -4346,7 +4345,6 @@ def reduce(
dim=reduce_dims,
keep_attrs=keep_attrs,
keepdims=keepdims,
allow_lazy=allow_lazy,
**kwargs,
)

Expand Down
15 changes: 2 additions & 13 deletions xarray/core/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,6 @@ def reduce(
axis=None,
keep_attrs=None,
keepdims=False,
allow_lazy=None,
**kwargs,
):
"""Reduce this array by applying `func` along some dimension(s).
Expand Down Expand Up @@ -1624,24 +1623,14 @@ def reduce(
if dim is not None:
axis = self.get_axis_num(dim)

if allow_lazy is not None:
warnings.warn(
"allow_lazy is deprecated and will be removed in version 0.16.0. It is now True by default.",
DeprecationWarning,
)
else:
allow_lazy = True

input_data = self.data if allow_lazy else self.values

with warnings.catch_warnings():
warnings.filterwarnings(
"ignore", r"Mean of empty slice", category=RuntimeWarning
)
if axis is not None:
data = func(input_data, axis=axis, **kwargs)
data = func(self.data, axis=axis, **kwargs)
else:
data = func(input_data, **kwargs)
data = func(self.data, **kwargs)

if getattr(data, "shape", ()) == self.shape:
dims = self.dims
Expand Down
4 changes: 0 additions & 4 deletions xarray/tests/test_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -1570,10 +1570,6 @@ def test_reduce(self):

with raises_regex(ValueError, "cannot supply both"):
v.mean(dim="x", axis=0)
with pytest.warns(DeprecationWarning, match="allow_lazy is deprecated"):
v.mean(dim="x", allow_lazy=True)
with pytest.warns(DeprecationWarning, match="allow_lazy is deprecated"):
v.mean(dim="x", allow_lazy=False)

@pytest.mark.parametrize("skipna", [True, False])
@pytest.mark.parametrize("q", [0.25, [0.50], [0.25, 0.75]])
Expand Down