Skip to content

Commit 3088de2

Browse files
TomNicholaskeewisdcherian
authored
Remove old auto combine (#3926)
* Removed auto_combine function and argument to open_mfdataset * Removed corresponding tests * Code formatting * updated what's new * PEP8 fixes * Update doc/whats-new.rst `:py:func:` links fixed Co-Authored-By: keewis <[email protected]> * removed auto_combine from API docs * clarify that auto_combine is completely removed * concat_dim=None by default for combine='nested' * fix black formatting Co-authored-by: keewis <[email protected]> Co-authored-by: dcherian <[email protected]>
1 parent 24d755d commit 3088de2

File tree

8 files changed

+34
-573
lines changed

8 files changed

+34
-573
lines changed

doc/api-hidden.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
.. autosummary::
1010
:toctree: generated/
1111

12-
auto_combine
13-
1412
Dataset.nbytes
1513
Dataset.chunks
1614

doc/api.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ Top-level functions
2121
broadcast
2222
concat
2323
merge
24-
auto_combine
2524
combine_by_coords
2625
combine_nested
2726
where

doc/whats-new.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ Breaking changes
3333
<https://matplotlib.org/api/prev_api_changes/api_changes_3.1.0.html#passing-a-line2d-s-drawstyle-together-with-the-linestyle-is-deprecated>`_.
3434
(:pull:`3274`)
3535
By `Elliott Sales de Andrade <https://github.com/QuLogic>`_
36+
- The old :py:func:`auto_combine` function has now been removed in
37+
favour of the :py:func:`combine_by_coords` and
38+
:py:func:`combine_nested` functions. This also means that
39+
the default behaviour of :py:func:`open_mfdataset` has changed to use
40+
``combine='by_coords'`` as the default argument value. (:issue:`2616`, :pull:`3926`)
41+
By `Tom Nicholas <https://github.com/TomNicholas>`_.
42+
3643

3744
Enhancements
3845
~~~~~~~~~~~~

xarray/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from .coding.frequencies import infer_freq
1717
from .conventions import SerializationWarning, decode_cf
1818
from .core.alignment import align, broadcast
19-
from .core.combine import auto_combine, combine_by_coords, combine_nested
19+
from .core.combine import combine_by_coords, combine_nested
2020
from .core.common import ALL_DIMS, full_like, ones_like, zeros_like
2121
from .core.computation import apply_ufunc, corr, cov, dot, polyval, where
2222
from .core.concat import concat
@@ -47,7 +47,6 @@
4747
"align",
4848
"apply_ufunc",
4949
"as_variable",
50-
"auto_combine",
5150
"broadcast",
5251
"cftime_range",
5352
"combine_by_coords",

xarray/backends/api.py

Lines changed: 16 additions & 45 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,
@@ -23,7 +22,6 @@
2322
from ..core.combine import (
2423
_infer_concat_order_from_positions,
2524
_nested_combine,
26-
auto_combine,
2725
combine_by_coords,
2826
)
2927
from ..core.dataarray import DataArray
@@ -726,14 +724,14 @@ def close(self):
726724
def open_mfdataset(
727725
paths,
728726
chunks=None,
729-
concat_dim="_not_supplied",
727+
concat_dim=None,
730728
compat="no_conflicts",
731729
preprocess=None,
732730
engine=None,
733731
lock=None,
734732
data_vars="all",
735733
coords="different",
736-
combine="_old_auto",
734+
combine="by_coords",
737735
autoclose=None,
738736
parallel=False,
739737
join="outer",
@@ -746,9 +744,8 @@ def open_mfdataset(
746744
the datasets into one before returning the result, and if combine='nested' then
747745
``combine_nested`` is used. The filepaths must be structured according to which
748746
combining function is used, the details of which are given in the documentation for
749-
``combine_by_coords`` and ``combine_nested``. By default the old (now deprecated)
750-
``auto_combine`` will be used, please specify either ``combine='by_coords'`` or
751-
``combine='nested'`` in future. Requires dask to be installed. See documentation for
747+
``combine_by_coords`` and ``combine_nested``. By default ``combine='by_coords'``
748+
will be used. Requires dask to be installed. See documentation for
752749
details on dask [1]_. Global attributes from the ``attrs_file`` are used
753750
for the combined dataset.
754751
@@ -758,7 +755,7 @@ def open_mfdataset(
758755
Either a string glob in the form ``"path/to/my/files/*.nc"`` or an explicit list of
759756
files to open. Paths can be given as strings or as pathlib Paths. If
760757
concatenation along more than one dimension is desired, then ``paths`` must be a
761-
nested list-of-lists (see ``manual_combine`` for details). (A string glob will
758+
nested list-of-lists (see ``combine_nested`` for details). (A string glob will
762759
be expanded to a 1-dimensional list.)
763760
chunks : int or dict, optional
764761
Dictionary with keys given by dimension names and values given by chunk sizes.
@@ -768,15 +765,16 @@ def open_mfdataset(
768765
see the full documentation for more details [2]_.
769766
concat_dim : str, or list of str, DataArray, Index or None, optional
770767
Dimensions to concatenate files along. You only need to provide this argument
771-
if any of the dimensions along which you want to concatenate is not a dimension
772-
in the original datasets, e.g., if you want to stack a collection of 2D arrays
773-
along a third dimension. Set ``concat_dim=[..., None, ...]`` explicitly to
774-
disable concatenation along a particular dimension.
768+
if ``combine='by_coords'``, and if any of the dimensions along which you want to
769+
concatenate is not a dimension in the original datasets, e.g., if you want to
770+
stack a collection of 2D arrays along a third dimension. Set
771+
``concat_dim=[..., None, ...]`` explicitly to disable concatenation along a
772+
particular dimension. Default is None, which for a 1D list of filepaths is
773+
equivalent to opening the files separately and then merging them with
774+
``xarray.merge``.
775775
combine : {'by_coords', 'nested'}, optional
776776
Whether ``xarray.combine_by_coords`` or ``xarray.combine_nested`` is used to
777-
combine all the data. If this argument is not provided, `xarray.auto_combine` is
778-
used, but in the future this behavior will switch to use
779-
`xarray.combine_by_coords` by default.
777+
combine all the data. Default is to use ``xarray.combine_by_coords``.
780778
compat : {'identical', 'equals', 'broadcast_equals',
781779
'no_conflicts', 'override'}, optional
782780
String indicating how to compare variables of the same name for
@@ -869,7 +867,6 @@ def open_mfdataset(
869867
--------
870868
combine_by_coords
871869
combine_nested
872-
auto_combine
873870
open_dataset
874871
875872
References
@@ -897,11 +894,8 @@ def open_mfdataset(
897894
# If combine='nested' then this creates a flat list which is easier to
898895
# iterate over, while saving the originally-supplied structure as "ids"
899896
if combine == "nested":
900-
if str(concat_dim) == "_not_supplied":
901-
raise ValueError("Must supply concat_dim when using " "combine='nested'")
902-
else:
903-
if isinstance(concat_dim, (str, DataArray)) or concat_dim is None:
904-
concat_dim = [concat_dim]
897+
if isinstance(concat_dim, (str, DataArray)) or concat_dim is None:
898+
concat_dim = [concat_dim]
905899
combined_ids_paths = _infer_concat_order_from_positions(paths)
906900
ids, paths = (list(combined_ids_paths.keys()), list(combined_ids_paths.values()))
907901

@@ -933,30 +927,7 @@ def open_mfdataset(
933927

934928
# Combine all datasets, closing them in case of a ValueError
935929
try:
936-
if combine == "_old_auto":
937-
# Use the old auto_combine for now
938-
# Remove this after deprecation cycle from #2616 is complete
939-
basic_msg = dedent(
940-
"""\
941-
In xarray version 0.15 the default behaviour of `open_mfdataset`
942-
will change. To retain the existing behavior, pass
943-
combine='nested'. To use future default behavior, pass
944-
combine='by_coords'. See
945-
http://xarray.pydata.org/en/stable/combining.html#combining-multi
946-
"""
947-
)
948-
warnings.warn(basic_msg, FutureWarning, stacklevel=2)
949-
950-
combined = auto_combine(
951-
datasets,
952-
concat_dim=concat_dim,
953-
compat=compat,
954-
data_vars=data_vars,
955-
coords=coords,
956-
join=join,
957-
from_openmfds=True,
958-
)
959-
elif combine == "nested":
930+
if combine == "nested":
960931
# Combined nested list by successive concat and merge operations
961932
# along each dimension, using structure given by "ids"
962933
combined = _nested_combine(

0 commit comments

Comments
 (0)