Skip to content

Commit

Permalink
Fix concat with scalar coordinate (#6385)
Browse files Browse the repository at this point in the history
  • Loading branch information
benbovy authored Mar 21, 2022
1 parent 067b2e8 commit 83f238a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion xarray/core/concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,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.
Expand Down
16 changes: 16 additions & 0 deletions xarray/tests/test_concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down

0 comments on commit 83f238a

Please sign in to comment.