Skip to content
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: 2 additions & 0 deletions xarray/core/concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ def _calc_concat_dim_coord(dim):
(dim,) = coord.dims
else:
coord = dim
if coord.name is None:
coord.name = dim.dims[0]
(dim,) = coord.dims
return dim, coord

Expand Down
9 changes: 9 additions & 0 deletions xarray/tests/test_concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,15 @@ def test_concat_str_dtype(self, dtype, dim):

assert np.issubdtype(actual.x2.dtype, dtype)

def test_concat_coord_name(self):

da = DataArray([0], dims="a")
da_concat = concat([da, da], dim=DataArray([0, 1], dims="b"))
assert list(da_concat.coords) == ["b"]

da_concat_std = concat([da, da], dim=DataArray([0, 1]))
assert list(da_concat_std.coords) == ["dim_0"]


@pytest.mark.parametrize("attr1", ({"a": {"meta": [10, 20, 30]}}, {"a": [1, 2, 3]}, {}))
@pytest.mark.parametrize("attr2", ({"a": [1, 2, 3]}, {}))
Expand Down