Skip to content

Commit aca67b9

Browse files
committed
Don't change concat_dims
1 parent 729b8ba commit aca67b9

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

xarray/backends/api.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1607,6 +1607,9 @@ def open_mfdataset(
16071607

16081608
paths1d: list[str | ReadBuffer]
16091609
if combine == "nested":
1610+
if isinstance(concat_dim, str | DataArray) or concat_dim is None:
1611+
concat_dim = [concat_dim] # type: ignore[assignment]
1612+
16101613
# This creates a flat list which is easier to iterate over, whilst
16111614
# encoding the originally-supplied structure as "ids".
16121615
# The "ids" are not used at all if combine='by_coords`.
@@ -1655,7 +1658,7 @@ def open_mfdataset(
16551658
# along each dimension, using structure given by "ids"
16561659
combined = _nested_combine(
16571660
datasets,
1658-
concat_dim=concat_dim,
1661+
concat_dims=concat_dim,
16591662
compat=compat,
16601663
data_vars=data_vars,
16611664
coords=coords,

xarray/structure/combine.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ def _new_tile_id(single_id_ds_pair):
352352

353353
def _nested_combine(
354354
datasets,
355-
concat_dim,
355+
concat_dims,
356356
compat,
357357
data_vars,
358358
coords,
@@ -364,9 +364,6 @@ def _nested_combine(
364364
if len(datasets) == 0:
365365
return Dataset()
366366

367-
if isinstance(concat_dim, str | DataArray) or concat_dim is None:
368-
concat_dim = [concat_dim]
369-
370367
# Arrange datasets for concatenation
371368
# Use information from the shape of the user input
372369
if not ids:
@@ -383,7 +380,7 @@ def _nested_combine(
383380
# Apply series of concatenate or merge operations along each dimension
384381
combined = _combine_nd(
385382
combined_ids,
386-
concat_dims=concat_dim,
383+
concat_dims=concat_dims,
387384
compat=compat,
388385
data_vars=data_vars,
389386
coords=coords,
@@ -598,10 +595,13 @@ def combine_nested(
598595
if mixed_datasets_and_arrays:
599596
raise ValueError("Can't combine datasets with unnamed arrays.")
600597

598+
if isinstance(concat_dim, str | DataArray) or concat_dim is None:
599+
concat_dim = [concat_dim]
600+
601601
# The IDs argument tells _nested_combine that datasets aren't yet sorted
602602
return _nested_combine(
603603
datasets,
604-
concat_dim=concat_dim,
604+
concat_dims=concat_dim,
605605
compat=compat,
606606
data_vars=data_vars,
607607
coords=coords,

0 commit comments

Comments
 (0)