diff options
author | Mark Wiebe <mwwiebe@gmail.com> | 2011-07-15 01:35:39 -0500 |
---|---|---|
committer | Mark Wiebe <mwiebe@enthought.com> | 2011-07-19 14:00:27 -0500 |
commit | 2bb06a5cc043943ba4147b3ddeb5fd8835310200 (patch) | |
tree | ab4b0e2d4f6c77cff1a543da69e4a69271d4cda8 /numpy/numarray | |
parent | 4dce9c07eaa7756c9a6d552ac316137c83e92809 (diff) | |
download | numpy-2bb06a5cc043943ba4147b3ddeb5fd8835310200.tar.gz |
ENH: core: Progress getting NumPy building without direct field access
Diffstat (limited to 'numpy/numarray')
-rw-r--r-- | numpy/numarray/_capi.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/numpy/numarray/_capi.c b/numpy/numarray/_capi.c index 446594d99..f6094426e 100644 --- a/numpy/numarray/_capi.c +++ b/numpy/numarray/_capi.c @@ -1,5 +1,6 @@ #include <Python.h> +#define NPY_NO_DEPRECATED_API #define _libnumarray_MODULE #include "include/numpy/libnumarray.h" #include "numpy/npy_3kcompat.h" @@ -1076,7 +1077,7 @@ NA_OutputArray(PyObject *a, NumarrayType t, int requires) PyArray_Descr *dtype; PyArrayObject *ret; - if (!PyArray_Check(a) || !PyArray_ISWRITEABLE(a)) { + if (!PyArray_Check(a) || !PyArray_ISWRITEABLE((PyArrayObject *)a)) { PyErr_Format(PyExc_TypeError, "NA_OutputArray: only writeable arrays work for output."); return NULL; @@ -1087,18 +1088,22 @@ NA_OutputArray(PyObject *a, NumarrayType t, int requires) return (PyArrayObject *)a; } if (t == tAny) { - dtype = PyArray_DESCR(a); + dtype = PyArray_DESCR((PyArrayObject *)a); Py_INCREF(dtype); } else { dtype = PyArray_DescrFromType(t); } - ret = (PyArrayObject *)PyArray_Empty(PyArray_NDIM(a), PyArray_DIMS(a), - dtype, 0); - ret->flags |= NPY_UPDATEIFCOPY; - ret->base = a; - PyArray_FLAGS(a) &= ~NPY_WRITEABLE; + ret = (PyArrayObject *)PyArray_Empty(PyArray_NDIM((PyArrayObject *)a), + PyArray_DIMS((PyArrayObject *)a), + dtype, 0); Py_INCREF(a); + if (PyArray_SetBase(ret, a) < 0) { + Py_DECREF(ret); + return NULL; + } + PyArray_ENABLEFLAGS(ret, NPY_ARRAY_UPDATEIFCOPY); + PyArray_CLEARFLAGS((PyArrayObject *)a, NPY_ARRAY_WRITEABLE); return ret; } @@ -1114,7 +1119,8 @@ NA_OutputArray(PyObject *a, NumarrayType t, int requires) static PyArrayObject * NA_IoArray(PyObject *a, NumarrayType t, int requires) { - PyArrayObject *shadow = NA_InputArray(a, t, requires | NPY_UPDATEIFCOPY ); + PyArrayObject *shadow = NA_InputArray(a, t, + requires | NPY_ARRAY_UPDATEIFCOPY ); if (!shadow) return NULL; @@ -2482,7 +2488,7 @@ _setFromPythonScalarCore(PyArrayObject *a, long offset, PyObject*value, int entr static int NA_setFromPythonScalar(PyArrayObject *a, long offset, PyObject *value) { - if (a->flags & WRITABLE) + if (PyArray_FLAGS(a) & NPY_ARRAY_WRITEABLE) return _setFromPythonScalarCore(a, offset, value, 0); else { PyErr_Format( @@ -2745,7 +2751,7 @@ NA_swapAxes(PyArrayObject *array, int x, int y) array->strides[x] = array->strides[y]; array->strides[y] = temp; - PyArray_UpdateFlags(array, NPY_UPDATE_ALL); + PyArray_UpdateFlags(array, NPY_ARRAY_UPDATE_ALL); return 0; } @@ -2861,20 +2867,20 @@ NA_NewAllFromBuffer(int ndim, maybelong *shape, NumarrayType type, static void NA_updateAlignment(PyArrayObject *self) { - PyArray_UpdateFlags(self, NPY_ALIGNED); + PyArray_UpdateFlags(self, NPY_ARRAY_ALIGNED); } static void NA_updateContiguous(PyArrayObject *self) { - PyArray_UpdateFlags(self, NPY_CONTIGUOUS | NPY_FORTRAN); + PyArray_UpdateFlags(self, NPY_ARRAY_C_CONTIGUOUS | NPY_ARRAY_F_CONTIGUOUS); } static void NA_updateStatus(PyArrayObject *self) { - PyArray_UpdateFlags(self, NPY_UPDATE_ALL); + PyArray_UpdateFlags(self, NPY_ARRAY_UPDATE_ALL); } static int |