Skip to content

Commit 04eb342

Browse files
authored
Allow Variable type as dim argument to concat (#8384)
1 parent d40609a commit 04eb342

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

xarray/core/concat.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
merge_attrs,
1717
merge_collected,
1818
)
19-
from xarray.core.types import T_DataArray, T_Dataset
19+
from xarray.core.types import T_DataArray, T_Dataset, T_Variable
2020
from xarray.core.variable import Variable
2121
from xarray.core.variable import concat as concat_vars
2222

@@ -34,7 +34,7 @@
3434
@overload
3535
def concat(
3636
objs: Iterable[T_Dataset],
37-
dim: Hashable | T_DataArray | pd.Index,
37+
dim: Hashable | T_Variable | T_DataArray | pd.Index,
3838
data_vars: T_DataVars = "all",
3939
coords: ConcatOptions | list[Hashable] = "different",
4040
compat: CompatOptions = "equals",
@@ -49,7 +49,7 @@ def concat(
4949
@overload
5050
def concat(
5151
objs: Iterable[T_DataArray],
52-
dim: Hashable | T_DataArray | pd.Index,
52+
dim: Hashable | T_Variable | T_DataArray | pd.Index,
5353
data_vars: T_DataVars = "all",
5454
coords: ConcatOptions | list[Hashable] = "different",
5555
compat: CompatOptions = "equals",
@@ -80,11 +80,11 @@ def concat(
8080
xarray objects to concatenate together. Each object is expected to
8181
consist of variables and coordinates with matching shapes except for
8282
along the concatenated dimension.
83-
dim : Hashable or DataArray or pandas.Index
83+
dim : Hashable or Variable or DataArray or pandas.Index
8484
Name of the dimension to concatenate along. This can either be a new
8585
dimension name, in which case it is added along axis=0, or an existing
8686
dimension name, in which case the location of the dimension is
87-
unchanged. If dimension is provided as a DataArray or Index, its name
87+
unchanged. If dimension is provided as a Variable, DataArray or Index, its name
8888
is used as the dimension to concatenate along and the values are added
8989
as a coordinate.
9090
data_vars : {"minimal", "different", "all"} or list of Hashable, optional
@@ -450,7 +450,7 @@ def _parse_datasets(
450450

451451
def _dataset_concat(
452452
datasets: list[T_Dataset],
453-
dim: str | T_DataArray | pd.Index,
453+
dim: str | T_Variable | T_DataArray | pd.Index,
454454
data_vars: T_DataVars,
455455
coords: str | list[str],
456456
compat: CompatOptions,
@@ -676,7 +676,7 @@ def get_indexes(name):
676676

677677
def _dataarray_concat(
678678
arrays: Iterable[T_DataArray],
679-
dim: str | T_DataArray | pd.Index,
679+
dim: str | T_Variable | T_DataArray | pd.Index,
680680
data_vars: T_DataVars,
681681
coords: str | list[str],
682682
compat: CompatOptions,

0 commit comments

Comments
 (0)