Exemplo n.º 1
0
        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)
Exemplo n.º 2
0
Arquivo: chunk.py Projeto: gdtm86/bolt
        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)
Exemplo n.º 3
0
        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)])
Exemplo n.º 4
0
        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)])
Exemplo n.º 5
0
Arquivo: chunk.py Projeto: gdtm86/bolt
 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)
Exemplo n.º 6
0
 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)
Exemplo n.º 7
0
 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)