Example #1
0
 def __init__(self, shape, dtype, order, strides, backstrides,
              storage=lltype.nullptr(RAW_STORAGE), zero=True):
     gcstruct = V_OBJECTSTORE
     flags = NPY.ARRAY_ALIGNED | NPY.ARRAY_WRITEABLE
     try:
         length = support.product_check(shape)
         self.size = ovfcheck(length * dtype.elsize)
     except OverflowError:
         raise oefmt(dtype.itemtype.space.w_ValueError, "array is too big.")
     if storage == lltype.nullptr(RAW_STORAGE):
         if dtype.num == NPY.OBJECT:
             storage = dtype.itemtype.malloc(length * dtype.elsize, zero=True)
             gcstruct = _create_objectstore(storage, length, dtype.elsize)
         else:
             storage = dtype.itemtype.malloc(length * dtype.elsize, zero=zero)
         flags |= NPY.ARRAY_OWNDATA
     start = calc_start(shape, strides)
     ConcreteArrayNotOwning.__init__(self, shape, dtype, order, strides, backstrides,
                                     storage, start=start)
     self.gcstruct = gcstruct
     if is_c_contiguous(self):
         flags |= NPY.ARRAY_C_CONTIGUOUS
     if is_f_contiguous(self):
         flags |= NPY.ARRAY_F_CONTIGUOUS
     self.flags = flags
Example #2
0
 def __init__(self,
              shape,
              dtype,
              order,
              strides,
              backstrides,
              storage=lltype.nullptr(RAW_STORAGE),
              zero=True):
     gcstruct = V_OBJECTSTORE
     if storage == lltype.nullptr(RAW_STORAGE):
         length = support.product(shape)
         if dtype.num == NPY.OBJECT:
             storage = dtype.itemtype.malloc(length * dtype.elsize,
                                             zero=True)
             gcstruct = _create_objectstore(storage, length, dtype.elsize)
         else:
             storage = dtype.itemtype.malloc(length * dtype.elsize,
                                             zero=zero)
     start = calc_start(shape, strides)
     ConcreteArrayNotOwning.__init__(self,
                                     shape,
                                     dtype,
                                     order,
                                     strides,
                                     backstrides,
                                     storage,
                                     start=start)
     self.gcstruct = gcstruct
     self.flags = NPY.ARRAY_ALIGNED | NPY.ARRAY_WRITEABLE
     if is_c_contiguous(self):
         self.flags |= NPY.ARRAY_C_CONTIGUOUS
     if is_f_contiguous(self):
         self.flags |= NPY.ARRAY_F_CONTIGUOUS
Example #3
0
 def __init__(self, shape, dtype, order, strides, backstrides,
              storage=lltype.nullptr(RAW_STORAGE), zero=True):
     gcstruct = V_OBJECTSTORE
     flags = NPY.ARRAY_ALIGNED | NPY.ARRAY_WRITEABLE
     try:
         length = support.product_check(shape)
         self.size = ovfcheck(length * dtype.elsize)
     except OverflowError: 
         raise oefmt(dtype.itemtype.space.w_ValueError, "array is too big.")
     if storage == lltype.nullptr(RAW_STORAGE):
         if dtype.num == NPY.OBJECT:
             storage = dtype.itemtype.malloc(length * dtype.elsize, zero=True)
             gcstruct = _create_objectstore(storage, length, dtype.elsize)
         else:
             storage = dtype.itemtype.malloc(length * dtype.elsize, zero=zero)
         flags |= NPY.ARRAY_OWNDATA
     start = calc_start(shape, strides)
     ConcreteArrayNotOwning.__init__(self, shape, dtype, order, strides, backstrides,
                                     storage, start=start)
     self.gcstruct = gcstruct
     if is_c_contiguous(self):
         flags |= NPY.ARRAY_C_CONTIGUOUS
     if is_f_contiguous(self):
         flags |= NPY.ARRAY_F_CONTIGUOUS
     self.flags = flags
Example #4
0
 def __init__(self, shape, dtype, order, strides, backstrides,
              storage=lltype.nullptr(RAW_STORAGE), zero=True):
     gcstruct = V_OBJECTSTORE
     if storage == lltype.nullptr(RAW_STORAGE):
         length = support.product(shape) 
         if dtype.num == NPY.OBJECT:
             storage = dtype.itemtype.malloc(length * dtype.elsize, zero=True)
             gcstruct = _create_objectstore(storage, length, dtype.elsize)
         else:
             storage = dtype.itemtype.malloc(length * dtype.elsize, zero=zero)
     start = calc_start(shape, strides)
     ConcreteArrayNotOwning.__init__(self, shape, dtype, order, strides, backstrides,
                                     storage, start=start)
     self.gcstruct = gcstruct
     self.flags = NPY.ARRAY_ALIGNED | NPY.ARRAY_WRITEABLE
     if is_c_contiguous(self):
         self.flags |= NPY.ARRAY_C_CONTIGUOUS
     if is_f_contiguous(self):
         self.flags |= NPY.ARRAY_F_CONTIGUOUS