Skip to content

Commit edcccdf

Browse files
committed
undo auto_combine deprecation.
1 parent d087fc5 commit edcccdf

File tree

4 files changed

+8
-120
lines changed

4 files changed

+8
-120
lines changed

xarray/backends/api.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from io import BytesIO
55
from numbers import Number
66
from pathlib import Path
7-
from textwrap import dedent
87
from typing import (
98
TYPE_CHECKING,
109
Callable,
@@ -714,7 +713,7 @@ def open_mfdataset(
714713
lock=None,
715714
data_vars="all",
716715
coords="different",
717-
combine="_old_auto",
716+
combine="auto",
718717
autoclose=None,
719718
parallel=False,
720719
join="outer",
@@ -910,20 +909,7 @@ def open_mfdataset(
910909

911910
# Combine all datasets, closing them in case of a ValueError
912911
try:
913-
if combine == "_old_auto":
914-
# Use the old auto_combine for now
915-
# Remove this after deprecation cycle from #2616 is complete
916-
basic_msg = dedent(
917-
"""\
918-
In xarray version 0.13 the default behaviour of `open_mfdataset`
919-
will change. To retain the existing behavior, pass
920-
combine='nested'. To use future default behavior, pass
921-
combine='by_coords'. See
922-
http://xarray.pydata.org/en/stable/combining.html#combining-multi
923-
"""
924-
)
925-
warnings.warn(basic_msg, FutureWarning, stacklevel=2)
926-
912+
if combine == "auto":
927913
combined = auto_combine(
928914
datasets,
929915
concat_dim=concat_dim,

xarray/core/combine.py

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -713,21 +713,13 @@ def auto_combine(
713713
Dataset.merge
714714
"""
715715

716-
if not from_openmfds:
717-
basic_msg = dedent(
718-
"""\
719-
In xarray version 0.13 `auto_combine` will be deprecated. See
720-
http://xarray.pydata.org/en/stable/combining.html#combining-multi"""
721-
)
722-
warnings.warn(basic_msg, FutureWarning, stacklevel=2)
723-
724716
if concat_dim == "_not_supplied":
725717
concat_dim = _CONCAT_DIM_DEFAULT
726718
message = ""
727719
else:
728720
message = dedent(
729721
"""\
730-
Also `open_mfdataset` will no longer accept a `concat_dim` argument.
722+
`open_mfdataset` will no longer accept a `concat_dim` argument.
731723
To get equivalent behaviour from now on please use the new
732724
`combine_nested` function instead (or the `combine='nested'` option to
733725
`open_mfdataset`)."""
@@ -753,24 +745,9 @@ def auto_combine(
753745
`combine='nested'` option to open_mfdataset."""
754746
)
755747

756-
if _requires_concat_and_merge(datasets):
757-
manual_dims = [concat_dim].append(None)
758-
message += dedent(
759-
"""\
760-
The datasets supplied require both concatenation and merging. From
761-
xarray version 0.13 this will operation will require either using the
762-
new `combine_nested` function (or the `combine='nested'` option to
763-
open_mfdataset), with a nested list structure such that you can combine
764-
along the dimensions {}. Alternatively if your datasets have global
765-
dimension coordinates then you can use the new `combine_by_coords`
766-
function.""".format(
767-
manual_dims
768-
)
769-
)
770-
771748
warnings.warn(message, FutureWarning, stacklevel=2)
772749

773-
return _old_auto_combine(
750+
return _auto_combine(
774751
datasets,
775752
concat_dim=concat_dim,
776753
compat=compat,
@@ -816,7 +793,7 @@ def _requires_concat_and_merge(datasets):
816793
return len(list(grouped_by_vars)) > 1
817794

818795

819-
def _old_auto_combine(
796+
def _auto_combine(
820797
datasets,
821798
concat_dim=_CONCAT_DIM_DEFAULT,
822799
compat="no_conflicts",

xarray/tests/test_backends.py

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -3061,73 +3061,6 @@ def test_load_dataarray(self):
30613061
ds.to_netcdf(tmp)
30623062

30633063

3064-
@requires_scipy_or_netCDF4
3065-
@requires_dask
3066-
class TestOpenMFDataSetDeprecation:
3067-
"""
3068-
Set of tests to check that FutureWarnings are correctly raised until the
3069-
deprecation cycle is complete. #2616
3070-
"""
3071-
3072-
def test_open_mfdataset_default(self):
3073-
ds1, ds2 = Dataset({"x": [0]}), Dataset({"x": [1]})
3074-
with create_tmp_file() as tmp1:
3075-
with create_tmp_file() as tmp2:
3076-
ds1.to_netcdf(tmp1)
3077-
ds2.to_netcdf(tmp2)
3078-
3079-
with pytest.warns(
3080-
FutureWarning, match="default behaviour of" " `open_mfdataset`"
3081-
):
3082-
open_mfdataset([tmp1, tmp2])
3083-
3084-
def test_open_mfdataset_with_concat_dim(self):
3085-
ds1, ds2 = Dataset({"x": [0]}), Dataset({"x": [1]})
3086-
with create_tmp_file() as tmp1:
3087-
with create_tmp_file() as tmp2:
3088-
ds1.to_netcdf(tmp1)
3089-
ds2.to_netcdf(tmp2)
3090-
3091-
with pytest.warns(FutureWarning, match="`concat_dim`"):
3092-
open_mfdataset([tmp1, tmp2], concat_dim="x")
3093-
3094-
def test_auto_combine_with_merge_and_concat(self):
3095-
ds1, ds2 = Dataset({"x": [0]}), Dataset({"x": [1]})
3096-
ds3 = Dataset({"z": ((), 99)})
3097-
with create_tmp_file() as tmp1:
3098-
with create_tmp_file() as tmp2:
3099-
with create_tmp_file() as tmp3:
3100-
ds1.to_netcdf(tmp1)
3101-
ds2.to_netcdf(tmp2)
3102-
ds3.to_netcdf(tmp3)
3103-
3104-
with pytest.warns(
3105-
FutureWarning, match="require both concatenation"
3106-
):
3107-
open_mfdataset([tmp1, tmp2, tmp3])
3108-
3109-
def test_auto_combine_with_coords(self):
3110-
ds1 = Dataset({"foo": ("x", [0])}, coords={"x": ("x", [0])})
3111-
ds2 = Dataset({"foo": ("x", [1])}, coords={"x": ("x", [1])})
3112-
with create_tmp_file() as tmp1:
3113-
with create_tmp_file() as tmp2:
3114-
ds1.to_netcdf(tmp1)
3115-
ds2.to_netcdf(tmp2)
3116-
3117-
with pytest.warns(FutureWarning, match="supplied have global"):
3118-
open_mfdataset([tmp1, tmp2])
3119-
3120-
def test_auto_combine_without_coords(self):
3121-
ds1, ds2 = Dataset({"foo": ("x", [0])}), Dataset({"foo": ("x", [1])})
3122-
with create_tmp_file() as tmp1:
3123-
with create_tmp_file() as tmp2:
3124-
ds1.to_netcdf(tmp1)
3125-
ds2.to_netcdf(tmp2)
3126-
3127-
with pytest.warns(FutureWarning, match="supplied do not have global"):
3128-
open_mfdataset([tmp1, tmp2])
3129-
3130-
31313064
@requires_scipy_or_netCDF4
31323065
@requires_pydap
31333066
@pytest.mark.filterwarnings("ignore:The binary mode of fromstring is deprecated")

xarray/tests/test_combine.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ def test_combine_nested_fill_value(self, fill_value):
583583
assert_identical(expected, actual)
584584

585585

586-
class TestCombineAuto:
586+
class TestCombineCoords:
587587
def test_combine_by_coords(self):
588588
objs = [Dataset({"x": [0]}), Dataset({"x": [1]})]
589589
actual = combine_by_coords(objs)
@@ -713,12 +713,9 @@ def test_check_for_impossible_ordering(self):
713713
combine_by_coords([ds1, ds0])
714714

715715

716-
@pytest.mark.filterwarnings(
717-
"ignore:In xarray version 0.13 `auto_combine` " "will be deprecated"
718-
)
719-
@pytest.mark.filterwarnings("ignore:Also `open_mfdataset` will no longer")
716+
@pytest.mark.filterwarnings("ignore:`open_mfdataset` will no longer")
720717
@pytest.mark.filterwarnings("ignore:The datasets supplied")
721-
class TestAutoCombineOldAPI:
718+
class TestAutoCombine:
722719
"""
723720
Set of tests which check that old 1-dimensional auto_combine behaviour is
724721
still satisfied. #2616
@@ -862,11 +859,6 @@ def test_auto_combine_with_concat_dim(self):
862859
with pytest.warns(FutureWarning, match="`concat_dim`"):
863860
auto_combine(objs, concat_dim="x")
864861

865-
def test_auto_combine_with_merge_and_concat(self):
866-
objs = [Dataset({"x": [0]}), Dataset({"x": [1]}), Dataset({"z": ((), 99)})]
867-
with pytest.warns(FutureWarning, match="require both concatenation"):
868-
auto_combine(objs)
869-
870862
def test_auto_combine_with_coords(self):
871863
objs = [
872864
Dataset({"foo": ("x", [0])}, coords={"x": ("x", [0])}),

0 commit comments

Comments
 (0)