@@ -1173,6 +1173,7 @@ def collapsed(self, dims_to_collapse=None):
11731173 Replaces the points & bounds with a simple bounded region.
11741174 """
11751175 import dask .array as da
1176+
11761177 # Ensure dims_to_collapse is a tuple to be able to pass
11771178 # through to numpy
11781179 if isinstance (dims_to_collapse , (int , np .integer )):
@@ -1211,16 +1212,16 @@ def serialize(x):
12111212 'Metadata may not be fully descriptive for {!r}.'
12121213 warnings .warn (msg .format (self .name ()))
12131214
1214- # Determine the right array method for stacking
1215- stack_method = da . stack if self .has_bounds () \
1216- and is_lazy_data ( self . core_bounds ()) else np . stack
1215+ # Determine the array library for stacking
1216+ al = da if self .has_bounds () and is_lazy_data ( self . core_bounds () ) \
1217+ else np
12171218
1218- item = stack_method (self .core_bounds ()) if self .has_bounds () \
1219+ item = al . concatenate (self .core_bounds ()) if self .has_bounds () \
12191220 else self .core_points ()
12201221
12211222 # Calculate the bounds and points along the right dims
1222- bounds = stack_method ([item .min (axis = dims_to_collapse ),
1223- item .max (axis = dims_to_collapse )]).T
1223+ bounds = al . stack ([item .min (axis = dims_to_collapse ),
1224+ item .max (axis = dims_to_collapse )]).T
12241225 points = item .mean (axis = dims_to_collapse , dtype = self .dtype )
12251226
12261227 # Create the new collapsed coordinate.
0 commit comments