def _rebuild(v): labels, data = zip(*v.data) sortinginds = tuplesort(labels) if uniform: labelshape = tuple(size) else: labelshape = tuple(amax(labels, axis=0) - amin(labels, axis=0) + 1) valshape = data[0].shape fullshape = labelshape + valshape return asarray(data)[sortinginds].reshape(fullshape)
def _extract(record): k, v = record[0], record[1] chunk, stationary_key = k[0], k[1] key_offsets = prod([asarray(chunk), asarray(chunk_sizes)[vmask]], axis=0) moving_keys, values = zip(*v.data) sorted_keys = tuplesort([i.tolist() for i in moving_keys]) values_sorted = asarray(values)[sorted_keys] expanded_shape = concatenate([moving_key_shape, values_sorted.shape[1:]]) bounds = asarray(values_sorted[0].shape)[vmask] indices = list(product(*map(lambda x: arange(x), bounds))) values = values_sorted.reshape(expanded_shape) for b in indices: s = slices.copy() s[mask] = b yield (tuple(asarray(r_[stationary_key, key_offsets + b], dtype='int')), values[tuple(s)])
def _extract(record): k, v = record[0], record[1] chunk, stationary_key = k[0], k[1] key_offsets = prod( [asarray(chunk), asarray(chunk_sizes)[vmask]], axis=0) moving_keys, values = zip(*v.data) sorted_keys = tuplesort([i.tolist() for i in moving_keys]) values_sorted = asarray(values)[sorted_keys] expanded_shape = concatenate( [moving_key_shape, values_sorted.shape[1:]]) bounds = asarray(values_sorted[0].shape)[vmask] indices = list(product(*map(lambda x: arange(x), bounds))) values = values_sorted.reshape(expanded_shape) for b in indices: s = slices.copy() s[mask] = b yield (tuple( asarray(r_[stationary_key, key_offsets + b], dtype='int')), values[tuple(s)])
def _unchunk(v): #idx, data = zip(*v.data) idx, data = v sorted_idx = tuplesort(idx) return asarray(data)[sorted_idx].reshape(full_shape).transpose(perm).reshape(vshape)
def _unchunk(v): #idx, data = zip(*v.data) idx, data = v sorted_idx = tuplesort(idx) return asarray(data)[sorted_idx].reshape(full_shape).transpose( perm).reshape(vshape)
def _rebuild(v): idx, data = zip(*v.data) valshape = data[0].shape fullshape = moving_kshape + valshape sorted_idx = tuplesort(idx) return asarray(data)[sorted_idx].reshape(fullshape)