Skip to content

Fix concat with scalar coordinate #6385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 21, 2022
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: 1 addition & 1 deletion xarray/core/concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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