Пример #1
0
class W_FlatIterator(ViewArray):

    @jit.unroll_safe
    def __init__(self, arr):
        arr = arr.get_concrete()
        size = 1
        for sh in arr.shape:
            size *= sh
        self.strides = [arr.strides[-1]]
        self.backstrides = [arr.backstrides[-1]]
        ViewArray.__init__(self, size, [size], arr.dtype, arr.order,
                               arr)
        self.shapelen = len(arr.shape)
        self.iter = OneDimIterator(arr.start, self.strides[0],
                                   self.shape[0])

    def descr_next(self, space):
        if self.iter.done():
            raise OperationError(space.w_StopIteration, space.w_None)
        result = self.getitem(self.iter.offset)
        self.iter = self.iter.next(self.shapelen)
        return result

    def descr_iter(self):
        return self
Пример #2
0
 def __init__(self, arr):
     arr = arr.get_concrete()
     size = 1
     for sh in arr.shape:
         size *= sh
     self.strides = [arr.strides[-1]]
     self.backstrides = [arr.backstrides[-1]]
     ViewArray.__init__(self, size, [size], arr.dtype, arr.order, arr)
     self.shapelen = len(arr.shape)
     self.iter = OneDimIterator(arr.start, self.strides[0], self.shape[0])
Пример #3
0
 def __init__(self, arr):
     arr = arr.get_concrete()
     size = 1
     for sh in arr.shape:
         size *= sh
     self.strides = [arr.strides[-1]]
     self.backstrides = [arr.backstrides[-1]]
     ViewArray.__init__(self, size, [size], arr.dtype, arr.order,
                            arr)
     self.shapelen = len(arr.shape)
     self.iter = OneDimIterator(arr.start, self.strides[0],
                                self.shape[0])
Пример #4
0
class W_FlatIterator(ViewArray):
    @jit.unroll_safe
    def __init__(self, arr):
        arr = arr.get_concrete()
        size = 1
        for sh in arr.shape:
            size *= sh
        self.strides = [arr.strides[-1]]
        self.backstrides = [arr.backstrides[-1]]
        ViewArray.__init__(self, size, [size], arr.dtype, arr.order, arr)
        self.shapelen = len(arr.shape)
        self.iter = OneDimIterator(arr.start, self.strides[0], self.shape[0])

    def descr_next(self, space):
        if self.iter.done():
            raise OperationError(space.w_StopIteration, space.w_None)
        result = self.getitem(self.iter.offset)
        self.iter = self.iter.next(self.shapelen)
        return result

    def descr_iter(self):
        return self