From 608526032eb2a5508cfc1ce1a923e9cb99811982 Mon Sep 17 00:00:00 2001 From: Thomas Nicholas Date: Thu, 30 Sep 2021 13:00:08 -0400 Subject: [PATCH 01/17] fixed bug --- xarray/core/combine.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xarray/core/combine.py b/xarray/core/combine.py index 2ee7763ccd7..5a260753e55 100644 --- a/xarray/core/combine.py +++ b/xarray/core/combine.py @@ -901,6 +901,9 @@ def combine_by_coords( return DataArray()._from_temp_dataset(combined_temp_dataset) else: + # Promote any named DataArrays to single-variable Datasets to simplify combining + data_objects = [obj.to_dataset() if isinstance(obj, DataArray) else obj for obj in data_objects] + # Group by data vars sorted_datasets = sorted(data_objects, key=vars_as_keys) grouped_by_vars = itertools.groupby(sorted_datasets, key=vars_as_keys) From 4d9e781aa977c1f36ad1f460c4942cc7035f4e69 Mon Sep 17 00:00:00 2001 From: Thomas Nicholas Date: Thu, 30 Sep 2021 13:12:06 -0400 Subject: [PATCH 02/17] added tests + reorganised slightly --- xarray/tests/test_combine.py | 62 ++++++++++++++++++++++++++++-------- 1 file changed, 49 insertions(+), 13 deletions(-) diff --git a/xarray/tests/test_combine.py b/xarray/tests/test_combine.py index cbe09aab815..d1d043ed064 100644 --- a/xarray/tests/test_combine.py +++ b/xarray/tests/test_combine.py @@ -688,7 +688,7 @@ def test_nested_combine_mixed_datasets_arrays(self): combine_nested(objs, "x") -class TestCombineAuto: +class TestCombineDatasetsbyCoords: def test_combine_by_coords(self): objs = [Dataset({"x": [0]}), Dataset({"x": [1]})] actual = combine_by_coords(objs) @@ -730,17 +730,6 @@ def test_combine_by_coords(self): def test_empty_input(self): assert_identical(Dataset(), combine_by_coords([])) - def test_combine_coords_mixed_datasets_arrays(self): - objs = [ - DataArray([0, 1], dims=("x"), coords=({"x": [0, 1]})), - Dataset({"x": [2, 3]}), - ] - with pytest.raises( - ValueError, - match=r"Can't automatically combine datasets with unnamed arrays.", - ): - combine_by_coords(objs) - @pytest.mark.parametrize( "join, expected", [ @@ -1044,7 +1033,35 @@ def test_combine_by_coords_incomplete_hypercube(self): with pytest.raises(ValueError): combine_by_coords([x1, x2, x3], fill_value=None) - def test_combine_by_coords_unnamed_arrays(self): + +class TestCombineMixedObjectsbyCoords: + def test_combine_by_coords_mixed_unnamed_dataarrays(self): + named_da = DataArray(name="a", data=[1.0, 2.0], coords={"x": [0, 1]}, dims="x") + unnamed_da = DataArray(data=[3.0, 4.0], coords={"x": [2, 3]}, dims="x") + + with pytest.raises( + ValueError, match="Can't automatically combine unnamed dataarrays with" + ): + combine_by_coords([named_da, unnamed_da]) + + da = DataArray([0, 1], dims="x", coords=({"x": [0, 1]})) + ds = Dataset({"x": [2, 3]}) + with pytest.raises( + ValueError, + match="Can't automatically combine unnamed dataarrays with", + ): + combine_by_coords([da, ds]) + + def test_combine_coords_mixed_datasets_named_dataarrays(self): + da = DataArray(name="a", data=[4, 5], dims="x", coords=({"x": [0, 1]})) + ds = Dataset({"b": ("x", [2, 3])}) + actual = combine_by_coords([da, ds]) + expected = Dataset( + {"a": ("x", [4, 5]), "b": ("x", [2, 3])}, coords={"x": ("x", [0, 1])} + ) + assert_identical(expected, actual) + + def test_combine_by_coords_all_unnamed_dataarrays(self): unnamed_array = DataArray(data=[1.0, 2.0], coords={"x": [0, 1]}, dims="x") actual = combine_by_coords([unnamed_array]) @@ -1060,6 +1077,25 @@ def test_combine_by_coords_unnamed_arrays(self): ) assert_identical(expected, actual) + def test_combine_by_coords_all_named_dataarrays(self): + named_da = DataArray(name="a", data=[1.0, 2.0], coords={"x": [0, 1]}, dims="x") + + actual = combine_by_coords([named_da]) + expected = named_da.to_dataset() + assert_identical(expected, actual) + + named_da1 = DataArray(name="a", data=[1.0, 2.0], coords={"x": [0, 1]}, dims="x") + named_da2 = DataArray(name="b", data=[3.0, 4.0], coords={"x": [2, 3]}, dims="x") + + actual = combine_by_coords([named_da1, named_da2]) + expected = Dataset( + { + "a": DataArray(data=[1.0, 2.0], coords={"x": [0, 1]}, dims="x"), + "b": DataArray(data=[3.0, 4.0], coords={"x": [2, 3]}, dims="x"), + } + ) + assert_identical(expected, actual) + @requires_cftime def test_combine_by_coords_distant_cftime_dates(): From 8d81ad3603dcb3154eb3dad316cdbf0f600d5cdd Mon Sep 17 00:00:00 2001 From: Thomas Nicholas Date: Thu, 30 Sep 2021 13:12:37 -0400 Subject: [PATCH 03/17] clarified logic for dealing with mixed sets of objects --- xarray/core/combine.py | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/xarray/core/combine.py b/xarray/core/combine.py index 5a260753e55..f2b51a11f1b 100644 --- a/xarray/core/combine.py +++ b/xarray/core/combine.py @@ -874,12 +874,13 @@ def combine_by_coords( if not data_objects: return Dataset() + """ mixed_arrays_and_datasets = any( isinstance(data_object, DataArray) and data_object.name is None for data_object in data_objects ) and any(isinstance(data_object, Dataset) for data_object in data_objects) if mixed_arrays_and_datasets: - raise ValueError("Can't automatically combine datasets with unnamed arrays.") + raise ValueError("Can't automatically combine datasets with unnamed dataarrays.") all_unnamed_data_arrays = all( isinstance(data_object, DataArray) and data_object.name is None @@ -899,10 +900,42 @@ def combine_by_coords( combine_attrs=combine_attrs, ) return DataArray()._from_temp_dataset(combined_temp_dataset) + """ + objs_are_unnamed_dataarrays = [ + isinstance(data_object, DataArray) and data_object.name is None + for data_object in data_objects + ] + if any(objs_are_unnamed_dataarrays): + if all(objs_are_unnamed_dataarrays): + # Combine into a single larger DataArray + unnamed_arrays = data_objects + temp_datasets = [ + data_array._to_temp_dataset() for data_array in unnamed_arrays + ] + + combined_temp_dataset = _combine_single_variable_hypercube( + temp_datasets, + fill_value=fill_value, + data_vars=data_vars, + coords=coords, + compat=compat, + join=join, + combine_attrs=combine_attrs, + ) + return DataArray()._from_temp_dataset(combined_temp_dataset) + else: + # Must be a mix of unnamed dataarrays with either named dataarrays or with datasets + # Can't combine these as we wouldn't know whether to merge or concatenate the arrays + raise ValueError( + "Can't automatically combine unnamed dataarrays with either named dataarrays or datasets." + ) else: # Promote any named DataArrays to single-variable Datasets to simplify combining - data_objects = [obj.to_dataset() if isinstance(obj, DataArray) else obj for obj in data_objects] + data_objects = [ + obj.to_dataset() if isinstance(obj, DataArray) else obj + for obj in data_objects + ] # Group by data vars sorted_datasets = sorted(data_objects, key=vars_as_keys) From 9056dbc39190eb5bc616ebb3f72ee9434cf2bd25 Mon Sep 17 00:00:00 2001 From: Thomas Nicholas Date: Thu, 30 Sep 2021 17:25:39 -0400 Subject: [PATCH 04/17] removed commented out old code --- xarray/core/combine.py | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/xarray/core/combine.py b/xarray/core/combine.py index c21f9782f50..7409a1ba3f4 100644 --- a/xarray/core/combine.py +++ b/xarray/core/combine.py @@ -883,34 +883,6 @@ def combine_by_coords( if not data_objects: return Dataset() - """ - mixed_arrays_and_datasets = any( - isinstance(data_object, DataArray) and data_object.name is None - for data_object in data_objects - ) and any(isinstance(data_object, Dataset) for data_object in data_objects) - if mixed_arrays_and_datasets: - raise ValueError("Can't automatically combine datasets with unnamed dataarrays.") - - all_unnamed_data_arrays = all( - isinstance(data_object, DataArray) and data_object.name is None - for data_object in data_objects - ) - if all_unnamed_data_arrays: - unnamed_arrays = data_objects - temp_datasets = [data_array._to_temp_dataset() for data_array in unnamed_arrays] - - combined_temp_dataset = _combine_single_variable_hypercube( - temp_datasets, - fill_value=fill_value, - data_vars=data_vars, - coords=coords, - compat=compat, - join=join, - combine_attrs=combine_attrs, - ) - return DataArray()._from_temp_dataset(combined_temp_dataset) - """ - objs_are_unnamed_dataarrays = [ isinstance(data_object, DataArray) and data_object.name is None for data_object in data_objects From a5a94518c8b5064212f19ae6a056c217e9c3c532 Mon Sep 17 00:00:00 2001 From: Thomas Nicholas Date: Thu, 30 Sep 2021 17:32:44 -0400 Subject: [PATCH 05/17] recorded bugfix in whatsnew --- doc/whats-new.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 7e006e875e2..799a84410fa 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -62,9 +62,10 @@ Bug fixes - Fixed performance bug where ``cftime`` import attempted within various core operations if ``cftime`` not installed (:pull:`5640`). By `Luke Sewell `_ - - Numbers are properly formatted in a plot's title (:issue:`5788`, :pull:`5789`). By `Maxime Liquet `_. +- Fixed bug when combining named DataArrays using :py:meth:`combine_by_coords`. (:pull:`5834`). + By `Tom Nicholas `_. Documentation ~~~~~~~~~~~~~ From 7aa7a808f88cf81a3f4dd3f20acf978ca83ecd1b Mon Sep 17 00:00:00 2001 From: Tom Nicholas <35968931+TomNicholas@users.noreply.github.com> Date: Fri, 29 Oct 2021 11:08:04 -0400 Subject: [PATCH 06/17] Update doc/whats-new.rst Co-authored-by: Mathias Hauser --- doc/whats-new.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 799a84410fa..e4cf2e3b460 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -64,7 +64,7 @@ Bug fixes By `Luke Sewell `_ - Numbers are properly formatted in a plot's title (:issue:`5788`, :pull:`5789`). By `Maxime Liquet `_. -- Fixed bug when combining named DataArrays using :py:meth:`combine_by_coords`. (:pull:`5834`). +- Fixed bug when combining named DataArrays using :py:func:`combine_by_coords`. (:pull:`5834`). By `Tom Nicholas `_. Documentation From 7805bb46e4df5cd2b91b57a59125dd3c0f2d1762 Mon Sep 17 00:00:00 2001 From: Tom Nicholas <35968931+TomNicholas@users.noreply.github.com> Date: Fri, 29 Oct 2021 11:08:11 -0400 Subject: [PATCH 07/17] Update xarray/core/combine.py Co-authored-by: Mathias Hauser --- xarray/core/combine.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xarray/core/combine.py b/xarray/core/combine.py index 7409a1ba3f4..d95ba830085 100644 --- a/xarray/core/combine.py +++ b/xarray/core/combine.py @@ -909,7 +909,7 @@ def combine_by_coords( # Must be a mix of unnamed dataarrays with either named dataarrays or with datasets # Can't combine these as we wouldn't know whether to merge or concatenate the arrays raise ValueError( - "Can't automatically combine unnamed dataarrays with either named dataarrays or datasets." + "Can't automatically combine unnamed DataArrays with either named DataArrays or Datasets." ) else: # Promote any named DataArrays to single-variable Datasets to simplify combining From 61c6021bb246b38aca1cba492bd429576ca5be6e Mon Sep 17 00:00:00 2001 From: Thomas Nicholas Date: Fri, 29 Oct 2021 11:14:42 -0400 Subject: [PATCH 08/17] removed pointless renaming --- xarray/core/combine.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xarray/core/combine.py b/xarray/core/combine.py index d95ba830085..eaa5343ddf6 100644 --- a/xarray/core/combine.py +++ b/xarray/core/combine.py @@ -890,9 +890,9 @@ def combine_by_coords( if any(objs_are_unnamed_dataarrays): if all(objs_are_unnamed_dataarrays): # Combine into a single larger DataArray - unnamed_arrays = data_objects temp_datasets = [ - data_array._to_temp_dataset() for data_array in unnamed_arrays + unnamed_dataarray._to_temp_dataset() + for unnamed_dataarray in data_objects ] combined_temp_dataset = _combine_single_variable_hypercube( From 35a65cd8fd93687e42c15462c8a97766646f1b26 Mon Sep 17 00:00:00 2001 From: Thomas Nicholas Date: Fri, 29 Oct 2021 11:19:30 -0400 Subject: [PATCH 09/17] update tests to look for capitalized error message --- xarray/tests/test_combine.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xarray/tests/test_combine.py b/xarray/tests/test_combine.py index d1d043ed064..b95325cb361 100644 --- a/xarray/tests/test_combine.py +++ b/xarray/tests/test_combine.py @@ -1040,7 +1040,7 @@ def test_combine_by_coords_mixed_unnamed_dataarrays(self): unnamed_da = DataArray(data=[3.0, 4.0], coords={"x": [2, 3]}, dims="x") with pytest.raises( - ValueError, match="Can't automatically combine unnamed dataarrays with" + ValueError, match="Can't automatically combine unnamed DataArrays with" ): combine_by_coords([named_da, unnamed_da]) @@ -1048,7 +1048,7 @@ def test_combine_by_coords_mixed_unnamed_dataarrays(self): ds = Dataset({"x": [2, 3]}) with pytest.raises( ValueError, - match="Can't automatically combine unnamed dataarrays with", + match="Can't automatically combine unnamed DataArrays with", ): combine_by_coords([da, ds]) From 75c4a91afb98d71b9d8c8fa8c6e476920dbe0c8e Mon Sep 17 00:00:00 2001 From: Thomas Nicholas Date: Fri, 29 Oct 2021 11:29:46 -0400 Subject: [PATCH 10/17] clarified return type in docstring --- xarray/core/combine.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xarray/core/combine.py b/xarray/core/combine.py index eaa5343ddf6..08dbef03b2c 100644 --- a/xarray/core/combine.py +++ b/xarray/core/combine.py @@ -673,7 +673,7 @@ def combine_by_coords( Attempt to auto-magically combine the given datasets (or data arrays) into one by using dimension coordinates. - This method attempts to combine a group of datasets along any number of + This function attempts to combine a group of datasets along any number of dimensions into a single entity by inspecting coords and metadata and using a combination of concat and merge. @@ -765,6 +765,8 @@ def combine_by_coords( Returns ------- combined : xarray.Dataset or xarray.DataArray + Will return a Dataset unless all the inputs are unnamed DataArrays, in which case a + DataArray will be returned. See also -------- From e3b71f4a7eee61f5ce1b0b0c0043eb351805a008 Mon Sep 17 00:00:00 2001 From: Thomas Nicholas Date: Fri, 29 Oct 2021 11:33:48 -0400 Subject: [PATCH 11/17] added test for combining two dataarrays with the same name --- xarray/tests/test_combine.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/xarray/tests/test_combine.py b/xarray/tests/test_combine.py index b95325cb361..504fb889a96 100644 --- a/xarray/tests/test_combine.py +++ b/xarray/tests/test_combine.py @@ -12,6 +12,7 @@ combine_by_coords, combine_nested, concat, + merge, ) from xarray.core import dtypes from xarray.core.combine import ( @@ -1096,6 +1097,15 @@ def test_combine_by_coords_all_named_dataarrays(self): ) assert_identical(expected, actual) + def test_combine_by_coords_all_dataarrays_with_the_same_name(self): + named_da1 = DataArray(name="a", data=[1.0, 2.0], coords={"x": [0, 1]}, dims="x") + named_da2 = DataArray(name="a", data=[3.0, 4.0], coords={"x": [2, 3]}, dims="x") + + actual = combine_by_coords([named_da1, named_da2]) + print(actual) + expected = merge([named_da1, named_da2]) + assert_identical(expected, actual) + @requires_cftime def test_combine_by_coords_distant_cftime_dates(): From 38f20529903e5834bbb49e4da6a63c0cf4d62287 Mon Sep 17 00:00:00 2001 From: Tom Nicholas <35968931+TomNicholas@users.noreply.github.com> Date: Fri, 29 Oct 2021 11:53:12 -0400 Subject: [PATCH 12/17] Update xarray/tests/test_combine.py Co-authored-by: Deepak Cherian --- xarray/tests/test_combine.py | 1 - 1 file changed, 1 deletion(-) diff --git a/xarray/tests/test_combine.py b/xarray/tests/test_combine.py index 504fb889a96..8d0c09eacec 100644 --- a/xarray/tests/test_combine.py +++ b/xarray/tests/test_combine.py @@ -1102,7 +1102,6 @@ def test_combine_by_coords_all_dataarrays_with_the_same_name(self): named_da2 = DataArray(name="a", data=[3.0, 4.0], coords={"x": [2, 3]}, dims="x") actual = combine_by_coords([named_da1, named_da2]) - print(actual) expected = merge([named_da1, named_da2]) assert_identical(expected, actual) From d815cf87c41831a913349428454324cfd056d4f9 Mon Sep 17 00:00:00 2001 From: Tom Nicholas <35968931+TomNicholas@users.noreply.github.com> Date: Fri, 29 Oct 2021 11:53:50 -0400 Subject: [PATCH 13/17] Update doc/whats-new.rst Co-authored-by: Deepak Cherian --- doc/whats-new.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 50cbd4e3bc6..6de7d61dad4 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -76,8 +76,6 @@ Bug fixes - Fixed performance bug where ``cftime`` import attempted within various core operations if ``cftime`` not installed (:pull:`5640`). By `Luke Sewell `_ -- Numbers are properly formatted in a plot's title (:issue:`5788`, :pull:`5789`). - By `Maxime Liquet `_. - Fixed bug when combining named DataArrays using :py:func:`combine_by_coords`. (:pull:`5834`). By `Tom Nicholas `_. - When a custom engine was used in :py:func:`~xarray.open_dataset` the engine From 40c6b771a35c4ec8726a57847b38fa72709f8840 Mon Sep 17 00:00:00 2001 From: Thomas Nicholas Date: Fri, 29 Oct 2021 13:24:03 -0400 Subject: [PATCH 14/17] added examples to docstrings --- xarray/core/combine.py | 43 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/xarray/core/combine.py b/xarray/core/combine.py index 08dbef03b2c..9a33de184a2 100644 --- a/xarray/core/combine.py +++ b/xarray/core/combine.py @@ -872,6 +872,49 @@ def combine_by_coords( Data variables: temperature (y, x) float64 10.98 14.3 12.06 nan ... 18.89 10.44 8.293 precipitation (y, x) float64 0.4376 0.8918 0.9637 ... 0.5684 0.01879 0.6176 + + You can also combine DataArray objects, but the behaviour will differ depending on + whether or not the DataArrays are named. If all DataArrays are named then they will + be promoted to Datasets before combining, and then the resultant Dataset will be + returned, e.g. + + >>> named_da1 = xr.DataArray( + ... name="a", data=[1.0, 2.0], coords={"x": [0, 1]}, dims="x" + ... ) + >>> named_da1 + + array([1., 2.]) + Coordinates: + * x (x) int64 0 1 + + >>> named_da2 = xr.DataArray( + ... name="a", data=[3.0, 4.0], coords={"x": [2, 3]}, dims="x" + ... ) + >>> named_da2 + + array([3., 4.]) + Coordinates: + * x (x) int64 2 3 + + >>> xr.combine_by_coords([named_da1, named_da2]) + + Dimensions: (x: 4) + Coordinates: + * x (x) int64 0 1 2 3 + Data variables: + a (x) float64 1.0 2.0 3.0 4.0 + + If all the DataArrays are unnamed, a single DataArray will be returned, e.g. + >>> unnamed_da1 = xr.DataArray(data=[1.0, 2.0], coords={"x": [0, 1]}, dims="x") + >>> unnamed_da2 = xr.DataArray(data=[3.0, 4.0], coords={"x": [2, 3]}, dims="x") + >>> xr.combine_by_coords([unnamed_da1, named_da2]) + + array([1., 2., 3., 4.]) + Coordinates: + * x (x) int64 0 1 2 3 + + Finally, if you attempt to combine a mix of unnamed DataArrays with either named + DataArrays or Datasets, a ValueError will be raised (as this is an ambiguous operation). """ # TODO remove after version 0.21, see PR4696 From 08f15afbb02b514d8ca0d54a280b2548564345b4 Mon Sep 17 00:00:00 2001 From: Thomas Nicholas Date: Fri, 29 Oct 2021 13:54:13 -0400 Subject: [PATCH 15/17] correct docstring example --- xarray/core/combine.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xarray/core/combine.py b/xarray/core/combine.py index 9a33de184a2..f76091aa637 100644 --- a/xarray/core/combine.py +++ b/xarray/core/combine.py @@ -907,7 +907,7 @@ def combine_by_coords( If all the DataArrays are unnamed, a single DataArray will be returned, e.g. >>> unnamed_da1 = xr.DataArray(data=[1.0, 2.0], coords={"x": [0, 1]}, dims="x") >>> unnamed_da2 = xr.DataArray(data=[3.0, 4.0], coords={"x": [2, 3]}, dims="x") - >>> xr.combine_by_coords([unnamed_da1, named_da2]) + >>> xr.combine_by_coords([unnamed_da1, unnamed_da2]) array([1., 2., 3., 4.]) Coordinates: From 65878e47bf55b27d9319fb1a815bd4e4af61a17d Mon Sep 17 00:00:00 2001 From: Thomas Nicholas Date: Fri, 29 Oct 2021 14:42:37 -0400 Subject: [PATCH 16/17] re-trigger CI From f475f444740496cc5a2208113988f09b70d90c0b Mon Sep 17 00:00:00 2001 From: Tom Nicholas <35968931+TomNicholas@users.noreply.github.com> Date: Fri, 29 Oct 2021 15:33:42 -0400 Subject: [PATCH 17/17] Update xarray/core/combine.py Co-authored-by: Illviljan <14371165+Illviljan@users.noreply.github.com> --- xarray/core/combine.py | 1 + 1 file changed, 1 insertion(+) diff --git a/xarray/core/combine.py b/xarray/core/combine.py index f76091aa637..081b53391ba 100644 --- a/xarray/core/combine.py +++ b/xarray/core/combine.py @@ -905,6 +905,7 @@ def combine_by_coords( a (x) float64 1.0 2.0 3.0 4.0 If all the DataArrays are unnamed, a single DataArray will be returned, e.g. + >>> unnamed_da1 = xr.DataArray(data=[1.0, 2.0], coords={"x": [0, 1]}, dims="x") >>> unnamed_da2 = xr.DataArray(data=[3.0, 4.0], coords={"x": [2, 3]}, dims="x") >>> xr.combine_by_coords([unnamed_da1, unnamed_da2])