From a91e6ee2728bb5b2768184d4e0cf1c261113f93e Mon Sep 17 00:00:00 2001 From: Benoit Bovy Date: Sun, 20 Mar 2022 17:45:19 +0100 Subject: [PATCH] fix concat with scalar coordinate + test --- xarray/core/concat.py | 2 +- xarray/tests/test_concat.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/xarray/core/concat.py b/xarray/core/concat.py index 8ee4672c49a..6a0ca42e071 100644 --- a/xarray/core/concat.py +++ b/xarray/core/concat.py @@ -524,7 +524,7 @@ def get_indexes(name): elif name == dim: var = ds._variables[name] if not var.dims: - yield PandasIndex([var.values], dim) + yield PandasIndex([var.values.item()], dim) # stack up each variable and/or index to fill-out the dataset (in order) # n.b. this loop preserves variable order, needed for groupby. diff --git a/xarray/tests/test_concat.py b/xarray/tests/test_concat.py index 8abede64761..1932fb0537d 100644 --- a/xarray/tests/test_concat.py +++ b/xarray/tests/test_concat.py @@ -440,6 +440,22 @@ def test_concat_promote_shape(self) -> None: expected = Dataset({"z": (("x", "y"), [[-1], [1]])}, {"x": [0, 1], "y": [0]}) assert_identical(actual, expected) + # regression GH6384 + objs = [ + Dataset({}, {"x": pd.Interval(-1, 0, closed="right")}), + Dataset({"x": [pd.Interval(0, 1, closed="right")]}), + ] + actual = concat(objs, "x") + expected = Dataset( + { + "x": [ + pd.Interval(-1, 0, closed="right"), + pd.Interval(0, 1, closed="right"), + ] + } + ) + assert_identical(actual, expected) + def test_concat_do_not_promote(self) -> None: # GH438 objs = [