示例#1
0
 def slicer(start, length, slicelen):
     length = min(len(self) - start, length)
     slicelen = min(length, slicelen)
     buf = np.empty(slicelen, dtype=dtype)
     if rightclosed:
         return Seq.map((lambda s: g_rightclosed(s, buf, cuts)),
                        covariate.slicer(start, length, slicelen))
     else:
         return Seq.map(
             (lambda s: g_leftclosed(s, buf, cuts, levelcount - 1)),
             covariate.slicer(start, length, slicelen))
示例#2
0
    def __call__(self, start, length, slicelen):
        assert start >= 0 and start < len(self.vector)
        length = min(length, len(self.vector) - start)
        slicelen = min(length, slicelen)
        state = start, length, slicelen

        def f(from_to):
            return self.vector[from_to[0]:from_to[1]]

        return Seq.map(f, Seq.from_next(state, next_slice_indices))
示例#3
0
    def __call__(self, start, length, slicelen):
        dtypes = [f.slicer.dtype for f in self.factors]
        alluint8 = all([d == np.uint8 for d in dtypes])
        dtype = np.uint8 if alluint8 else np.uint16
        k = len(self.factors)
        buf = np.empty((k, slicelen), dtype=dtype)

        def f(slices):
            n = len(slices[0])
            for i in range(k):
                if dtypes[i] == dtype:
                    buf[i, :n] = slices[i]
                else:
                    buf[i, :n] = slices[i].astype(dtype)
            if n == slicelen:
                return buf
            else:
                return buf[:, :n]

        return Seq.map(
            f,
            Seq.zip(*[f.slicer(start, length, slicelen)
                      for f in self.factors]))
示例#4
0
 def slicer(start, length, slicelen):
     length = min(self._length - start, length)
     slicelen = min(length, slicelen)
     buf = np.ones(slicelen, dtype = np.uint8)
     return Seq.map((lambda x: buf[x[0]:x[1]]), Seq.from_next((start, length, slicelen), ch.next_slice_indices))
示例#5
0
 def f(start, length, slicelen):
     buf = np.empty(slicelen, dtype=np.float32)
     return Seq.map((lambda s: g(s, buf)), vslicer(start, length, slicelen))
示例#6
0
 def slice(start, length, slicelen):
     buf = np.empty(slicelen, dtype = np.float32)
     return Seq.map((lambda slice: g_parse(slice, buf, parsed)), basefactor.slicer(start, length, slicelen))