def __init__(self, start, strides, backstrides, shape, parent, orig_arr, dtype=None): self.strides = strides self.backstrides = backstrides self.shape = shape if dtype is None: dtype = parent.dtype if isinstance(parent, SliceArray): parent = parent.parent # one level only self.parent = parent self.storage = parent.storage self.gcstruct = parent.gcstruct if parent.order not in (NPY.CORDER, NPY.FORTRANORDER): raise oefmt(dtype.itemtype.space.w_ValueError, "SliceArray but parent order is not 0,1 rather %d", parent.order) self.order = parent.order self.dtype = dtype try: self.size = ovfcheck(support.product_check(shape) * self.dtype.elsize) except OverflowError: raise oefmt(dtype.itemtype.space.w_ValueError, "array is too big.") self.start = start self.orig_arr = orig_arr flags = parent.flags & NPY.ARRAY_ALIGNED flags |= parent.flags & NPY.ARRAY_WRITEABLE if is_c_contiguous(self): flags |= NPY.ARRAY_C_CONTIGUOUS if is_f_contiguous(self): flags |= NPY.ARRAY_F_CONTIGUOUS self.flags = flags
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
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
def __init__(self, start, strides, backstrides, shape, parent, orig_arr, dtype=None): self.strides = strides self.backstrides = backstrides self.shape = shape if dtype is None: dtype = parent.dtype if isinstance(parent, SliceArray): parent = parent.parent # one level only self.parent = parent self.storage = parent.storage self.gcstruct = parent.gcstruct self.order = parent.order self.dtype = dtype self.size = support.product(shape) * self.dtype.elsize self.start = start self.orig_arr = orig_arr flags = parent.flags & NPY.ARRAY_ALIGNED flags |= parent.flags & NPY.ARRAY_WRITEABLE if is_c_contiguous(self): flags |= NPY.ARRAY_C_CONTIGUOUS if is_f_contiguous(self): flags |= NPY.ARRAY_F_CONTIGUOUS self.flags = flags
def __init__(self, shape, strides, start=0): self.shape = shape self.strides = strides self.start = start if is_c_contiguous(self): self.flags |= NPY.ARRAY_C_CONTIGUOUS if is_f_contiguous(self): self.flags |= NPY.ARRAY_F_CONTIGUOUS
def _update_contiguous_flags(arr): is_c_contig = is_c_contiguous(arr) if is_c_contig: enable_flags(arr, NPY.ARRAY_C_CONTIGUOUS) else: clear_flags(arr, NPY.ARRAY_C_CONTIGUOUS) is_f_contig = is_f_contiguous(arr) if is_f_contig: enable_flags(arr, NPY.ARRAY_F_CONTIGUOUS) else: clear_flags(arr, NPY.ARRAY_F_CONTIGUOUS)
def __init__(self, shape, dtype, order, strides, backstrides, storage, orig_base, start=0): ConcreteArrayNotOwning.__init__(self, shape, dtype, order, strides, backstrides, storage, start) self.orig_base = orig_base if isinstance(orig_base, W_NumpyObject): self.flags = orig_base.get_flags() & NPY.ARRAY_ALIGNED self.flags |= orig_base.get_flags() & NPY.ARRAY_WRITEABLE else: self.flags = 0 if is_c_contiguous(self): self.flags |= NPY.ARRAY_C_CONTIGUOUS if is_f_contiguous(self): self.flags |= NPY.ARRAY_F_CONTIGUOUS
def __init__(self, shape, dtype, order, strides, backstrides, storage, orig_base, start=0): ConcreteArrayNotOwning.__init__(self, shape, dtype, order, strides, backstrides, storage, start) self.orig_base = orig_base if isinstance(orig_base, W_NumpyObject): flags = orig_base.get_flags() & NPY.ARRAY_ALIGNED flags |= orig_base.get_flags() & NPY.ARRAY_WRITEABLE else: flags = 0 if is_c_contiguous(self): flags |= NPY.ARRAY_C_CONTIGUOUS if is_f_contiguous(self): flags |= NPY.ARRAY_F_CONTIGUOUS self.flags = flags
def __init__(self, start, strides, backstrides, shape, parent, orig_arr, dtype=None): self.strides = strides self.backstrides = backstrides self.shape = shape if dtype is None: dtype = parent.dtype if isinstance(parent, SliceArray): parent = parent.parent # one level only self.parent = parent self.storage = parent.storage self.gcstruct = parent.gcstruct self.order = parent.order self.dtype = dtype self.size = support.product(shape) * self.dtype.elsize self.start = start self.orig_arr = orig_arr self.flags = parent.flags & NPY.ARRAY_ALIGNED self.flags |= parent.flags & 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