@@ -28,7 +28,7 @@ def _load_static_files():
28
28
]
29
29
30
30
31
- def short_data_repr_html (array ):
31
+ def short_data_repr_html (array ) -> str :
32
32
"""Format "data" for DataArray and Variable."""
33
33
internal_data = getattr (array , "variable" , array )._data
34
34
if hasattr (internal_data , "_repr_html_" ):
@@ -37,7 +37,7 @@ def short_data_repr_html(array):
37
37
return f"<pre>{ text } </pre>"
38
38
39
39
40
- def format_dims (dims , dims_with_index ):
40
+ def format_dims (dims , dims_with_index ) -> str :
41
41
if not dims :
42
42
return ""
43
43
@@ -53,7 +53,7 @@ def format_dims(dims, dims_with_index):
53
53
return f"<ul class='xr-dim-list'>{ dims_li } </ul>"
54
54
55
55
56
- def summarize_attrs (attrs ):
56
+ def summarize_attrs (attrs ) -> str :
57
57
attrs_dl = "" .join (
58
58
f"<dt><span>{ escape (str (k ))} :</span></dt>" f"<dd>{ escape (str (v ))} </dd>"
59
59
for k , v in attrs .items ()
@@ -62,7 +62,7 @@ def summarize_attrs(attrs):
62
62
return f"<dl class='xr-attrs'>{ attrs_dl } </dl>"
63
63
64
64
65
- def _icon (icon_name ):
65
+ def _icon (icon_name ) -> str :
66
66
# icon_name should be defined in xarray/static/html/icon-svg-inline.html
67
67
return (
68
68
f"<svg class='icon xr-{ icon_name } '>"
@@ -72,7 +72,7 @@ def _icon(icon_name):
72
72
)
73
73
74
74
75
- def summarize_variable (name , var , is_index = False , dtype = None ):
75
+ def summarize_variable (name , var , is_index = False , dtype = None ) -> str :
76
76
variable = var .variable if hasattr (var , "variable" ) else var
77
77
78
78
cssclass_idx = " class='xr-has-index'" if is_index else ""
@@ -109,7 +109,7 @@ def summarize_variable(name, var, is_index=False, dtype=None):
109
109
)
110
110
111
111
112
- def summarize_coords (variables ):
112
+ def summarize_coords (variables ) -> str :
113
113
li_items = []
114
114
for k , v in variables .items ():
115
115
li_content = summarize_variable (k , v , is_index = k in variables .xindexes )
@@ -120,7 +120,7 @@ def summarize_coords(variables):
120
120
return f"<ul class='xr-var-list'>{ vars_li } </ul>"
121
121
122
122
123
- def summarize_vars (variables ):
123
+ def summarize_vars (variables ) -> str :
124
124
vars_li = "" .join (
125
125
f"<li class='xr-var-item'>{ summarize_variable (k , v )} </li>"
126
126
for k , v in variables .items ()
@@ -129,14 +129,14 @@ def summarize_vars(variables):
129
129
return f"<ul class='xr-var-list'>{ vars_li } </ul>"
130
130
131
131
132
- def short_index_repr_html (index ):
132
+ def short_index_repr_html (index ) -> str :
133
133
if hasattr (index , "_repr_html_" ):
134
134
return index ._repr_html_ ()
135
135
136
136
return f"<pre>{ escape (repr (index ))} </pre>"
137
137
138
138
139
- def summarize_index (coord_names , index ):
139
+ def summarize_index (coord_names , index ) -> str :
140
140
name = "<br>" .join ([escape (str (n )) for n in coord_names ])
141
141
142
142
index_id = f"index-{ uuid .uuid4 ()} "
@@ -155,7 +155,7 @@ def summarize_index(coord_names, index):
155
155
)
156
156
157
157
158
- def summarize_indexes (indexes ):
158
+ def summarize_indexes (indexes ) -> str :
159
159
indexes_li = "" .join (
160
160
f"<li class='xr-var-item'>{ summarize_index (v , i )} </li>"
161
161
for v , i in indexes .items ()
@@ -165,7 +165,7 @@ def summarize_indexes(indexes):
165
165
166
166
def collapsible_section (
167
167
name , inline_details = "" , details = "" , n_items = None , enabled = True , collapsed = False
168
- ):
168
+ ) -> str :
169
169
# "unique" id to expand/collapse the section
170
170
data_id = "section-" + str (uuid .uuid4 ())
171
171
@@ -187,7 +187,7 @@ def collapsible_section(
187
187
188
188
def _mapping_section (
189
189
mapping , name , details_func , max_items_collapse , expand_option_name , enabled = True
190
- ):
190
+ ) -> str :
191
191
n_items = len (mapping )
192
192
expanded = _get_boolean_with_default (
193
193
expand_option_name , n_items < max_items_collapse
@@ -203,15 +203,15 @@ def _mapping_section(
203
203
)
204
204
205
205
206
- def dim_section (obj ):
206
+ def dim_section (obj ) -> str :
207
207
dim_list = format_dims (obj .dims , obj .xindexes .dims )
208
208
209
209
return collapsible_section (
210
210
"Dimensions" , inline_details = dim_list , enabled = False , collapsed = True
211
211
)
212
212
213
213
214
- def array_section (obj ):
214
+ def array_section (obj ) -> str :
215
215
# "unique" id to expand/collapse the section
216
216
data_id = "section-" + str (uuid .uuid4 ())
217
217
collapsed = (
@@ -296,7 +296,7 @@ def _obj_repr(obj, header_components, sections):
296
296
)
297
297
298
298
299
- def array_repr (arr ):
299
+ def array_repr (arr ) -> str :
300
300
dims = OrderedDict ((k , v ) for k , v in zip (arr .dims , arr .shape ))
301
301
if hasattr (arr , "xindexes" ):
302
302
indexed_dims = arr .xindexes .dims
@@ -326,7 +326,7 @@ def array_repr(arr):
326
326
return _obj_repr (arr , header_components , sections )
327
327
328
328
329
- def dataset_repr (ds ):
329
+ def dataset_repr (ds ) -> str :
330
330
obj_type = f"xarray.{ type (ds ).__name__ } "
331
331
332
332
header_components = [f"<div class='xr-obj-type'>{ escape (obj_type )} </div>" ]
0 commit comments