def _unchunk(v): #idx, data = zip(*v.data) idx, data = v arr = empty(nchunks, dtype='object') for (i, d) in zip(idx, data): arr[i] = d return allstack(arr.tolist())
def _unchunk(it): ordered = sorted(it, key=lambda kv: kv[0][split:]) keys, values = zip(*ordered) k_chks = [k[split:] for k in keys] arr = empty(nchunks, dtype='object') for (i, d) in zip(k_chks, values): arr[i] = d yield keys[0][:split], allstack(arr.tolist())
def unchunk(self): """ Reconstitute the chunked array back into a full ndarray. Returns ------- ndarray """ if self.padding != len(self.shape)*(0,): shape = self.values.shape arr = empty(shape, dtype=object) for inds in product(*[arange(s) for s in shape]): slices = [] for i, p, n in zip(inds, self.padding, shape): start = None if (i == 0 or p == 0) else p stop = None if (i == n-1 or p == 0) else -p slices.append(slice(start, stop, None)) arr[inds] = self.values[inds][tuple(slices)] else: arr = self.values return allstack(arr.tolist())
def unblock(self): """ Reconstitute the blocked array back into a full ndarray Returns ------- ndarray """ if self.padding is not None: shape = self.values.shape arr = empty(shape, dtype=object) for inds in product([arange(s) for s in shape]): slices = [] for i, p, n in zip(inds, self.padding, shape): start = None if i == 0 else p stop = None if i == n else -p slices += slice(start, stop, None) arr[inds] = arr[inds][slices] else: arr = self.values return allstack(self.values.tolist())