예제 #1
0
 def get_view(self, orig_array, dtype, new_shape):
     strides, backstrides = support.calc_strides(new_shape, dtype,
                                                 self.order)
     return SliceArray(self.start,
                       strides,
                       backstrides,
                       new_shape,
                       self,
                       orig_array,
                       dtype=dtype)
예제 #2
0
파일: concrete.py 프로젝트: charred/pypy
 def astype(self, space, dtype):
     strides, backstrides = support.calc_strides(self.get_shape(), dtype,
                                                 self.order)
     impl = ConcreteArray(self.get_shape(), dtype, self.order,
                          strides, backstrides)
     if self.dtype.is_str_or_unicode() and not dtype.is_str_or_unicode():
         raise OperationError(space.w_NotImplementedError, space.wrap(
             "astype(%s) not implemented yet" % self.dtype))
     else:
         loop.setslice(space, impl.get_shape(), impl, self)
     return impl
예제 #3
0
파일: base.py 프로젝트: charred/pypy
    def from_shape(space, shape, dtype, order='C', w_instance=None):
        from pypy.module.micronumpy.arrayimpl import concrete, scalar

        if not shape:
            impl = scalar.Scalar(dtype.base)
        else:
            strides, backstrides = calc_strides(shape, dtype.base, order)
            impl = concrete.ConcreteArray(shape, dtype.base, order, strides,
                                      backstrides)
        if w_instance:
            return wrap_impl(space, space.type(w_instance), w_instance, impl)
        return W_NDimArray(impl)
예제 #4
0
 def astype(self, space, dtype):
     strides, backstrides = support.calc_strides(self.get_shape(), dtype,
                                                 self.order)
     impl = ConcreteArray(self.get_shape(), dtype, self.order, strides,
                          backstrides)
     if self.dtype.is_str_or_unicode() and not dtype.is_str_or_unicode():
         raise OperationError(
             space.w_NotImplementedError,
             space.wrap("astype(%s) not implemented yet" % self.dtype))
     else:
         loop.setslice(space, impl.get_shape(), impl, self)
     return impl
예제 #5
0
파일: base.py 프로젝트: charred/pypy
 def from_shape_and_storage(space, shape, storage, dtype, order='C', owning=False, w_subtype=None):
     from pypy.module.micronumpy.arrayimpl import concrete
     assert shape
     strides, backstrides = calc_strides(shape, dtype, order)
     if owning:
         # Will free storage when GCd
         impl = concrete.ConcreteArray(shape, dtype, order, strides,
                                             backstrides, storage=storage)
     else:
         impl = concrete.ConcreteArrayNotOwning(shape, dtype, order, strides,
                                             backstrides, storage)
     if w_subtype:
         w_ret = space.allocate_instance(W_NDimArray, w_subtype)
         W_NDimArray.__init__(w_ret, impl)
         space.call_method(w_ret, '__array_finalize__', w_subtype)
         return w_ret
     return W_NDimArray(impl)
예제 #6
0
 def set_shape(self, space, orig_array, new_shape):
     strides, backstrides = support.calc_strides(new_shape, self.dtype,
                                                 self.order)
     return SliceArray(0, strides, backstrides, new_shape, self, orig_array)
예제 #7
0
 def copy(self, space):
     strides, backstrides = support.calc_strides(self.get_shape(),
                                                 self.dtype, self.order)
     impl = ConcreteArray(self.get_shape(), self.dtype, self.order, strides,
                          backstrides)
     return loop.setslice(space, self.get_shape(), impl, self)
예제 #8
0
파일: concrete.py 프로젝트: charred/pypy
 def get_view(self, orig_array, dtype, new_shape):
     strides, backstrides = support.calc_strides(new_shape, dtype,
                                                 self.order)
     return SliceArray(self.start, strides, backstrides, new_shape,
                       self, orig_array, dtype=dtype)
예제 #9
0
파일: concrete.py 프로젝트: charred/pypy
 def set_shape(self, space, orig_array, new_shape):
     strides, backstrides = support.calc_strides(new_shape, self.dtype,
                                                 self.order)
     return SliceArray(0, strides, backstrides, new_shape, self,
                       orig_array)
예제 #10
0
파일: concrete.py 프로젝트: charred/pypy
 def copy(self, space):
     strides, backstrides = support.calc_strides(self.get_shape(), self.dtype,
                                                 self.order)
     impl = ConcreteArray(self.get_shape(), self.dtype, self.order, strides,
                          backstrides)
     return loop.setslice(space, self.get_shape(), impl, self)