@@ -54,24 +54,34 @@ def __getitem__(self, key):
54
54
)
55
55
56
56
def _getitem (self , key ):
57
- if self ._batch and hasattr (self .array , "dataset" ): # is self.array not loaded?
57
+ if self ._batch and hasattr (self .array , "dataset" ):
58
58
# this are both True only for pydap>3.5.5
59
- from pydap .lib import resolve_batch_for_all_variables
59
+ # from pydap.lib import resolve_batch_for_all_variables
60
+ from pydap .lib import get_batch_data
60
61
61
62
dataset = self .array .dataset
62
- resolve_batch_for_all_variables (self .array , key , checksums = self ._checksums )
63
- result = np .asarray (
64
- dataset ._current_batch_promise .wait_for_result (self .array .id )
65
- )
63
+ print ("[batching]" , self .array .id )
64
+ if not dataset [self .array .id ]._is_data_loaded ():
65
+ print ("data not loaded" , self .array .id )
66
+ # data has not been deserialized yet
67
+ # runs only once per store/hierarchy
68
+ get_batch_data (self .array , checksums = self ._checksums , key = key )
69
+ result = np .asarray (dataset [self .array .id ].data )
70
+ result = robust_getitem (result , key , catch = ValueError )
66
71
else :
72
+ print ("[non-batching]" , self .array .id )
67
73
result = robust_getitem (self .array , key , catch = ValueError )
68
- # try:
69
74
result = np .asarray (result .data )
70
- # except AttributeError:
71
- # result = np.asarray(result)
72
75
axis = tuple (n for n , k in enumerate (key ) if isinstance (k , integer_types ))
76
+ print (key )
77
+ print ("axis:" , axis )
78
+ # print("ndim", result.ndim)
79
+ # print("array.ndim", self.array.ndim)
73
80
if result .ndim + len (axis ) != self .array .ndim and axis :
81
+ # print('here????')
82
+ # print("squeezed result", np.shape(result))
74
83
result = np .squeeze (result , axis )
84
+ # print("squeezed result", np.shape(result))
75
85
return result
76
86
77
87
@@ -246,9 +256,9 @@ def _get_data_array(self, var):
246
256
from pydap .lib import get_batch_data
247
257
248
258
if not var ._is_data_loaded ():
249
- # this implies dat has not been deserialized yet
259
+ # data has not been deserialized yet
250
260
# runs only once per store/hierarchy
251
- get_batch_data (var . parent , checksums = self ._checksums )
261
+ get_batch_data (var , checksums = self ._checksums )
252
262
return self .dataset [var .id ].data
253
263
254
264
0 commit comments