@@ -97,19 +97,19 @@ def asdataset(
97
97
model = DataModel .from_dataclass (dataclass )
98
98
dataset = dataoptions .factory ()
99
99
100
- for item in model .data . values () :
101
- dataset [item .name ] = item (reference )
100
+ for entry in model .data_vars :
101
+ dataset [entry .name ] = entry (reference )
102
102
103
- for item in model .coord . values () :
104
- if item .name in dataset .dims :
105
- dataset .coords [item .name ] = item (dataset )
103
+ for entry in model .coords :
104
+ if entry .name in dataset .dims :
105
+ dataset .coords [entry .name ] = entry (dataset )
106
106
107
- for item in model .coord . values () :
108
- if item .name not in dataset .dims :
109
- dataset .coords [item .name ] = item (dataset )
107
+ for entry in model .coords :
108
+ if entry .name not in dataset .dims :
109
+ dataset .coords [entry .name ] = entry (dataset )
110
110
111
- for item in model .attr . values () :
112
- dataset .attrs [item .name ] = item ()
111
+ for entry in model .attrs :
112
+ dataset .attrs [entry .name ] = entry ()
113
113
114
114
return dataset
115
115
@@ -202,11 +202,11 @@ def shaped(
202
202
203
203
"""
204
204
model = DataModel .from_dataclass (cls )
205
- data_vars : Dict [str , Any ] = {}
205
+ data_vars : Dict [str , np . ndarray ] = {}
206
206
207
- for name , item in model .data . items () :
208
- shape = tuple (sizes [dim ] for dim in item . type [ " dims" ] )
209
- data_vars [name ] = func (shape )
207
+ for key , entry in model .data_vars_items :
208
+ shape = tuple (sizes [dim ] for dim in entry . dims )
209
+ data_vars [key ] = func (shape )
210
210
211
211
return asdataset (cls (** data_vars , ** kwargs ))
212
212
0 commit comments