Esempio n. 1
0
/*NUMPY_API
 * Update Several Flags at once.
 */
NPY_NO_EXPORT void
PyArray_UpdateFlags(PyArrayObject *ret, int flagmask)
{

    if (flagmask & NPY_ARRAY_F_CONTIGUOUS) {
        if (_IsFortranContiguous(ret)) {
            PyArray_ENABLEFLAGS(ret, NPY_ARRAY_F_CONTIGUOUS);
            if (PyArray_NDIM(ret) > 1) {
                PyArray_CLEARFLAGS(ret, NPY_ARRAY_C_CONTIGUOUS);
            }
        }
        else {
            PyArray_CLEARFLAGS(ret, NPY_ARRAY_F_CONTIGUOUS);
        }
    }
    if (flagmask & NPY_ARRAY_C_CONTIGUOUS) {
        if (_IsContiguous(ret)) {
            PyArray_ENABLEFLAGS(ret, NPY_ARRAY_C_CONTIGUOUS);
            if (PyArray_NDIM(ret) > 1) {
                PyArray_CLEARFLAGS(ret, NPY_ARRAY_F_CONTIGUOUS);
            }
        }
        else {
            PyArray_CLEARFLAGS(ret, NPY_ARRAY_C_CONTIGUOUS);
        }
    }
    if (flagmask & NPY_ARRAY_ALIGNED) {
        if (_IsAligned(ret)) {
            PyArray_ENABLEFLAGS(ret, NPY_ARRAY_ALIGNED);
        }
        else {
            PyArray_CLEARFLAGS(ret, NPY_ARRAY_ALIGNED);
        }
    }
    /*
     * This is not checked by default WRITEABLE is not
     * part of UPDATE_ALL
     */
    if (flagmask & NPY_ARRAY_WRITEABLE) {
        if (_IsWriteable(ret)) {
            PyArray_ENABLEFLAGS(ret, NPY_ARRAY_WRITEABLE);
        }
        else {
            PyArray_CLEARFLAGS(ret, NPY_ARRAY_WRITEABLE);
        }
    }
    return;
}
Esempio n. 2
0
/*NUMPY_API
 * Update Several Flags at once.
 */
NPY_NO_EXPORT void
PyArray_UpdateFlags(PyArrayObject *ret, int flagmask)
{

    if (flagmask & FORTRAN) {
        if (_IsFortranContiguous(ret)) {
            ret->flags |= FORTRAN;
            if (ret->nd > 1) {
                ret->flags &= ~CONTIGUOUS;
            }
        }
        else {
            ret->flags &= ~FORTRAN;
        }
    }
    if (flagmask & CONTIGUOUS) {
        if (_IsContiguous(ret)) {
            ret->flags |= CONTIGUOUS;
            if (ret->nd > 1) {
                ret->flags &= ~FORTRAN;
            }
        }
        else {
            ret->flags &= ~CONTIGUOUS;
        }
    }
    if (flagmask & ALIGNED) {
        if (_IsAligned(ret)) {
            ret->flags |= ALIGNED;
        }
        else {
            ret->flags &= ~ALIGNED;
        }
    }
    /*
     * This is not checked by default WRITEABLE is not
     * part of UPDATE_ALL
     */
    if (flagmask & WRITEABLE) {
        if (_IsWriteable(ret)) {
            ret->flags |= WRITEABLE;
        }
        else {
            ret->flags &= ~WRITEABLE;
        }
    }
    return;
}