diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2012-01-28 12:18:36 -0700 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2012-02-04 16:11:38 -0700 |
commit | 215a91a9a0e790273a3dc1203709190025ce0641 (patch) | |
tree | 5eb06f85a8e789cf7776194e13cae8c597d639a2 /numpy/core | |
parent | 48d6edb89112bf00eaaa55f4b7d284b68a9ab84f (diff) | |
download | numpy-215a91a9a0e790273a3dc1203709190025ce0641.tar.gz |
STY: core/src - replace macros in old_defines.h with new versions.
Diffstat (limited to 'numpy/core')
29 files changed, 269 insertions, 269 deletions
diff --git a/numpy/core/src/multiarray/arrayobject.c b/numpy/core/src/multiarray/arrayobject.c index 5ca5d22f0..202ff6813 100644 --- a/numpy/core/src/multiarray/arrayobject.c +++ b/numpy/core/src/multiarray/arrayobject.c @@ -157,7 +157,7 @@ PyArray_CopyObject(PyArrayObject *dest, PyObject *src_object) * Special code to mimic Numeric behavior for * character arrays. */ - if (PyArray_DESCR(dest)->type == PyArray_CHARLTR && + if (PyArray_DESCR(dest)->type == NPY_CHARLTR && PyArray_NDIM(dest) > 0 && PyString_Check(src_object)) { npy_intp n_new, n_old; @@ -325,7 +325,7 @@ PyArray_CopyObject(PyArrayObject *dest, PyObject *src_object) /* Given a string return the type-number for the data-type with that string as the type-object name. - Returns PyArray_NOTYPE without setting an error if no type can be + Returns NPY_NOTYPE without setting an error if no type can be found. Only works for user-defined data-types. */ @@ -343,7 +343,7 @@ PyArray_TypeNumFromName(char *str) return descr->type_num; } } - return PyArray_NOTYPE; + return NPY_NOTYPE; } /*********************** end C-API functions **********************/ @@ -676,7 +676,7 @@ array_str(PyArrayObject *self) NPY_NO_EXPORT int PyArray_CompareUCS4(npy_ucs4 *s1, npy_ucs4 *s2, size_t len) { - PyArray_UCS4 c1, c2; + npy_ucs4 c1, c2; while(len-- > 0) { c1 = *s1++; c2 = *s2++; @@ -712,21 +712,21 @@ PyArray_CompareString(char *s1, char *s2, size_t len) If they are NULL terminated, then stop comparison. */ static int -_myunincmp(PyArray_UCS4 *s1, PyArray_UCS4 *s2, int len1, int len2) +_myunincmp(npy_ucs4 *s1, npy_ucs4 *s2, int len1, int len2) { - PyArray_UCS4 *sptr; - PyArray_UCS4 *s1t=s1, *s2t=s2; + npy_ucs4 *sptr; + npy_ucs4 *s1t=s1, *s2t=s2; int val; npy_intp size; int diff; - if ((npy_intp)s1 % sizeof(PyArray_UCS4) != 0) { - size = len1*sizeof(PyArray_UCS4); + if ((npy_intp)s1 % sizeof(npy_ucs4) != 0) { + size = len1*sizeof(npy_ucs4); s1t = malloc(size); memcpy(s1t, s1, size); } - if ((npy_intp)s2 % sizeof(PyArray_UCS4) != 0) { - size = len2*sizeof(PyArray_UCS4); + if ((npy_intp)s2 % sizeof(npy_ucs4) != 0) { + size = len2*sizeof(npy_ucs4); s2t = malloc(size); memcpy(s2t, s2, size); } @@ -825,11 +825,11 @@ static void _rstripw(char *s, int n) } } -static void _unistripw(PyArray_UCS4 *s, int n) +static void _unistripw(npy_ucs4 *s, int n) { int i; for (i = n - 1; i >= 1; i--) { /* Never strip to length 0. */ - PyArray_UCS4 c = s[i]; + npy_ucs4 c = s[i]; if (!c || isspace(c)) { s[i] = 0; } @@ -866,22 +866,22 @@ _char_release(char *ptr, int nc) static char * _uni_copy_n_strip(char *original, char *temp, int nc) { - if (nc*sizeof(PyArray_UCS4) > SMALL_STRING) { - temp = malloc(nc*sizeof(PyArray_UCS4)); + if (nc*sizeof(npy_ucs4) > SMALL_STRING) { + temp = malloc(nc*sizeof(npy_ucs4)); if (!temp) { PyErr_NoMemory(); return NULL; } } - memcpy(temp, original, nc*sizeof(PyArray_UCS4)); - _unistripw((PyArray_UCS4 *)temp, nc); + memcpy(temp, original, nc*sizeof(npy_ucs4)); + _unistripw((npy_ucs4 *)temp, nc); return temp; } static void _uni_release(char *ptr, int nc) { - if (nc*sizeof(PyArray_UCS4) > SMALL_STRING) { + if (nc*sizeof(npy_ucs4) > SMALL_STRING) { free(ptr); } } @@ -1025,8 +1025,8 @@ _strings_richcompare(PyArrayObject *self, PyArrayObject *other, int cmp_op, return Py_NotImplemented; #else PyObject *new; - if (PyArray_TYPE(self) == PyArray_STRING && - PyArray_DESCR(other)->type_num == PyArray_UNICODE) { + if (PyArray_TYPE(self) == NPY_STRING && + PyArray_DESCR(other)->type_num == NPY_UNICODE) { PyArray_Descr* unicode = PyArray_DescrNew(PyArray_DESCR(other)); unicode->elsize = PyArray_DESCR(self)->elsize << 2; new = PyArray_FromAny((PyObject *)self, unicode, @@ -1037,8 +1037,8 @@ _strings_richcompare(PyArrayObject *self, PyArrayObject *other, int cmp_op, Py_INCREF(other); self = (PyArrayObject *)new; } - else if (PyArray_TYPE(self) == PyArray_UNICODE && - PyArray_DESCR(other)->type_num == PyArray_STRING) { + else if (PyArray_TYPE(self) == NPY_UNICODE && + PyArray_DESCR(other)->type_num == NPY_STRING) { PyArray_Descr* unicode = PyArray_DescrNew(PyArray_DESCR(self)); unicode->elsize = PyArray_DESCR(other)->elsize << 2; new = PyArray_FromAny((PyObject *)other, unicode, @@ -1071,7 +1071,7 @@ _strings_richcompare(PyArrayObject *self, PyArrayObject *other, int cmp_op, } result = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type, - PyArray_DescrFromType(PyArray_BOOL), + PyArray_DescrFromType(NPY_BOOL), mit->nd, mit->dimensions, NULL, NULL, 0, @@ -1166,7 +1166,7 @@ _void_compare(PyArrayObject *self, PyArrayObject *other, int cmp_op) sizeof(intp)*result_ndim); dimensions[result_ndim] = -1; temp2 = PyArray_Newshape((PyArrayObject *)temp, - &newdims, PyArray_ANYORDER); + &newdims, NPY_ANYORDER); if (temp2 == NULL) { Py_DECREF(temp); Py_XDECREF(res); @@ -1178,7 +1178,7 @@ _void_compare(PyArrayObject *self, PyArrayObject *other, int cmp_op) /* Reduce the extra dimension of `temp` using `op` */ temp2 = PyArray_GenericReduceFunction((PyArrayObject *)temp, op, result_ndim, - PyArray_BOOL, NULL); + NPY_BOOL, NULL); if (temp2 == NULL) { Py_DECREF(temp); Py_XDECREF(res); @@ -1354,11 +1354,11 @@ array_richcompare(PyArrayObject *self, PyObject *other, int cmp_op) } if (result == Py_NotImplemented) { /* Try to handle string comparisons */ - if (PyArray_TYPE(self) == PyArray_OBJECT) { + if (PyArray_TYPE(self) == NPY_OBJECT) { return result; } array_other = (PyArrayObject *)PyArray_FromObject(other, - PyArray_NOTYPE, 0, 0); + NPY_NOTYPE, 0, 0); if (PyArray_ISSTRING(self) && PyArray_ISSTRING(array_other)) { Py_DECREF(result); result = _strings_richcompare(self, (PyArrayObject *) diff --git a/numpy/core/src/multiarray/arraytypes.c.src b/numpy/core/src/multiarray/arraytypes.c.src index 3225965ef..8f72f919e 100644 --- a/numpy/core/src/multiarray/arraytypes.c.src +++ b/numpy/core/src/multiarray/arraytypes.c.src @@ -306,9 +306,9 @@ static PyObject * UNICODE_getitem(char *ip, PyArrayObject *ap) { intp elsize = PyArray_DESCR(ap)->elsize; - intp mysize = elsize/sizeof(PyArray_UCS4); + intp mysize = elsize/sizeof(npy_ucs4); int alloc = 0; - PyArray_UCS4 *buffer = NULL; + npy_ucs4 *buffer = NULL; PyUnicodeObject *obj; intp i; @@ -321,11 +321,11 @@ UNICODE_getitem(char *ip, PyArrayObject *ap) alloc = 1; memcpy(buffer, ip, elsize); if (!PyArray_ISNOTSWAPPED(ap)) { - byte_swap_vector(buffer, mysize, sizeof(PyArray_UCS4)); + byte_swap_vector(buffer, mysize, sizeof(npy_ucs4)); } } else { - buffer = (PyArray_UCS4 *)ip; + buffer = (npy_ucs4 *)ip; } for (i = mysize; i > 0 && buffer[--i] == 0; mysize = i); @@ -418,7 +418,7 @@ UNICODE_setitem(PyObject *op, char *ov, PyArrayObject *ap) else { buffer = ov; } - datalen = PyUCS2Buffer_AsUCS4(ptr, (PyArray_UCS4 *)buffer, + datalen = PyUCS2Buffer_AsUCS4(ptr, (npy_ucs4 *)buffer, datalen >> 1, PyArray_DESCR(ap)->elsize >> 2); datalen <<= 2; if (!PyArray_ISALIGNED(ap)) { @@ -804,7 +804,7 @@ VOID_setitem(PyObject *op, char *ip, PyArrayObject *ap) if (res == -1) { goto fail; } - memcpy(ip, buffer, NPY_MIN(buflen, itemsize)); + memcpy(ip, buffer, PyArray_MIN(buflen, itemsize)); if (itemsize > buflen) { memset(ip + buflen, 0, itemsize - buflen); } @@ -2176,7 +2176,7 @@ STRING_nonzero (char *ip, PyArrayObject *ap) #endif static Bool -UNICODE_nonzero (PyArray_UCS4 *ip, PyArrayObject *ap) +UNICODE_nonzero (npy_ucs4 *ip, PyArrayObject *ap) { int len = PyArray_DESCR(ap)->elsize >> 2; int i; @@ -2192,7 +2192,7 @@ UNICODE_nonzero (PyArray_UCS4 *ip, PyArrayObject *ap) if (!PyArray_ISNOTSWAPPED(ap)) { byte_swap_vector(buffer, len, 4); } - ip = (PyArray_UCS4 *)buffer; + ip = (npy_ucs4 *)buffer; } for (i = 0; i < len; i++) { @@ -2504,7 +2504,7 @@ STRING_compare(char *ip1, char *ip2, PyArrayObject *ap) /* unicode type */ static int -UNICODE_compare(PyArray_UCS4 *ip1, PyArray_UCS4 *ip2, +UNICODE_compare(npy_ucs4 *ip1, npy_ucs4 *ip2, PyArrayObject *ap) { int itemsize = PyArray_DESCR(ap)->elsize; @@ -2513,8 +2513,8 @@ UNICODE_compare(PyArray_UCS4 *ip1, PyArray_UCS4 *ip2, return 0; } while (itemsize-- > 0) { - PyArray_UCS4 c1 = *ip1++; - PyArray_UCS4 c2 = *ip2++; + npy_ucs4 c1 = *ip1++; + npy_ucs4 c2 = *ip2++; if (c1 != c2) { return (c1 < c2) ? -1 : 1; } @@ -2795,7 +2795,7 @@ OBJECT_argmax(PyObject **ip, intp n, intp *max_ind, PyArrayObject *NPY_UNUSED(ai /**begin repeat * * #fname = STRING, UNICODE# - * #type = char, PyArray_UCS4# + * #type = char, npy_ucs4# */ static int @fname@_argmax(@type@ *ip, intp n, intp *max_ind, PyArrayObject *aip) @@ -2851,7 +2851,7 @@ OBJECT_argmin(PyObject **ip, intp n, intp *min_ind, PyArrayObject *NPY_UNUSED(ai /**begin repeat * * #fname = STRING, UNICODE# - * #type = char, PyArray_UCS4# + * #type = char, npy_ucs4# */ static int @fname@_argmin(@type@ *ip, intp n, intp *min_ind, PyArrayObject *aip) @@ -3475,7 +3475,7 @@ static int * #from = VOID, STRING, UNICODE# * #suff = void, string, unicode# * #sort = 0, 1, 1# - * #align = char, char, PyArray_UCS4# + * #align = char, char, npy_ucs4# * #NAME = Void, String, Unicode# * #endian = |, |, =# */ @@ -3935,55 +3935,55 @@ set_typeinfo(PyObject *dict) PyDict_SetItemString(infodict, "OBJECT", #if defined(NPY_PY3K) - s = Py_BuildValue("CiiiO", PyArray_OBJECTLTR, + s = Py_BuildValue("CiiiO", NPY_OBJECTLTR, #else - s = Py_BuildValue("ciiiO", PyArray_OBJECTLTR, + s = Py_BuildValue("ciiiO", NPY_OBJECTLTR, #endif - PyArray_OBJECT, + NPY_OBJECT, sizeof(PyObject *) * CHAR_BIT, _ALIGN(PyObject *), (PyObject *) &PyObjectArrType_Type)); Py_DECREF(s); PyDict_SetItemString(infodict, "STRING", #if defined(NPY_PY3K) - s = Py_BuildValue("CiiiO", PyArray_STRINGLTR, + s = Py_BuildValue("CiiiO", NPY_STRINGLTR, #else - s = Py_BuildValue("ciiiO", PyArray_STRINGLTR, + s = Py_BuildValue("ciiiO", NPY_STRINGLTR, #endif - PyArray_STRING, + NPY_STRING, 0, _ALIGN(char), (PyObject *) &PyStringArrType_Type)); Py_DECREF(s); PyDict_SetItemString(infodict, "UNICODE", #if defined(NPY_PY3K) - s = Py_BuildValue("CiiiO", PyArray_UNICODELTR, + s = Py_BuildValue("CiiiO", NPY_UNICODELTR, #else - s = Py_BuildValue("ciiiO", PyArray_UNICODELTR, + s = Py_BuildValue("ciiiO", NPY_UNICODELTR, #endif - PyArray_UNICODE, + NPY_UNICODE, 0, - _ALIGN(PyArray_UCS4), + _ALIGN(npy_ucs4), (PyObject *) &PyUnicodeArrType_Type)); Py_DECREF(s); PyDict_SetItemString(infodict, "VOID", #if defined(NPY_PY3K) - s = Py_BuildValue("CiiiO", PyArray_VOIDLTR, + s = Py_BuildValue("CiiiO", NPY_VOIDLTR, #else - s = Py_BuildValue("ciiiO", PyArray_VOIDLTR, + s = Py_BuildValue("ciiiO", NPY_VOIDLTR, #endif - PyArray_VOID, + NPY_VOID, 0, _ALIGN(char), (PyObject *) &PyVoidArrType_Type)); Py_DECREF(s); PyDict_SetItemString(infodict, "DATETIME", #if defined(NPY_PY3K) - s = Py_BuildValue("CiiiNNO", PyArray_DATETIMELTR, + s = Py_BuildValue("CiiiNNO", NPY_DATETIMELTR, #else - s = Py_BuildValue("ciiiNNO", PyArray_DATETIMELTR, + s = Py_BuildValue("ciiiNNO", NPY_DATETIMELTR, #endif - PyArray_DATETIME, + NPY_DATETIME, sizeof(npy_datetime) * CHAR_BIT, _ALIGN(npy_datetime), MyPyLong_FromInt64(MAX_DATETIME), @@ -3992,11 +3992,11 @@ set_typeinfo(PyObject *dict) Py_DECREF(s); PyDict_SetItemString(infodict, "TIMEDELTA", #if defined(NPY_PY3K) - s = Py_BuildValue("CiiiNNO", PyArray_TIMEDELTALTR, + s = Py_BuildValue("CiiiNNO", NPY_TIMEDELTALTR, #else - s = Py_BuildValue("ciiiNNO",PyArray_TIMEDELTALTR, + s = Py_BuildValue("ciiiNNO",NPY_TIMEDELTALTR, #endif - PyArray_TIMEDELTA, + NPY_TIMEDELTA, sizeof(npy_timedelta) * CHAR_BIT, _ALIGN(npy_timedelta), MyPyLong_FromInt64(MAX_TIMEDELTA), diff --git a/numpy/core/src/multiarray/buffer.c b/numpy/core/src/multiarray/buffer.c index de283604b..11bf711f1 100644 --- a/numpy/core/src/multiarray/buffer.c +++ b/numpy/core/src/multiarray/buffer.c @@ -762,7 +762,7 @@ _descriptor_from_pep3118_format(char *s) PyObject *_numpy_internal; if (s == NULL) { - return PyArray_DescrNewFromType(PyArray_BYTE); + return PyArray_DescrNewFromType(NPY_BYTE); } /* Strip whitespace, except from field names */ diff --git a/numpy/core/src/multiarray/calculation.c b/numpy/core/src/multiarray/calculation.c index eea59f24a..b993ea3ec 100644 --- a/numpy/core/src/multiarray/calculation.c +++ b/numpy/core/src/multiarray/calculation.c @@ -101,7 +101,7 @@ PyArray_ArgMax(PyArrayObject *op, int axis, PyArrayObject *out) if (!out) { rp = (PyArrayObject *)PyArray_New(Py_TYPE(ap), PyArray_NDIM(ap)-1, - PyArray_DIMS(ap), PyArray_INTP, + PyArray_DIMS(ap), NPY_INTP, NULL, NULL, 0, 0, (PyObject *)ap); if (rp == NULL) { @@ -115,7 +115,7 @@ PyArray_ArgMax(PyArrayObject *op, int axis, PyArrayObject *out) "invalid shape for output array."); } rp = (PyArrayObject *)PyArray_FromArray(out, - PyArray_DescrFromType(PyArray_INTP), + PyArray_DescrFromType(NPY_INTP), NPY_ARRAY_CARRAY | NPY_ARRAY_UPDATEIFCOPY); if (rp == NULL) { goto fail; @@ -214,7 +214,7 @@ PyArray_ArgMin(PyArrayObject *op, int axis, PyArrayObject *out) if (!out) { rp = (PyArrayObject *)PyArray_New(Py_TYPE(ap), PyArray_NDIM(ap)-1, - PyArray_DIMS(ap), PyArray_INTP, + PyArray_DIMS(ap), NPY_INTP, NULL, NULL, 0, 0, (PyObject *)ap); if (rp == NULL) { @@ -228,7 +228,7 @@ PyArray_ArgMin(PyArrayObject *op, int axis, PyArrayObject *out) "invalid shape for output array."); } rp = (PyArrayObject *)PyArray_FromArray(out, - PyArray_DescrFromType(PyArray_INTP), + PyArray_DescrFromType(NPY_INTP), NPY_ARRAY_CARRAY | NPY_ARRAY_UPDATEIFCOPY); if (rp == NULL) { goto fail; @@ -795,7 +795,7 @@ PyArray_Any(PyArrayObject *self, int axis, PyArrayObject *out) } ret = PyArray_GenericReduceFunction((PyArrayObject *)arr, n_ops.logical_or, axis, - PyArray_BOOL, out); + NPY_BOOL, out); Py_DECREF(arr); return ret; } @@ -814,7 +814,7 @@ PyArray_All(PyArrayObject *self, int axis, PyArrayObject *out) } ret = PyArray_GenericReduceFunction((PyArrayObject *)arr, n_ops.logical_and, axis, - PyArray_BOOL, out); + NPY_BOOL, out); Py_DECREF(arr); return ret; } diff --git a/numpy/core/src/multiarray/common.c b/numpy/core/src/multiarray/common.c index 1eceeae1a..1d3948bf6 100644 --- a/numpy/core/src/multiarray/common.c +++ b/numpy/core/src/multiarray/common.c @@ -19,27 +19,27 @@ NPY_NO_EXPORT PyArray_Descr * _array_find_python_scalar_type(PyObject *op) { if (PyFloat_Check(op)) { - return PyArray_DescrFromType(PyArray_DOUBLE); + return PyArray_DescrFromType(NPY_DOUBLE); } else if (PyComplex_Check(op)) { - return PyArray_DescrFromType(PyArray_CDOUBLE); + return PyArray_DescrFromType(NPY_CDOUBLE); } else if (PyInt_Check(op)) { /* bools are a subclass of int */ if (PyBool_Check(op)) { - return PyArray_DescrFromType(PyArray_BOOL); + return PyArray_DescrFromType(NPY_BOOL); } else { - return PyArray_DescrFromType(PyArray_LONG); + return PyArray_DescrFromType(NPY_LONG); } } else if (PyLong_Check(op)) { /* if integer can fit into a longlong then return that*/ if ((PyLong_AsLongLong(op) == -1) && PyErr_Occurred()) { PyErr_Clear(); - return PyArray_DescrFromType(PyArray_OBJECT); + return PyArray_DescrFromType(NPY_OBJECT); } - return PyArray_DescrFromType(PyArray_LONGLONG); + return PyArray_DescrFromType(NPY_LONGLONG); } return NULL; } diff --git a/numpy/core/src/multiarray/conversion_utils.c b/numpy/core/src/multiarray/conversion_utils.c index 7823b6960..68d6e75fb 100644 --- a/numpy/core/src/multiarray/conversion_utils.c +++ b/numpy/core/src/multiarray/conversion_utils.c @@ -379,7 +379,7 @@ PyArray_ByteorderConverter(PyObject *obj, char *endian) obj = tmp = PyUnicode_AsASCIIString(obj); } - *endian = PyArray_SWAP; + *endian = NPY_SWAP; str = PyBytes_AsString(obj); if (!str) { Py_XDECREF(tmp); @@ -392,22 +392,22 @@ PyArray_ByteorderConverter(PyObject *obj, char *endian) return PY_FAIL; } *endian = str[0]; - if (str[0] != PyArray_BIG && str[0] != PyArray_LITTLE - && str[0] != PyArray_NATIVE && str[0] != PyArray_IGNORE) { + if (str[0] != NPY_BIG && str[0] != NPY_LITTLE + && str[0] != NPY_NATIVE && str[0] != NPY_IGNORE) { if (str[0] == 'b' || str[0] == 'B') { - *endian = PyArray_BIG; + *endian = NPY_BIG; } else if (str[0] == 'l' || str[0] == 'L') { - *endian = PyArray_LITTLE; + *endian = NPY_LITTLE; } else if (str[0] == 'n' || str[0] == 'N') { - *endian = PyArray_NATIVE; + *endian = NPY_NATIVE; } else if (str[0] == 'i' || str[0] == 'I') { - *endian = PyArray_IGNORE; + *endian = NPY_IGNORE; } else if (str[0] == 's' || str[0] == 'S') { - *endian = PyArray_SWAP; + *endian = NPY_SWAP; } else { PyErr_Format(PyExc_ValueError, @@ -434,7 +434,7 @@ PyArray_SortkindConverter(PyObject *obj, NPY_SORTKIND *sortkind) obj = tmp = PyUnicode_AsASCIIString(obj); } - *sortkind = PyArray_QUICKSORT; + *sortkind = NPY_QUICKSORT; str = PyBytes_AsString(obj); if (!str) { Py_XDECREF(tmp); @@ -447,13 +447,13 @@ PyArray_SortkindConverter(PyObject *obj, NPY_SORTKIND *sortkind) return PY_FAIL; } if (str[0] == 'q' || str[0] == 'Q') { - *sortkind = PyArray_QUICKSORT; + *sortkind = NPY_QUICKSORT; } else if (str[0] == 'h' || str[0] == 'H') { - *sortkind = PyArray_HEAPSORT; + *sortkind = NPY_HEAPSORT; } else if (str[0] == 'm' || str[0] == 'M') { - *sortkind = PyArray_MERGESORT; + *sortkind = NPY_MERGESORT; } else { PyErr_Format(PyExc_ValueError, @@ -1030,7 +1030,7 @@ PyArray_TypestrConvert(int itemsize, int gentype) case 8: newtype = NPY_INT64; break; -#ifdef PyArray_INT128 +#ifdef NPY_INT128 case 16: newtype = NPY_INT128; break; @@ -1052,7 +1052,7 @@ PyArray_TypestrConvert(int itemsize, int gentype) case 8: newtype = NPY_UINT64; break; -#ifdef PyArray_INT128 +#ifdef NPY_INT128 case 16: newtype = NPY_UINT128; break; @@ -1071,17 +1071,17 @@ PyArray_TypestrConvert(int itemsize, int gentype) case 8: newtype = NPY_FLOAT64; break; -#ifdef PyArray_FLOAT80 +#ifdef NPY_FLOAT80 case 10: newtype = NPY_FLOAT80; break; #endif -#ifdef PyArray_FLOAT96 +#ifdef NPY_FLOAT96 case 12: newtype = NPY_FLOAT96; break; #endif -#ifdef PyArray_FLOAT128 +#ifdef NPY_FLOAT128 case 16: newtype = NPY_FLOAT128; break; @@ -1097,17 +1097,17 @@ PyArray_TypestrConvert(int itemsize, int gentype) case 16: newtype = NPY_COMPLEX128; break; -#ifdef PyArray_FLOAT80 +#ifdef NPY_FLOAT80 case 20: newtype = NPY_COMPLEX160; break; #endif -#ifdef PyArray_FLOAT96 +#ifdef NPY_FLOAT96 case 24: newtype = NPY_COMPLEX192; break; #endif -#ifdef PyArray_FLOAT128 +#ifdef NPY_FLOAT128 case 32: newtype = NPY_COMPLEX256; break; diff --git a/numpy/core/src/multiarray/convert.c b/numpy/core/src/multiarray/convert.c index 555256c63..e55f33140 100644 --- a/numpy/core/src/multiarray/convert.c +++ b/numpy/core/src/multiarray/convert.c @@ -257,7 +257,7 @@ PyArray_ToString(PyArrayObject *self, NPY_ORDER order) if (order == NPY_ANYORDER) order = PyArray_ISFORTRAN(self); - /* if (PyArray_TYPE(self) == PyArray_OBJECT) { + /* if (PyArray_TYPE(self) == NPY_OBJECT) { PyErr_SetString(PyExc_ValueError, "a string for the data" \ "in an object array is not appropriate"); return NULL; diff --git a/numpy/core/src/multiarray/convert_datatype.c b/numpy/core/src/multiarray/convert_datatype.c index d519efe69..88463c6b5 100644 --- a/numpy/core/src/multiarray/convert_datatype.c +++ b/numpy/core/src/multiarray/convert_datatype.c @@ -287,7 +287,7 @@ PyArray_AdaptFlexibleDType(PyObject *data_obj, PyArray_Descr *data_dtype, /* * Must be broadcastable. * This code is very similar to PyArray_CopyInto/PyArray_MoveInto - * except casting is done --- PyArray_BUFSIZE is used + * except casting is done --- NPY_BUFSIZE is used * as the size of the casting buffer. */ @@ -352,7 +352,7 @@ PyArray_CanCastSafely(int fromtype, int totype) from = PyArray_DescrFromType(fromtype); /* - * cancastto is a PyArray_NOTYPE terminated C-int-array of types that + * cancastto is a NPY_NOTYPE terminated C-int-array of types that * the data-type can be cast to safely. */ if (from->f->cancastto) { @@ -734,7 +734,7 @@ PyArray_CanCastScalar(PyTypeObject *from, PyTypeObject *to) fromtype = _typenum_fromtypeobj((PyObject *)from, 0); totype = _typenum_fromtypeobj((PyObject *)to, 0); - if (fromtype == PyArray_NOTYPE || totype == PyArray_NOTYPE) { + if (fromtype == NPY_NOTYPE || totype == NPY_NOTYPE) { return FALSE; } return (npy_bool) PyArray_CanCastSafely(fromtype, totype); diff --git a/numpy/core/src/multiarray/ctors.c b/numpy/core/src/multiarray/ctors.c index a24767faa..fec6e63c1 100644 --- a/numpy/core/src/multiarray/ctors.c +++ b/numpy/core/src/multiarray/ctors.c @@ -918,7 +918,7 @@ PyArray_NewFromDescr(PyTypeObject *subtype, PyArray_Descr *descr, int nd, sd = descr->elsize = 1; } else { - sd = descr->elsize = sizeof(PyArray_UCS4); + sd = descr->elsize = sizeof(npy_ucs4); } } @@ -1273,7 +1273,7 @@ _array_from_buffer_3118(PyObject *obj, PyObject **out) } } else { - descr = PyArray_DescrNewFromType(PyArray_STRING); + descr = PyArray_DescrNewFromType(NPY_STRING); descr->elsize = view->itemsize; } @@ -2142,7 +2142,7 @@ PyArray_FromStructInterface(PyObject *input) PyArrayInterface *inter; PyObject *attr; PyArrayObject *ret; - char endian = PyArray_NATBYTE; + char endian = NPY_NATBYTE; attr = PyObject_GetAttrString(input, "__array_struct__"); if (attr == NULL) { @@ -3288,7 +3288,7 @@ PyArray_ArangeObj(PyObject *start, PyObject *stop, PyObject *step, PyArray_Descr * order version. And then swap on the way out. */ if (!PyArray_ISNBO(dtype->byteorder)) { - native = PyArray_DescrNewByteorder(dtype, PyArray_NATBYTE); + native = PyArray_DescrNewByteorder(dtype, NPY_NATBYTE); swap = 1; } else { @@ -3470,7 +3470,7 @@ array_from_text(PyArray_Descr *dtype, npy_intp num, char *sep, size_t *nread, } } if (num < 0) { - tmp = PyDataMem_RENEW(PyArray_DATA(r), NPY_MAX(*nread,1)*dtype->elsize); + tmp = PyDataMem_RENEW(PyArray_DATA(r), PyArray_MAX(*nread,1)*dtype->elsize); if (tmp == NULL) { err = 1; } @@ -3549,7 +3549,7 @@ PyArray_FromFile(FILE *fp, PyArray_Descr *dtype, npy_intp num, char *sep) } if (((npy_intp) nread) < num) { /* Realloc memory for smaller number of elements */ - const size_t nsize = NPY_MAX(nread,1)*PyArray_DESCR(ret)->elsize; + const size_t nsize = PyArray_MAX(nread,1)*PyArray_DESCR(ret)->elsize; char *tmp; if((tmp = PyDataMem_RENEW(PyArray_DATA(ret), nsize)) == NULL) { diff --git a/numpy/core/src/multiarray/descriptor.c b/numpy/core/src/multiarray/descriptor.c index 7e7daa724..16aab402a 100644 --- a/numpy/core/src/multiarray/descriptor.c +++ b/numpy/core/src/multiarray/descriptor.c @@ -227,7 +227,7 @@ _convert_from_tuple(PyObject *obj) goto fail; } PyArray_DESCR_REPLACE(type); - if (type->type_num == PyArray_UNICODE) { + if (type->type_num == NPY_UNICODE) { type->elsize = itemsize << 2; } else { @@ -244,7 +244,7 @@ _convert_from_tuple(PyObject *obj) else { /* * interpret next item as shape (if it's a tuple) - * and reset the type to PyArray_VOID with + * and reset the type to NPY_VOID with * a new fields attribute. */ PyArray_Dims shape = {NULL, -1}; @@ -268,7 +268,7 @@ _convert_from_tuple(PyObject *obj) PyDimMem_FREE(shape.ptr); return type; } - newdescr = PyArray_DescrNewFromType(PyArray_VOID); + newdescr = PyArray_DescrNewFromType(NPY_VOID); if (newdescr == NULL) { PyDimMem_FREE(shape.ptr); goto fail; @@ -471,7 +471,7 @@ _convert_from_array_descr(PyObject *obj, int align) totalsize = NPY_NEXT_ALIGNED_OFFSET(totalsize, maxalign); } - new = PyArray_DescrNewFromType(PyArray_VOID); + new = PyArray_DescrNewFromType(NPY_VOID); if (new == NULL) { Py_XDECREF(fields); Py_XDECREF(nameslist); @@ -565,7 +565,7 @@ _convert_from_list(PyObject *obj, int align) PyTuple_SET_ITEM(nameslist, i, key); totalsize += conv->elsize; } - new = PyArray_DescrNewFromType(PyArray_VOID); + new = PyArray_DescrNewFromType(NPY_VOID); new->fields = fields; new->names = nameslist; new->flags = dtypeflags; @@ -1142,7 +1142,7 @@ PyArray_DescrConverter2(PyObject *obj, PyArray_Descr **at) NPY_NO_EXPORT int PyArray_DescrConverter(PyObject *obj, PyArray_Descr **at) { - int check_num = PyArray_NOTYPE + 10; + int check_num = NPY_NOTYPE + 10; PyObject *item; int elsize = 0; char endian = '='; @@ -1376,7 +1376,7 @@ PyArray_DescrConverter(PyObject *obj, PyArray_Descr **at) } finish: - if ((check_num == PyArray_NOTYPE + 10) + if ((check_num == NPY_NOTYPE + 10) || (*at = PyArray_DescrFromType(check_num)) == NULL) { PyErr_Clear(); /* Now check to see if the object is registered in typeDict */ @@ -1552,7 +1552,7 @@ arraydescr_protocol_typestr_get(PyArray_Descr *self) endian = '>'; } } - if (self->type_num == PyArray_UNICODE) { + if (self->type_num == NPY_UNICODE) { size >>= 2; } @@ -2100,14 +2100,14 @@ arraydescr_reduce(PyArray_Descr *self, PyObject *NPY_UNUSED(args)) } PyTuple_SET_ITEM(ret, 0, obj); if (PyTypeNum_ISUSERDEF(self->type_num) - || ((self->type_num == PyArray_VOID + || ((self->type_num == NPY_VOID && self->typeobj != &PyVoidArrType_Type))) { obj = (PyObject *)self->typeobj; Py_INCREF(obj); } else { elsize = self->elsize; - if (self->type_num == PyArray_UNICODE) { + if (self->type_num == NPY_UNICODE) { elsize >>= 2; } obj = PyUString_FromFormat("%c%d",self->kind, elsize); @@ -2193,11 +2193,11 @@ static int _descr_find_object(PyArray_Descr *self) { if (self->flags - || self->type_num == PyArray_OBJECT + || self->type_num == NPY_OBJECT || self->kind == 'O') { return NPY_OBJECT_DTYPE_FLAGS; } - if (PyDescr_HASFIELDS(self)) { + if (PyDataType_HASFIELDS(self)) { PyObject *key, *value, *title = NULL; PyArray_Descr *new; int offset; @@ -2483,7 +2483,7 @@ arraydescr_setstate(PyArray_Descr *self, PyObject *args) * naming). If itemsize is given it must be >= size computed from fields * * The .fields attribute must return a convertible dictionary if present. - * Result inherits from PyArray_VOID. + * Result inherits from NPY_VOID. */ NPY_NO_EXPORT int PyArray_DescrAlignConverter(PyObject *obj, PyArray_Descr **at) @@ -2580,18 +2580,18 @@ PyArray_DescrNewByteorder(PyArray_Descr *self, char newendian) new = PyArray_DescrNew(self); endian = new->byteorder; - if (endian != PyArray_IGNORE) { - if (newendian == PyArray_SWAP) { + if (endian != NPY_IGNORE) { + if (newendian == NPY_SWAP) { /* swap byteorder */ if PyArray_ISNBO(endian) { - endian = PyArray_OPPBYTE; + endian = NPY_OPPBYTE; } else { - endian = PyArray_NATBYTE; + endian = NPY_NATBYTE; } new->byteorder = endian; } - else if (newendian != PyArray_IGNORE) { + else if (newendian != NPY_IGNORE) { new->byteorder = newendian; } } @@ -2649,7 +2649,7 @@ PyArray_DescrNewByteorder(PyArray_Descr *self, char newendian) static PyObject * arraydescr_newbyteorder(PyArray_Descr *self, PyObject *args) { - char endian=PyArray_SWAP; + char endian=NPY_SWAP; if (!PyArg_ParseTuple(args, "|O&", PyArray_ByteorderConverter, &endian)) { diff --git a/numpy/core/src/multiarray/dtype_transfer.c b/numpy/core/src/multiarray/dtype_transfer.c index 943859ae5..8bc6c42a6 100644 --- a/numpy/core/src/multiarray/dtype_transfer.c +++ b/numpy/core/src/multiarray/dtype_transfer.c @@ -2509,7 +2509,7 @@ get_fields_transfer_function(int aligned, _single_field_transfer *fields; /* Copy the src value to all the fields of dst */ - if (!PyDescr_HASFIELDS(src_dtype)) { + if (!PyDataType_HASFIELDS(src_dtype)) { names = dst_dtype->names; names_size = PyTuple_GET_SIZE(dst_dtype->names); @@ -2582,7 +2582,7 @@ get_fields_transfer_function(int aligned, return NPY_SUCCEED; } /* Copy the value of the first field to dst */ - else if (!PyDescr_HASFIELDS(dst_dtype)) { + else if (!PyDataType_HASFIELDS(dst_dtype)) { names = src_dtype->names; names_size = PyTuple_GET_SIZE(src_dtype->names); diff --git a/numpy/core/src/multiarray/getset.c b/numpy/core/src/multiarray/getset.c index 0031b6ece..8dddb592f 100644 --- a/numpy/core/src/multiarray/getset.c +++ b/numpy/core/src/multiarray/getset.c @@ -156,10 +156,10 @@ static PyObject * array_priority_get(PyArrayObject *self) { if (PyArray_CheckExact(self)) { - return PyFloat_FromDouble(PyArray_PRIORITY); + return PyFloat_FromDouble(NPY_PRIORITY); } else { - return PyFloat_FromDouble(PyArray_SUBTYPE_PRIORITY); + return PyFloat_FromDouble(NPY_PRIORITY); } } @@ -601,14 +601,14 @@ _get_part(PyArrayObject *self, int imag) int offset; switch (PyArray_DESCR(self)->type_num) { - case PyArray_CFLOAT: - float_type_num = PyArray_FLOAT; + case NPY_CFLOAT: + float_type_num = NPY_FLOAT; break; - case PyArray_CDOUBLE: - float_type_num = PyArray_DOUBLE; + case NPY_CDOUBLE: + float_type_num = NPY_DOUBLE; break; - case PyArray_CLONGDOUBLE: - float_type_num = PyArray_LONGDOUBLE; + case NPY_CLONGDOUBLE: + float_type_num = NPY_LONGDOUBLE; break; default: PyErr_Format(PyExc_ValueError, diff --git a/numpy/core/src/multiarray/item_selection.c b/numpy/core/src/multiarray/item_selection.c index 8058a9959..4aa52d230 100644 --- a/numpy/core/src/multiarray/item_selection.c +++ b/numpy/core/src/multiarray/item_selection.c @@ -1125,7 +1125,7 @@ PyArray_Sort(PyArrayObject *op, int axis, NPY_SORTKIND which) if (PyArray_DESCR(op)->f->sort[which] != NULL) { return _new_sort(op, axis, which); } - if ((which != PyArray_QUICKSORT) + if ((which != NPY_QUICKSORT) || PyArray_DESCR(op)->f->compare == NULL) { PyErr_SetString(PyExc_TypeError, "desired sort not supported for this type"); @@ -1221,7 +1221,7 @@ PyArray_ArgSort(PyArrayObject *op, int axis, NPY_SORTKIND which) return (PyObject *)ret; } - if ((which != PyArray_QUICKSORT) || PyArray_DESCR(op2)->f->compare == NULL) { + if ((which != NPY_QUICKSORT) || PyArray_DESCR(op2)->f->compare == NULL) { PyErr_SetString(PyExc_TypeError, "requested sort not available for type"); Py_DECREF(op2); @@ -1232,7 +1232,7 @@ PyArray_ArgSort(PyArrayObject *op, int axis, NPY_SORTKIND which) /* ap will contain the reference to op2 */ SWAPAXES(ap, op2); op = (PyArrayObject *)PyArray_ContiguousFromAny((PyObject *)ap, - PyArray_NOTYPE, + NPY_NOTYPE, 1, 0); Py_DECREF(ap); if (op == NULL) { @@ -1340,7 +1340,7 @@ PyArray_LexSort(PyObject *sort_keys, int axis) goto fail; } } - if (!PyArray_DESCR(mps[i])->f->argsort[PyArray_MERGESORT]) { + if (!PyArray_DESCR(mps[i])->f->argsort[NPY_MERGESORT]) { PyErr_Format(PyExc_TypeError, "merge sort not available for item %d", i); goto fail; @@ -1428,7 +1428,7 @@ PyArray_LexSort(PyObject *sort_keys, int axis) for (j = 0; j < n; j++) { elsize = PyArray_DESCR(mps[j])->elsize; astride = PyArray_STRIDES(mps[j])[axis]; - argsort = PyArray_DESCR(mps[j])->f->argsort[PyArray_MERGESORT]; + argsort = PyArray_DESCR(mps[j])->f->argsort[NPY_MERGESORT]; _unaligned_strided_byte_copy(valbuffer, (intp) elsize, its[j]->dataptr, astride, N, elsize); if (swaps[j]) { @@ -1457,7 +1457,7 @@ PyArray_LexSort(PyObject *sort_keys, int axis) *iptr++ = i; } for (j = 0; j < n; j++) { - argsort = PyArray_DESCR(mps[j])->f->argsort[PyArray_MERGESORT]; + argsort = PyArray_DESCR(mps[j])->f->argsort[NPY_MERGESORT]; if (argsort(its[j]->dataptr, (intp *)rit->dataptr, N, mps[j]) < 0) { goto fail; diff --git a/numpy/core/src/multiarray/iterators.c b/numpy/core/src/multiarray/iterators.c index e359b26a6..4347b9aee 100644 --- a/numpy/core/src/multiarray/iterators.c +++ b/numpy/core/src/multiarray/iterators.c @@ -882,7 +882,7 @@ iter_subscript(PyArrayIterObject *self, PyObject *ind) } /* convert to INTP array if Integer array scalar or List */ - indtype = PyArray_DescrFromType(PyArray_INTP); + indtype = PyArray_DescrFromType(NPY_INTP); if (PyArray_IsScalar(ind, Integer) || PyList_Check(ind)) { Py_INCREF(indtype); obj = PyArray_FromAny(ind, indtype, 0, 0, NPY_ARRAY_FORCECAST, NULL); @@ -1145,7 +1145,7 @@ iter_ass_subscript(PyArrayIterObject *self, PyObject *ind, PyObject *val) } /* convert to INTP array if Integer array scalar or List */ - indtype = PyArray_DescrFromType(PyArray_INTP); + indtype = PyArray_DescrFromType(NPY_INTP); if (PyList_Check(ind)) { Py_INCREF(indtype); obj = PyArray_FromAny(ind, indtype, 0, 0, NPY_ARRAY_FORCECAST, NULL); @@ -1157,7 +1157,7 @@ iter_ass_subscript(PyArrayIterObject *self, PyObject *ind, PyObject *val) if (obj != NULL && PyArray_Check(obj)) { /* Check for Boolean object */ - if (PyArray_TYPE((PyArrayObject *)obj)==PyArray_BOOL) { + if (PyArray_TYPE((PyArrayObject *)obj)==NPY_BOOL) { if (iter_ass_sub_Bool(self, (PyArrayObject *)obj, val_it, swap) < 0) { goto finish; diff --git a/numpy/core/src/multiarray/mapping.c b/numpy/core/src/multiarray/mapping.c index ed03105d5..15952fe93 100644 --- a/numpy/core/src/multiarray/mapping.c +++ b/numpy/core/src/multiarray/mapping.c @@ -242,7 +242,7 @@ _swap_axes(PyArrayMapIterObject *mit, PyArrayObject **ret, int getmap) for (i = 0; i < mit->nd-PyArray_NDIM(arr); i++) { permute.ptr[i] = 1; } - new = PyArray_Newshape(arr, &permute, PyArray_ANYORDER); + new = PyArray_Newshape(arr, &permute, NPY_ANYORDER); Py_DECREF(arr); *ret = (PyArrayObject *)new; if (new == NULL) { @@ -1928,7 +1928,7 @@ _nonzero_indices(PyObject *myBool, PyArrayIterObject **iters) /* create count-sized index arrays for each dimension */ for (j = 0; j < nd; j++) { new = (PyArrayObject *)PyArray_New(&PyArray_Type, 1, &count, - PyArray_INTP, NULL, NULL, + NPY_INTP, NULL, NULL, 0, 0, NULL); if (new == NULL) { goto fail; @@ -2000,7 +2000,7 @@ _convert_obj(PyObject *obj, PyArrayIterObject **iter) return _nonzero_indices(obj, iter); } else { - indtype = PyArray_DescrFromType(PyArray_INTP); + indtype = PyArray_DescrFromType(NPY_INTP); arr = PyArray_FromAny(obj, indtype, 0, 0, NPY_ARRAY_FORCECAST, NULL); if (arr == NULL) { return -1; diff --git a/numpy/core/src/multiarray/methods.c b/numpy/core/src/multiarray/methods.c index 8e01bc1c9..24af4db5b 100644 --- a/numpy/core/src/multiarray/methods.c +++ b/numpy/core/src/multiarray/methods.c @@ -176,7 +176,7 @@ array_reshape(PyArrayObject *self, PyObject *args, PyObject *kwds) static char *keywords[] = {"order", NULL}; PyArray_Dims newshape; PyObject *ret; - PyArray_ORDER order = NPY_CORDER; + NPY_ORDER order = NPY_CORDER; Py_ssize_t n = PyTuple_Size(args); if (!NpyArg_ParseKeywords(kwds, "|O&", keywords, @@ -1107,7 +1107,7 @@ array_getarray(PyArrayObject *self, PyObject *args) static PyObject * array_copy(PyArrayObject *self, PyObject *args, PyObject *kwds) { - PyArray_ORDER order = NPY_CORDER; + NPY_ORDER order = NPY_CORDER; PyObject *maskna_in = Py_None; int maskna = -1; static char *kwlist[] = {"order", "maskna", NULL}; @@ -1247,7 +1247,7 @@ array_sort(PyArrayObject *self, PyObject *args, PyObject *kwds) { int axis=-1; int val; - PyArray_SORTKIND sortkind = PyArray_QUICKSORT; + NPY_SORTKIND sortkind = NPY_QUICKSORT; PyObject *order = NULL; PyArray_Descr *saved = NULL; PyArray_Descr *newd; @@ -1303,7 +1303,7 @@ static PyObject * array_argsort(PyArrayObject *self, PyObject *args, PyObject *kwds) { int axis = -1; - PyArray_SORTKIND sortkind = PyArray_QUICKSORT; + NPY_SORTKIND sortkind = NPY_QUICKSORT; PyObject *order = NULL, *res; PyArray_Descr *newd, *saved=NULL; static char *kwlist[] = {"axis", "kind", "order", NULL}; @@ -1371,7 +1371,7 @@ _deepcopy_call(char *iptr, char *optr, PyArray_Descr *dtype, if (!PyDataType_REFCHK(dtype)) { return; } - else if (PyDescr_HASFIELDS(dtype)) { + else if (PyDataType_HASFIELDS(dtype)) { PyObject *key, *value, *title = NULL; PyArray_Descr *new; int offset; @@ -1737,11 +1737,11 @@ array_setstate(PyArrayObject *self, PyObject *args) } else { fa->descr = PyArray_DescrNew(typecode); - if (PyArray_DESCR(self)->byteorder == PyArray_BIG) { - PyArray_DESCR(self)->byteorder = PyArray_LITTLE; + if (PyArray_DESCR(self)->byteorder == NPY_BIG) { + PyArray_DESCR(self)->byteorder = NPY_LITTLE; } - else if (PyArray_DESCR(self)->byteorder == PyArray_LITTLE) { - PyArray_DESCR(self)->byteorder = PyArray_BIG; + else if (PyArray_DESCR(self)->byteorder == NPY_LITTLE) { + PyArray_DESCR(self)->byteorder = NPY_BIG; } } Py_DECREF(typecode); @@ -1900,7 +1900,7 @@ array_transpose(PyArrayObject *self, PyObject *args) return ret; } -#define _CHKTYPENUM(typ) ((typ) ? (typ)->type_num : PyArray_NOTYPE) +#define _CHKTYPENUM(typ) ((typ) ? (typ)->type_num : NPY_NOTYPE) static PyObject * array_mean(PyArrayObject *self, PyObject *args, PyObject *kwds) @@ -2185,7 +2185,7 @@ array_diagonal(PyArrayObject *self, PyObject *args, PyObject *kwds) static PyObject * array_flatten(PyArrayObject *self, PyObject *args, PyObject *kwds) { - PyArray_ORDER order = NPY_CORDER; + NPY_ORDER order = NPY_CORDER; static char *kwlist[] = {"order", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O&", kwlist, @@ -2199,7 +2199,7 @@ array_flatten(PyArrayObject *self, PyObject *args, PyObject *kwds) static PyObject * array_ravel(PyArrayObject *self, PyObject *args, PyObject *kwds) { - PyArray_ORDER order = NPY_CORDER; + NPY_ORDER order = NPY_CORDER; static char *kwlist[] = {"order", NULL}; if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O&", kwlist, @@ -2301,7 +2301,7 @@ array_setflags(PyArrayObject *self, PyObject *args, PyObject *kwds) static PyObject * array_newbyteorder(PyArrayObject *self, PyObject *args) { - char endian = PyArray_SWAP; + char endian = NPY_SWAP; PyArray_Descr *new; if (!PyArg_ParseTuple(args, "|O&", PyArray_ByteorderConverter, diff --git a/numpy/core/src/multiarray/multiarraymodule.c b/numpy/core/src/multiarray/multiarraymodule.c index d06e782a1..fff1c5ce3 100644 --- a/numpy/core/src/multiarray/multiarraymodule.c +++ b/numpy/core/src/multiarray/multiarraymodule.c @@ -662,9 +662,9 @@ _signbit_set(PyArrayObject *arr) byteorder = PyArray_DESCR(arr)->byteorder; ptr = PyArray_DATA(arr); if (elsize > 1 && - (byteorder == PyArray_LITTLE || - (byteorder == PyArray_NATIVE && - PyArray_ISNBO(PyArray_LITTLE)))) { + (byteorder == NPY_LITTLE || + (byteorder == NPY_NATIVE && + PyArray_ISNBO(NPY_LITTLE)))) { ptr += elsize - 1; } return ((*ptr & bitmask) != 0); @@ -684,14 +684,14 @@ _signbit_set(PyArrayObject *arr) NPY_NO_EXPORT NPY_SCALARKIND PyArray_ScalarKind(int typenum, PyArrayObject **arr) { - NPY_SCALARKIND ret = PyArray_NOSCALAR; + NPY_SCALARKIND ret = NPY_NOSCALAR; if ((unsigned int)typenum < NPY_NTYPES) { ret = _npy_scalar_kinds_table[typenum]; /* Signed integer types are INTNEG in the table */ - if (ret == PyArray_INTNEG_SCALAR) { + if (ret == NPY_INTNEG_SCALAR) { if (!arr || !_signbit_set(*arr)) { - ret = PyArray_INTPOS_SCALAR; + ret = NPY_INTPOS_SCALAR; } } } else if (PyTypeNum_ISUSERDEF(typenum)) { @@ -719,13 +719,13 @@ PyArray_CanCoerceScalar(int thistype, int neededtype, int *castlist; /* If 'thistype' is not a scalar, it must be safely castable */ - if (scalar == PyArray_NOSCALAR) { + if (scalar == NPY_NOSCALAR) { return PyArray_CanCastSafely(thistype, neededtype); } if ((unsigned int)neededtype < NPY_NTYPES) { NPY_SCALARKIND neededscalar; - if (scalar == PyArray_OBJECT_SCALAR) { + if (scalar == NPY_OBJECT_SCALAR) { return PyArray_CanCastSafely(thistype, neededtype); } @@ -754,7 +754,7 @@ PyArray_CanCoerceScalar(int thistype, int neededtype, from = PyArray_DescrFromType(thistype); if (from->f->cancastscalarkindto && (castlist = from->f->cancastscalarkindto[scalar])) { - while (*castlist != PyArray_NOTYPE) { + while (*castlist != NPY_NOTYPE) { if (*castlist++ == neededtype) { Py_DECREF(from); return 1; diff --git a/numpy/core/src/multiarray/number.c b/numpy/core/src/multiarray/number.c index a1caa849a..a4e42ead0 100644 --- a/numpy/core/src/multiarray/number.c +++ b/numpy/core/src/multiarray/number.c @@ -140,9 +140,9 @@ static PyObject * _get_keywords(int rtype, PyArrayObject *out) { PyObject *kwds = NULL; - if (rtype != PyArray_NOTYPE || out != NULL) { + if (rtype != NPY_NOTYPE || out != NULL) { kwds = PyDict_New(); - if (rtype != PyArray_NOTYPE) { + if (rtype != NPY_NOTYPE) { PyArray_Descr *descr; descr = PyArray_DescrFromType(rtype); if (descr) { diff --git a/numpy/core/src/multiarray/refcount.c b/numpy/core/src/multiarray/refcount.c index 409d4d30f..9e5bd888e 100644 --- a/numpy/core/src/multiarray/refcount.c +++ b/numpy/core/src/multiarray/refcount.c @@ -1,5 +1,5 @@ /* - * This module corresponds to the `Special functions for PyArray_OBJECT` + * This module corresponds to the `Special functions for NPY_OBJECT` * section in the numpy reference for C-API. */ @@ -31,11 +31,11 @@ PyArray_Item_INCREF(char *data, PyArray_Descr *descr) if (!PyDataType_REFCHK(descr)) { return; } - if (descr->type_num == PyArray_OBJECT) { + if (descr->type_num == NPY_OBJECT) { NPY_COPY_PYOBJECT_PTR(&temp, data); Py_XINCREF(temp); } - else if (PyDescr_HASFIELDS(descr)) { + else if (PyDataType_HASFIELDS(descr)) { PyObject *key, *value, *title = NULL; PyArray_Descr *new; int offset; @@ -67,11 +67,11 @@ PyArray_Item_XDECREF(char *data, PyArray_Descr *descr) return; } - if (descr->type_num == PyArray_OBJECT) { + if (descr->type_num == NPY_OBJECT) { NPY_COPY_PYOBJECT_PTR(&temp, data); Py_XDECREF(temp); } - else if PyDescr_HASFIELDS(descr) { + else if PyDataType_HASFIELDS(descr) { PyObject *key, *value, *title = NULL; PyArray_Descr *new; int offset; @@ -107,7 +107,7 @@ PyArray_INCREF(PyArrayObject *mp) if (!PyDataType_REFCHK(PyArray_DESCR(mp))) { return 0; } - if (PyArray_DESCR(mp)->type_num != PyArray_OBJECT) { + if (PyArray_DESCR(mp)->type_num != NPY_OBJECT) { it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)mp); if (it == NULL) { return -1; @@ -165,7 +165,7 @@ PyArray_XDECREF(PyArrayObject *mp) if (!PyDataType_REFCHK(PyArray_DESCR(mp))) { return 0; } - if (PyArray_DESCR(mp)->type_num != PyArray_OBJECT) { + if (PyArray_DESCR(mp)->type_num != NPY_OBJECT) { it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)mp); if (it == NULL) { return -1; @@ -214,7 +214,7 @@ PyArray_FillObjectArray(PyArrayObject *arr, PyObject *obj) { intp i,n; n = PyArray_SIZE(arr); - if (PyArray_DESCR(arr)->type_num == PyArray_OBJECT) { + if (PyArray_DESCR(arr)->type_num == NPY_OBJECT) { PyObject **optr; optr = (PyObject **)(PyArray_DATA(arr)); n = PyArray_SIZE(arr); @@ -259,7 +259,7 @@ _fillobject(char *optr, PyObject *obj, PyArray_Descr *dtype) Py_XDECREF(arr); } } - else if (PyDescr_HASFIELDS(dtype)) { + else if (PyDataType_HASFIELDS(dtype)) { PyObject *key, *value, *title = NULL; PyArray_Descr *new; int offset; diff --git a/numpy/core/src/multiarray/scalarapi.c b/numpy/core/src/multiarray/scalarapi.c index 0ee4a3b09..0cee4b2ea 100644 --- a/numpy/core/src/multiarray/scalarapi.c +++ b/numpy/core/src/multiarray/scalarapi.c @@ -27,7 +27,7 @@ _descr_from_subtype(PyObject *type) PyObject *mro; mro = ((PyTypeObject *)type)->tp_mro; if (PyTuple_GET_SIZE(mro) < 2) { - return PyArray_DescrFromType(PyArray_OBJECT); + return PyArray_DescrFromType(NPY_OBJECT); } return PyArray_DescrFromTypeObject(PyTuple_GET_ITEM(mro, 1)); } @@ -277,7 +277,7 @@ PyArray_FromScalar(PyObject *scalar, PyArray_Descr *outcode) /* convert to 0-dim array of scalar typecode */ typecode = PyArray_DescrFromScalar(scalar); - if ((typecode->type_num == PyArray_VOID) && + if ((typecode->type_num == NPY_VOID) && !(((PyVoidScalarObject *)scalar)->flags & NPY_ARRAY_OWNDATA) && outcode == NULL) { r = (PyArrayObject *)PyArray_NewFromDescr(&PyArray_Type, @@ -316,9 +316,9 @@ PyArray_FromScalar(PyObject *scalar, PyArray_Descr *outcode) memptr = scalar_value(scalar, typecode); #ifndef Py_UNICODE_WIDE - if (typecode->type_num == PyArray_UNICODE) { + if (typecode->type_num == NPY_UNICODE) { PyUCS2Buffer_AsUCS4((Py_UNICODE *)memptr, - (PyArray_UCS4 *)PyArray_DATA(r), + (npy_ucs4 *)PyArray_DATA(r), PyUnicode_GET_SIZE(scalar), PyArray_ITEMSIZE(r) >> 2); } @@ -454,7 +454,7 @@ PyArray_DescrFromTypeObject(PyObject *type) typenum = NPY_VOID; } - if (typenum != PyArray_NOTYPE) { + if (typenum != NPY_NOTYPE) { return PyArray_DescrFromType(typenum); } @@ -538,13 +538,13 @@ PyArray_DescrFromScalar(PyObject *sc) dt_data = _pya_malloc(sizeof(PyArray_DatetimeMetaData)); if (PyArray_IsScalar(sc, Datetime)) { - descr = PyArray_DescrNewFromType(PyArray_DATETIME); + descr = PyArray_DescrNewFromType(NPY_DATETIME); memcpy(dt_data, &((PyDatetimeScalarObject *)sc)->obmeta, sizeof(PyArray_DatetimeMetaData)); } else { /* Timedelta */ - descr = PyArray_DescrNewFromType(PyArray_TIMEDELTA); + descr = PyArray_DescrNewFromType(NPY_TIMEDELTA); memcpy(dt_data, &((PyTimedeltaScalarObject *)sc)->obmeta, sizeof(PyArray_DatetimeMetaData)); } @@ -572,10 +572,10 @@ PyArray_DescrFromScalar(PyObject *sc) if (descr->elsize == 0) { PyArray_DESCR_REPLACE(descr); type_num = descr->type_num; - if (type_num == PyArray_STRING) { + if (type_num == NPY_STRING) { descr->elsize = PyString_GET_SIZE(sc); } - else if (type_num == PyArray_UNICODE) { + else if (type_num == NPY_UNICODE) { descr->elsize = PyUnicode_GET_DATA_SIZE(sc); #ifndef Py_UNICODE_WIDE descr->elsize <<= 1; @@ -636,7 +636,7 @@ PyArray_Scalar(void *data, PyArray_Descr *descr, PyObject *base) int swap; type_num = descr->type_num; - if (type_num == PyArray_BOOL) { + if (type_num == NPY_BOOL) { PyArrayScalar_RETURN_BOOL_FROM_LONG(*(Bool*)data); } else if (PyDataType_FLAGCHK(descr, NPY_USE_GETITEM)) { @@ -654,7 +654,7 @@ PyArray_Scalar(void *data, PyArray_Descr *descr, PyObject *base) while(itemsize && *dptr-- == 0) { itemsize--; } - if (type_num == PyArray_UNICODE && itemsize) { + if (type_num == NPY_UNICODE && itemsize) { /* * make sure itemsize is a multiple of 4 * so round up to nearest multiple @@ -689,7 +689,7 @@ PyArray_Scalar(void *data, PyArray_Descr *descr, PyObject *base) sizeof(PyArray_DatetimeMetaData)); } if (PyTypeNum_ISFLEXIBLE(type_num)) { - if (type_num == PyArray_STRING) { + if (type_num == NPY_STRING) { destptr = PyString_AS_STRING(obj); ((PyStringObject *)obj)->ob_shash = -1; #if !defined(NPY_PY3K) @@ -698,7 +698,7 @@ PyArray_Scalar(void *data, PyArray_Descr *descr, PyObject *base) memcpy(destptr, data, itemsize); return obj; } - else if (type_num == PyArray_UNICODE) { + else if (type_num == NPY_UNICODE) { PyUnicodeObject *uni = (PyUnicodeObject*)obj; size_t length = itemsize >> 2; #ifndef Py_UNICODE_WIDE @@ -746,7 +746,7 @@ PyArray_Scalar(void *data, PyArray_Descr *descr, PyObject *base) * Now convert from the data-buffer */ length = PyUCS2Buffer_FromUCS4(uni->str, - (PyArray_UCS4 *)buffer, itemsize >> 2); + (npy_ucs4 *)buffer, itemsize >> 2); if (alloc) { _pya_free(buffer); } diff --git a/numpy/core/src/multiarray/scalartypes.c.src b/numpy/core/src/multiarray/scalartypes.c.src index 7f95d7c02..71fc8ad95 100644 --- a/numpy/core/src/multiarray/scalartypes.c.src +++ b/numpy/core/src/multiarray/scalartypes.c.src @@ -1220,16 +1220,16 @@ static PyArray_Descr * _realdescr_fromcomplexscalar(PyObject *self, int *typenum) { if (PyArray_IsScalar(self, CDouble)) { - *typenum = PyArray_CDOUBLE; - return PyArray_DescrFromType(PyArray_DOUBLE); + *typenum = NPY_CDOUBLE; + return PyArray_DescrFromType(NPY_DOUBLE); } if (PyArray_IsScalar(self, CFloat)) { - *typenum = PyArray_CFLOAT; - return PyArray_DescrFromType(PyArray_FLOAT); + *typenum = NPY_CFLOAT; + return PyArray_DescrFromType(NPY_FLOAT); } if (PyArray_IsScalar(self, CLongDouble)) { - *typenum = PyArray_CLONGDOUBLE; - return PyArray_DescrFromType(PyArray_LONGDOUBLE); + *typenum = NPY_CLONGDOUBLE; + return PyArray_DescrFromType(NPY_LONGDOUBLE); } return NULL; } @@ -1281,7 +1281,7 @@ gentype_imag_get(PyObject *self) if (ret == NULL) { PyErr_Clear(); obj = PyInt_FromLong(0); - newtype = PyArray_DescrFromType(PyArray_OBJECT); + newtype = PyArray_DescrFromType(NPY_OBJECT); ret = PyArray_Scalar((char *)&obj, newtype, NULL); Py_DECREF(newtype); Py_DECREF(obj); @@ -1624,7 +1624,7 @@ voidtype_setfield(PyVoidScalarObject *self, PyObject *args, PyObject *kwds) dptr = self->obval + offset; - if (typecode->type_num == PyArray_OBJECT) { + if (typecode->type_num == NPY_OBJECT) { PyObject *temp; Py_INCREF(value); NPY_COPY_PYOBJECT_PTR(&temp, dptr); @@ -1709,7 +1709,7 @@ gentype_reduce(PyObject *self, PyObject *NPY_UNUSED(args)) } alloc = 1; newlen = PyUCS2Buffer_AsUCS4((Py_UNICODE *)buffer, - (PyArray_UCS4 *)tmp, + (npy_ucs4 *)tmp, buflen / 2, buflen / 2); buflen = newlen*4; buffer = tmp; @@ -2051,7 +2051,7 @@ voidtype_item(PyVoidScalarObject *self, Py_ssize_t n) intp m; PyObject *flist=NULL, *fieldinfo; - if (!(PyDescr_HASFIELDS(self->descr))) { + if (!(PyDataType_HASFIELDS(self->descr))) { PyErr_SetString(PyExc_IndexError, "can't index void scalar without fields"); return NULL; @@ -2078,7 +2078,7 @@ voidtype_subscript(PyVoidScalarObject *self, PyObject *ind) intp n; PyObject *fieldinfo; - if (!(PyDescr_HASFIELDS(self->descr))) { + if (!(PyDataType_HASFIELDS(self->descr))) { PyErr_SetString(PyExc_IndexError, "can't index void scalar without fields"); return NULL; @@ -2116,7 +2116,7 @@ voidtype_ass_item(PyVoidScalarObject *self, Py_ssize_t n, PyObject *val) PyObject *flist=NULL, *fieldinfo, *newtup; PyObject *res; - if (!(PyDescr_HASFIELDS(self->descr))) { + if (!(PyDataType_HASFIELDS(self->descr))) { PyErr_SetString(PyExc_IndexError, "can't index void scalar without fields"); return -1; @@ -2156,7 +2156,7 @@ voidtype_ass_subscript(PyVoidScalarObject *self, PyObject *ind, PyObject *val) PyObject *fieldinfo, *newtup; PyObject *res; - if (!PyDescr_HASFIELDS(self->descr)) { + if (!PyDataType_HASFIELDS(self->descr)) { PyErr_SetString(PyExc_IndexError, "can't index void scalar without fields"); return -1; @@ -2840,7 +2840,7 @@ void_arrtype_new(PyTypeObject *type, PyObject *args, PyObject *NPY_UNUSED(kwds)) ((PyVoidScalarObject *)ret)->obval = destptr; Py_SIZE((PyVoidScalarObject *)ret) = (int) memu; ((PyVoidScalarObject *)ret)->descr = - PyArray_DescrNewFromType(PyArray_VOID); + PyArray_DescrNewFromType(NPY_VOID); ((PyVoidScalarObject *)ret)->descr->elsize = (int) memu; ((PyVoidScalarObject *)ret)->flags = NPY_ARRAY_BEHAVED | NPY_ARRAY_OWNDATA; @@ -2849,7 +2849,7 @@ void_arrtype_new(PyTypeObject *type, PyObject *args, PyObject *NPY_UNUSED(kwds)) return ret; } - arr = PyArray_FROM_OTF(obj, PyArray_VOID, NPY_ARRAY_FORCECAST); + arr = PyArray_FROM_OTF(obj, NPY_VOID, NPY_ARRAY_FORCECAST); return PyArray_Return((PyArrayObject *)arr); } @@ -3701,7 +3701,7 @@ initialize_casting_tables(void) _npy_smallest_type_of_kind_table[NPY_OBJECT_SCALAR] = NPY_OBJECT; /* Default for built-in types is object scalar */ - memset(_npy_scalar_kinds_table, PyArray_OBJECT_SCALAR, + memset(_npy_scalar_kinds_table, NPY_OBJECT_SCALAR, sizeof(_npy_scalar_kinds_table)); /* Default for next largest type is -1, signalling no bigger */ memset(_npy_next_larger_type_table, -1, @@ -4165,9 +4165,9 @@ _typenum_fromtypeobj(PyObject *type, int user) { int typenum, i; - typenum = PyArray_NOTYPE; + typenum = NPY_NOTYPE; i = 0; - while(i < PyArray_NTYPES) { + while(i < NPY_NTYPES) { if (type == (PyObject *)typeobjects[i]) { typenum = i; break; @@ -4180,9 +4180,9 @@ _typenum_fromtypeobj(PyObject *type, int user) } /* Search any registered types */ i = 0; - while (i < PyArray_NUMUSERTYPES) { + while (i < NPY_NUMUSERTYPES) { if (type == (PyObject *)(userdescrs[i]->typeobj)) { - typenum = i + PyArray_USERDEF; + typenum = i + NPY_USERDEF; break; } i++; diff --git a/numpy/core/src/multiarray/shape.c b/numpy/core/src/multiarray/shape.c index 1c5dc590f..611071cc0 100644 --- a/numpy/core/src/multiarray/shape.c +++ b/numpy/core/src/multiarray/shape.c @@ -379,7 +379,7 @@ PyArray_Reshape(PyArrayObject *self, PyObject *shape) if (!PyArray_IntpConverter(shape, &newdims)) { return NULL; } - ret = PyArray_Newshape(self, &newdims, PyArray_CORDER); + ret = PyArray_Newshape(self, &newdims, NPY_CORDER); PyDimMem_FREE(newdims.ptr); return ret; } @@ -433,7 +433,7 @@ _putzero(char *optr, PyObject *zero, PyArray_Descr *dtype) if (!PyDataType_FLAGCHK(dtype, NPY_ITEM_REFCOUNT)) { memset(optr, 0, dtype->elsize); } - else if (PyDescr_HASFIELDS(dtype)) { + else if (PyDataType_HASFIELDS(dtype)) { PyObject *key, *value, *title = NULL; PyArray_Descr *new; int offset; diff --git a/numpy/core/src/multiarray/ucsnarrow.c b/numpy/core/src/multiarray/ucsnarrow.c index e405a2dbb..689b53d69 100644 --- a/numpy/core/src/multiarray/ucsnarrow.c +++ b/numpy/core/src/multiarray/ucsnarrow.c @@ -29,11 +29,11 @@ values above 0xffff are converted to surrogate pairs. */ NPY_NO_EXPORT int -PyUCS2Buffer_FromUCS4(Py_UNICODE *ucs2, PyArray_UCS4 *ucs4, int ucs4length) +PyUCS2Buffer_FromUCS4(Py_UNICODE *ucs2, npy_ucs4 *ucs4, int ucs4length) { int i; int numucs2 = 0; - PyArray_UCS4 chr; + npy_ucs4 chr; for (i=0; i<ucs4length; i++) { chr = *ucs4++; if (chr > 0xffff) { @@ -61,10 +61,10 @@ PyUCS2Buffer_FromUCS4(Py_UNICODE *ucs2, PyArray_UCS4 *ucs4, int ucs4length) */ NPY_NO_EXPORT int -PyUCS2Buffer_AsUCS4(Py_UNICODE *ucs2, PyArray_UCS4 *ucs4, int ucs2len, int ucs4len) +PyUCS2Buffer_AsUCS4(Py_UNICODE *ucs2, npy_ucs4 *ucs4, int ucs2len, int ucs4len) { int i; - PyArray_UCS4 chr; + npy_ucs4 chr; Py_UNICODE ch; int numchars=0; @@ -72,12 +72,12 @@ PyUCS2Buffer_AsUCS4(Py_UNICODE *ucs2, PyArray_UCS4 *ucs4, int ucs2len, int ucs4l ch = *ucs2++; if (ch >= 0xd800 && ch <= 0xdfff) { /* surrogate pair */ - chr = ((PyArray_UCS4)(ch-0xd800)) << 10; + chr = ((npy_ucs4)(ch-0xd800)) << 10; chr += *ucs2++ + 0x2400; /* -0xdc00 + 0x10000 */ i++; } else { - chr = (PyArray_UCS4) ch; + chr = (npy_ucs4) ch; } *ucs4++ = chr; numchars++; diff --git a/numpy/core/src/multiarray/ucsnarrow.h b/numpy/core/src/multiarray/ucsnarrow.h index 4b0e0c111..6ef645ba0 100644 --- a/numpy/core/src/multiarray/ucsnarrow.h +++ b/numpy/core/src/multiarray/ucsnarrow.h @@ -7,10 +7,10 @@ int int int; #endif NPY_NO_EXPORT int -PyUCS2Buffer_FromUCS4(Py_UNICODE *ucs2, PyArray_UCS4 *ucs4, int ucs4length); +PyUCS2Buffer_FromUCS4(Py_UNICODE *ucs2, npy_ucs4 *ucs4, int ucs4length); NPY_NO_EXPORT int -PyUCS2Buffer_AsUCS4(Py_UNICODE *ucs2, PyArray_UCS4 *ucs4, int ucs2len, int ucs4len); +PyUCS2Buffer_AsUCS4(Py_UNICODE *ucs2, npy_ucs4 *ucs4, int ucs2len, int ucs4len); NPY_NO_EXPORT PyObject * MyPyUnicode_New(int length); diff --git a/numpy/core/src/multiarray/usertypes.c b/numpy/core/src/multiarray/usertypes.c index 61df37b16..49f9618ed 100644 --- a/numpy/core/src/multiarray/usertypes.c +++ b/numpy/core/src/multiarray/usertypes.c @@ -47,12 +47,12 @@ _append_new(int *types, int insert) int n = 0; int *newtypes; - while (types[n] != PyArray_NOTYPE) { + while (types[n] != NPY_NOTYPE) { n++; } newtypes = (int *)realloc(types, (n + 2)*sizeof(int)); newtypes[n] = insert; - newtypes[n + 1] = PyArray_NOTYPE; + newtypes[n + 1] = NPY_NOTYPE; return newtypes; } @@ -111,7 +111,7 @@ PyArray_InitArrFuncs(PyArray_ArrFuncs *f) f->nonzero = NULL; f->fill = NULL; f->fillwithscalar = NULL; - for(i = 0; i < PyArray_NSORTS; i++) { + for(i = 0; i < NPY_NSORTS; i++) { f->sort[i] = NULL; f->argsort[i] = NULL; } @@ -122,7 +122,7 @@ PyArray_InitArrFuncs(PyArray_ArrFuncs *f) } /* - returns typenum to associate with this type >=PyArray_USERDEF. + returns typenum to associate with this type >=NPY_USERDEF. needs the userdecrs table and PyArray_NUMUSER variables defined in arraytypes.inc */ @@ -145,7 +145,7 @@ PyArray_RegisterDataType(PyArray_Descr *descr) return descr->type_num; } } - typenum = PyArray_USERDEF + NPY_NUMUSERTYPES; + typenum = NPY_USERDEF + NPY_NUMUSERTYPES; descr->type_num = typenum; if (descr->elsize == 0) { PyErr_SetString(PyExc_ValueError, "cannot register a" \ @@ -240,7 +240,7 @@ PyArray_RegisterCanCast(PyArray_Descr *descr, int totype, return -1; } - if (scalar == PyArray_NOSCALAR) { + if (scalar == NPY_NOSCALAR) { /* * register with cancastto * These lists won't be freed once created @@ -248,7 +248,7 @@ PyArray_RegisterCanCast(PyArray_Descr *descr, int totype, */ if (descr->f->cancastto == NULL) { descr->f->cancastto = (int *)malloc(1*sizeof(int)); - descr->f->cancastto[0] = PyArray_NOTYPE; + descr->f->cancastto[0] = NPY_NOTYPE; } descr->f->cancastto = _append_new(descr->f->cancastto, totype); @@ -258,8 +258,8 @@ PyArray_RegisterCanCast(PyArray_Descr *descr, int totype, if (descr->f->cancastscalarkindto == NULL) { int i; descr->f->cancastscalarkindto = - (int **)malloc(PyArray_NSCALARKINDS* sizeof(int*)); - for (i = 0; i < PyArray_NSCALARKINDS; i++) { + (int **)malloc(NPY_NSCALARKINDS* sizeof(int*)); + for (i = 0; i < NPY_NSCALARKINDS; i++) { descr->f->cancastscalarkindto[i] = NULL; } } @@ -267,7 +267,7 @@ PyArray_RegisterCanCast(PyArray_Descr *descr, int totype, descr->f->cancastscalarkindto[scalar] = (int *)malloc(1*sizeof(int)); descr->f->cancastscalarkindto[scalar][0] = - PyArray_NOTYPE; + NPY_NOTYPE; } descr->f->cancastscalarkindto[scalar] = _append_new(descr->f->cancastscalarkindto[scalar], totype); diff --git a/numpy/core/src/scalarmathmodule.c.src b/numpy/core/src/scalarmathmodule.c.src index 6f18b043a..113d39fa0 100644 --- a/numpy/core/src/scalarmathmodule.c.src +++ b/numpy/core/src/scalarmathmodule.c.src @@ -610,8 +610,8 @@ _@name@_convert_to_ctype(PyObject *a, npy_@name@ *arg1) return -1; } } - else if (PyArray_GetPriority(a, PyArray_SUBTYPE_PRIORITY) > - PyArray_SUBTYPE_PRIORITY) { + else if (PyArray_GetPriority(a, NPY_PRIORITY) > + NPY_PRIORITY) { return -2; } else if ((temp = PyArray_ScalarFromObject(a)) != NULL) { @@ -1360,7 +1360,7 @@ get_functions(void) i = 0; j = 0; - while(signatures[i] != PyArray_FLOAT) {i+=3; j++;} + while(signatures[i] != NPY_FLOAT) {i+=3; j++;} _basic_half_pow = funcdata[j-1]; _basic_float_pow = funcdata[j]; _basic_double_pow = funcdata[j+1]; @@ -1377,7 +1377,7 @@ get_functions(void) signatures = ((PyUFuncObject *)obj)->types; i = 0; j = 0; - while(signatures[i] != PyArray_FLOAT) {i+=2; j++;} + while(signatures[i] != NPY_FLOAT) {i+=2; j++;} _basic_half_floor = funcdata[j-1]; _basic_float_floor = funcdata[j]; _basic_double_floor = funcdata[j+1]; @@ -1391,7 +1391,7 @@ get_functions(void) signatures = ((PyUFuncObject *)obj)->types; i = 0; j = 0; - while(signatures[i] != PyArray_FLOAT) {i+=2; j++;} + while(signatures[i] != NPY_FLOAT) {i+=2; j++;} _basic_half_sqrt = funcdata[j-1]; _basic_float_sqrt = funcdata[j]; _basic_double_sqrt = funcdata[j+1]; @@ -1405,7 +1405,7 @@ get_functions(void) signatures = ((PyUFuncObject *)obj)->types; i = 0; j = 0; - while(signatures[i] != PyArray_FLOAT) {i+=3; j++;} + while(signatures[i] != NPY_FLOAT) {i+=3; j++;} _basic_half_fmod = funcdata[j-1]; _basic_float_fmod = funcdata[j]; _basic_double_fmod = funcdata[j+1]; diff --git a/numpy/core/src/umath/ufunc_object.c b/numpy/core/src/umath/ufunc_object.c index d87433341..0c7f6b3db 100644 --- a/numpy/core/src/umath/ufunc_object.c +++ b/numpy/core/src/umath/ufunc_object.c @@ -279,10 +279,10 @@ _find_array_prepare(PyObject *args, PyObject *kwds, prep = preps[0]; if (np > 1) { double maxpriority = PyArray_GetPriority(with_prep[0], - PyArray_SUBTYPE_PRIORITY); + NPY_PRIORITY); for (i = 1; i < np; ++i) { double priority = PyArray_GetPriority(with_prep[i], - PyArray_SUBTYPE_PRIORITY); + NPY_PRIORITY); if (priority > maxpriority) { maxpriority = priority; Py_DECREF(prep); @@ -386,14 +386,14 @@ _extract_pyvals(PyObject *ref, char *name, int *bufsize, if ((*bufsize == -1) && PyErr_Occurred()) { return -1; } - if ((*bufsize < PyArray_MIN_BUFSIZE) - || (*bufsize > PyArray_MAX_BUFSIZE) + if ((*bufsize < NPY_MIN_BUFSIZE) + || (*bufsize > NPY_MAX_BUFSIZE) || (*bufsize % 16 != 0)) { PyErr_Format(PyExc_ValueError, "buffer size (%d) is not in range " "(%"INTP_FMT" - %"INTP_FMT") or not a multiple of 16", - *bufsize, (intp) PyArray_MIN_BUFSIZE, - (intp) PyArray_MAX_BUFSIZE); + *bufsize, (intp) NPY_MIN_BUFSIZE, + (intp) NPY_MAX_BUFSIZE); return -1; } @@ -459,7 +459,7 @@ PyUFunc_GetPyValues(char *name, int *bufsize, int *errmask, PyObject **errobj) if (ref == NULL) { *errmask = UFUNC_ERR_DEFAULT; *errobj = Py_BuildValue("NO", PyBytes_FromString(name), Py_None); - *bufsize = PyArray_BUFSIZE; + *bufsize = NPY_BUFSIZE; return 0; } return _extract_pyvals(ref, name, bufsize, errmask, errobj); @@ -3677,7 +3677,7 @@ PyUFunc_GenericReduction(PyUFuncObject *ufunc, PyObject *args, if (operation == UFUNC_REDUCEAT) { PyArray_Descr *indtype; - indtype = PyArray_DescrFromType(PyArray_INTP); + indtype = PyArray_DescrFromType(NPY_INTP); if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO|OO&O&i", kwlist2, &op, &obj_ind, @@ -4003,10 +4003,10 @@ _find_array_wrap(PyObject *args, PyObject *kwds, wrap = wraps[0]; if (np > 1) { double maxpriority = PyArray_GetPriority(with_wrap[0], - PyArray_SUBTYPE_PRIORITY); + NPY_PRIORITY); for (i = 1; i < np; ++i) { double priority = PyArray_GetPriority(with_wrap[i], - PyArray_SUBTYPE_PRIORITY); + NPY_PRIORITY); if (priority > maxpriority) { maxpriority = priority; Py_DECREF(wrap); @@ -4221,7 +4221,7 @@ ufunc_geterr(PyObject *NPY_UNUSED(dummy), PyObject *args) if (res == NULL) { return NULL; } - PyList_SET_ITEM(res, 0, PyInt_FromLong(PyArray_BUFSIZE)); + PyList_SET_ITEM(res, 0, PyInt_FromLong(NPY_BUFSIZE)); PyList_SET_ITEM(res, 1, PyInt_FromLong(UFUNC_ERR_DEFAULT)); PyList_SET_ITEM(res, 2, Py_None); Py_INCREF(Py_None); return res; @@ -4248,7 +4248,7 @@ ufunc_update_use_defaults(void) Py_XDECREF(errobj); return -1; } - if ((errmask != UFUNC_ERR_DEFAULT) || (bufsize != PyArray_BUFSIZE) + if ((errmask != UFUNC_ERR_DEFAULT) || (bufsize != NPY_BUFSIZE) || (PyTuple_GET_ITEM(errobj, 1) != Py_None)) { PyUFunc_NUM_NODEFAULTS += 1; } @@ -4507,7 +4507,7 @@ PyUFunc_RegisterLoopForType(PyUFuncObject *ufunc, int *newtypes=NULL; descr=PyArray_DescrFromType(usertype); - if ((usertype < PyArray_USERDEF) || (descr==NULL)) { + if ((usertype < NPY_USERDEF) || (descr==NULL)) { PyErr_SetString(PyExc_TypeError, "unknown user-defined type"); return -1; } @@ -4688,7 +4688,7 @@ ufunc_outer(PyUFuncObject *ufunc, PyObject *args, PyObject *kwds) if (tmp == NULL) { return NULL; } - ap1 = (PyArrayObject *) PyArray_FromObject(tmp, PyArray_NOTYPE, 0, 0); + ap1 = (PyArrayObject *) PyArray_FromObject(tmp, NPY_NOTYPE, 0, 0); Py_DECREF(tmp); if (ap1 == NULL) { return NULL; @@ -4697,7 +4697,7 @@ ufunc_outer(PyUFuncObject *ufunc, PyObject *args, PyObject *kwds) if (tmp == NULL) { return NULL; } - ap2 = (PyArrayObject *)PyArray_FromObject(tmp, PyArray_NOTYPE, 0, 0); + ap2 = (PyArrayObject *)PyArray_FromObject(tmp, NPY_NOTYPE, 0, 0); Py_DECREF(tmp); if (ap2 == NULL) { Py_DECREF(ap1); diff --git a/numpy/core/src/umath/umath_tests.c.src b/numpy/core/src/umath/umath_tests.c.src index cb1d541f5..3234f8bb1 100644 --- a/numpy/core/src/umath/umath_tests.c.src +++ b/numpy/core/src/umath/umath_tests.c.src @@ -200,13 +200,13 @@ defdict = { static PyUFuncGenericFunction inner1d_functions[] = { LONG_inner1d, DOUBLE_inner1d }; static void * inner1d_data[] = { (void *)NULL, (void *)NULL }; -static char inner1d_signatures[] = { PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE }; +static char inner1d_signatures[] = { NPY_LONG, NPY_LONG, NPY_LONG, NPY_DOUBLE, NPY_DOUBLE, NPY_DOUBLE }; static PyUFuncGenericFunction innerwt_functions[] = { LONG_innerwt, DOUBLE_innerwt }; static void * innerwt_data[] = { (void *)NULL, (void *)NULL }; -static char innerwt_signatures[] = { PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE }; +static char innerwt_signatures[] = { NPY_LONG, NPY_LONG, NPY_LONG, NPY_LONG, NPY_DOUBLE, NPY_DOUBLE, NPY_DOUBLE, NPY_DOUBLE }; static PyUFuncGenericFunction matrix_multiply_functions[] = { LONG_matrix_multiply, FLOAT_matrix_multiply, DOUBLE_matrix_multiply }; static void *matrix_multiply_data[] = { (void *)NULL, (void *)NULL, (void *)NULL }; -static char matrix_multiply_signatures[] = { PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE }; +static char matrix_multiply_signatures[] = { NPY_LONG, NPY_LONG, NPY_LONG, NPY_FLOAT, NPY_FLOAT, NPY_FLOAT, NPY_DOUBLE, NPY_DOUBLE, NPY_DOUBLE }; static void addUfuncs(PyObject *dictionary) { diff --git a/numpy/core/src/umath/umathmodule.c.src b/numpy/core/src/umath/umathmodule.c.src index 9843b0eba..bd3907731 100644 --- a/numpy/core/src/umath/umathmodule.c.src +++ b/numpy/core/src/umath/umathmodule.c.src @@ -174,7 +174,7 @@ ufunc_frompyfunc(PyObject *NPY_UNUSED(dummy), PyObject *args, PyObject *NPY_UNUS self->data[0] = (void *)fdata; self->types = (char *)self->data + sizeof(void *); for (i = 0; i < self->nargs; i++) { - self->types[i] = PyArray_OBJECT; + self->types[i] = NPY_OBJECT; } str = self->types + offset[1]; memcpy(str, fname, fname_len); @@ -213,12 +213,12 @@ static void * blank6_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL}; static char frexp_signatures[] = { #ifdef HAVE_FREXPF - PyArray_HALF, PyArray_HALF, PyArray_INT, - PyArray_FLOAT, PyArray_FLOAT, PyArray_INT, + NPY_HALF, NPY_HALF, NPY_INT, + NPY_FLOAT, NPY_FLOAT, NPY_INT, #endif - PyArray_DOUBLE, PyArray_DOUBLE, PyArray_INT + NPY_DOUBLE, NPY_DOUBLE, NPY_INT #ifdef HAVE_FREXPL - ,PyArray_LONGDOUBLE, PyArray_LONGDOUBLE, PyArray_INT + ,NPY_LONGDOUBLE, NPY_LONGDOUBLE, NPY_INT #endif }; @@ -246,16 +246,16 @@ static PyUFuncGenericFunction ldexp_functions[] = { static char ldexp_signatures[] = { #ifdef HAVE_LDEXPF - PyArray_HALF, PyArray_INT, PyArray_HALF, - PyArray_FLOAT, PyArray_INT, PyArray_FLOAT, - PyArray_HALF, PyArray_LONG, PyArray_HALF, - PyArray_FLOAT, PyArray_LONG, PyArray_FLOAT, + NPY_HALF, NPY_INT, NPY_HALF, + NPY_FLOAT, NPY_INT, NPY_FLOAT, + NPY_HALF, NPY_LONG, NPY_HALF, + NPY_FLOAT, NPY_LONG, NPY_FLOAT, #endif - PyArray_DOUBLE, PyArray_INT, PyArray_DOUBLE, - PyArray_DOUBLE, PyArray_LONG, PyArray_DOUBLE + NPY_DOUBLE, NPY_INT, NPY_DOUBLE, + NPY_DOUBLE, NPY_LONG, NPY_DOUBLE #ifdef HAVE_LDEXPL - ,PyArray_LONGDOUBLE, PyArray_INT, PyArray_LONGDOUBLE - ,PyArray_LONGDOUBLE, PyArray_LONG, PyArray_LONGDOUBLE + ,NPY_LONGDOUBLE, NPY_INT, NPY_LONGDOUBLE + ,NPY_LONGDOUBLE, NPY_LONG, NPY_LONGDOUBLE #endif }; @@ -410,7 +410,7 @@ PyMODINIT_FUNC initumath(void) #undef ADDCONST #undef ADDSCONST - PyModule_AddIntConstant(m, "UFUNC_BUFSIZE_DEFAULT", (long)PyArray_BUFSIZE); + PyModule_AddIntConstant(m, "UFUNC_BUFSIZE_DEFAULT", (long)NPY_BUFSIZE); PyModule_AddObject(m, "PINF", PyFloat_FromDouble(NPY_INFINITY)); PyModule_AddObject(m, "NINF", PyFloat_FromDouble(-NPY_INFINITY)); |