예제 #1
0
파일: chunk.py 프로젝트: gdtm86/bolt
 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())
예제 #2
0
 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())
예제 #3
0
파일: chunk.py 프로젝트: kmader/bolt
 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())
예제 #4
0
파일: chunk.py 프로젝트: bolt-project/bolt
 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())
예제 #5
0
    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())
예제 #6
0
    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())