1
+ from __future__ import annotations
2
+
1
3
from typing import (
2
4
TYPE_CHECKING ,
3
5
Dict ,
12
14
)
13
15
14
16
import pandas as pd
17
+ from typing_extensions import Literal
15
18
16
19
from . import dtypes , utils
17
20
from .alignment import align
24
27
from .dataarray import DataArray
25
28
from .dataset import Dataset
26
29
30
+ compat_options = Literal [
31
+ "identical" , "equals" , "broadcast_equals" , "no_conflicts" , "override"
32
+ ]
33
+ concat_options = Literal ["all" , "minimal" , "different" ]
34
+
27
35
28
36
@overload
29
37
def concat (
30
38
objs : Iterable ["Dataset" ],
31
- dim : Union [ str , "DataArray" , pd .Index ] ,
32
- data_vars : Union [ str , List [str ] ] = "all" ,
33
- coords : Union [ str , List [str ] ] = "different" ,
34
- compat : str = "equals" ,
39
+ dim : Hashable | "DataArray" | pd .Index ,
40
+ data_vars : concat_options | List [Hashable ] = "all" ,
41
+ coords : concat_options | List [Hashable ] = "different" ,
42
+ compat : compat_options = "equals" ,
35
43
positions : Optional [Iterable [int ]] = None ,
36
44
fill_value : object = dtypes .NA ,
37
45
join : str = "outer" ,
@@ -43,10 +51,10 @@ def concat(
43
51
@overload
44
52
def concat (
45
53
objs : Iterable ["DataArray" ],
46
- dim : Union [ str , "DataArray" , pd .Index ] ,
47
- data_vars : Union [ str , List [str ] ] = "all" ,
48
- coords : Union [ str , List [str ] ] = "different" ,
49
- compat : str = "equals" ,
54
+ dim : Hashable | "DataArray" | pd .Index ,
55
+ data_vars : concat_options | List [Hashable ] = "all" ,
56
+ coords : concat_options | List [Hashable ] = "different" ,
57
+ compat : compat_options = "equals" ,
50
58
positions : Optional [Iterable [int ]] = None ,
51
59
fill_value : object = dtypes .NA ,
52
60
join : str = "outer" ,
@@ -74,14 +82,14 @@ def concat(
74
82
xarray objects to concatenate together. Each object is expected to
75
83
consist of variables and coordinates with matching shapes except for
76
84
along the concatenated dimension.
77
- dim : str or DataArray or pandas.Index
85
+ dim : Hashable or DataArray or pandas.Index
78
86
Name of the dimension to concatenate along. This can either be a new
79
87
dimension name, in which case it is added along axis=0, or an existing
80
88
dimension name, in which case the location of the dimension is
81
89
unchanged. If dimension is provided as a DataArray or Index, its name
82
90
is used as the dimension to concatenate along and the values are added
83
91
as a coordinate.
84
- data_vars : {"minimal", "different", "all"} or list of str , optional
92
+ data_vars : {"minimal", "different", "all"} or list of Hashable , optional
85
93
These data variables will be concatenated together:
86
94
* "minimal": Only data variables in which the dimension already
87
95
appears are included.
@@ -91,11 +99,11 @@ def concat(
91
99
load the data payload of data variables into memory if they are not
92
100
already loaded.
93
101
* "all": All data variables will be concatenated.
94
- * list of str : The listed data variables will be concatenated, in
102
+ * list of dims : The listed data variables will be concatenated, in
95
103
addition to the "minimal" data variables.
96
104
97
105
If objects are DataArrays, data_vars must be "all".
98
- coords : {"minimal", "different", "all"} or list of str , optional
106
+ coords : {"minimal", "different", "all"} or list of Hashable , optional
99
107
These coordinate variables will be concatenated together:
100
108
* "minimal": Only coordinates in which the dimension already appears
101
109
are included.
@@ -106,7 +114,7 @@ def concat(
106
114
loaded.
107
115
* "all": All coordinate variables will be concatenated, except
108
116
those corresponding to other dimensions.
109
- * list of str : The listed coordinate variables will be concatenated,
117
+ * list of Hashable : The listed coordinate variables will be concatenated,
110
118
in addition to the "minimal" coordinates.
111
119
compat : {"identical", "equals", "broadcast_equals", "no_conflicts", "override"}, optional
112
120
String indicating how to compare non-concatenated variables of the same name for
0 commit comments