Exemplo n.º 1
0
 def apply(self, space, orig_arr):
     arr = orig_arr.implementation
     shape = self.extend_shape(arr.shape)
     r = calculate_slice_strides(arr.shape, arr.start, arr.get_strides(),
                                 arr.get_backstrides(), self.l)
     _, start, strides, backstrides = r
     return W_NDimArray.new_slice(space, start, strides[:], backstrides[:],
                                  shape[:], arr, orig_arr)
Exemplo n.º 2
0
Arquivo: iter.py Projeto: sota/pypy
 def apply(self, space, orig_arr):
     arr = orig_arr.implementation
     shape = self.extend_shape(arr.shape)
     r = calculate_slice_strides(arr.shape, arr.start, arr.get_strides(),
                                 arr.get_backstrides(), self.l)
     _, start, strides, backstrides = r
     return W_NDimArray.new_slice(space, start, strides[:], backstrides[:],
                                  shape[:], arr, orig_arr)
Exemplo n.º 3
0
 def transform(self, arr, t):
     if isinstance(t, BroadcastTransform):
         r = calculate_broadcast_strides(self.strides, self.backstrides,
                                         self.res_shape, t.res_shape)
         return ViewIterator(self.offset, r[0], r[1], t.res_shape)
     elif isinstance(t, ViewTransform):
         r = calculate_slice_strides(self.res_shape, self.offset,
                                     self.strides,
                                     self.backstrides, t.chunks.l)
         return ViewIterator(r[1], r[2], r[3], r[0])
Exemplo n.º 4
0
 def transform(self, arr, t):
     if isinstance(t, BroadcastTransform):
         r = calculate_broadcast_strides(self.strides, self.backstrides,
                                         self.res_shape, t.res_shape)
         return ViewIterator(self.offset, r[0], r[1], t.res_shape)
     elif isinstance(t, ViewTransform):
         r = calculate_slice_strides(self.res_shape, self.offset,
                                     self.strides, self.backstrides,
                                     t.chunks.l)
         return ViewIterator(r[1], r[2], r[3], r[0])
Exemplo n.º 5
0
    def apply(self, arr):
        from pypy.module.micronumpy.interp_numarray import W_NDimSlice,\
             VirtualSlice, ConcreteArray

        shape = self.extend_shape(arr.shape)
        if not isinstance(arr, ConcreteArray):
            return VirtualSlice(arr, self, shape)
        r = calculate_slice_strides(arr.shape, arr.start, arr.strides,
                                    arr.backstrides, self.l)
        _, start, strides, backstrides = r
        return W_NDimSlice(start, strides[:], backstrides[:], shape[:], arr)
Exemplo n.º 6
0
    def apply(self, arr):
        from pypy.module.micronumpy.interp_numarray import W_NDimSlice,\
             VirtualSlice, ConcreteArray

        shape = self.extend_shape(arr.shape)
        if not isinstance(arr, ConcreteArray):
            return VirtualSlice(arr, self, shape)
        r = calculate_slice_strides(arr.shape, arr.start, arr.strides,
                                    arr.backstrides, self.l)
        _, start, strides, backstrides = r
        return W_NDimSlice(start, strides[:], backstrides[:],
                           shape[:], arr)
Exemplo n.º 7
0
 def create_slice(self, chunks):
     shape = []
     i = -1
     for i, (start_, stop, step, lgt) in enumerate(chunks):
         if step != 0:
             shape.append(lgt)
     s = i + 1
     assert s >= 0
     shape += self.shape[s:]
     if not isinstance(self, ConcreteArray):
         return VirtualSlice(self, chunks, shape)
     r = calculate_slice_strides(self.shape, self.start, self.strides,
                                 self.backstrides, chunks)
     _, start, strides, backstrides = r
     return W_NDimSlice(start, strides[:], backstrides[:], shape[:], self)
Exemplo n.º 8
0
 def create_slice(self, chunks):
     shape = []
     i = -1
     for i, (start_, stop, step, lgt) in enumerate(chunks):
         if step != 0:
             shape.append(lgt)
     s = i + 1
     assert s >= 0
     shape += self.shape[s:]
     if not isinstance(self, ConcreteArray):
         return VirtualSlice(self, chunks, shape)
     r = calculate_slice_strides(self.shape, self.start, self.strides,
                                 self.backstrides, chunks)
     _, start, strides, backstrides = r
     return W_NDimSlice(start, strides[:], backstrides[:],
                        shape[:], self)