summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2012-02-03 00:11:51 -0700
committerCharles Harris <charlesr.harris@gmail.com>2012-02-04 17:54:36 -0700
commitacad872c5bb8138cd2b0a065830cb88270f1d55f (patch)
treeaaaa4b8bde1f584d090fa5d50fcc5a72ccd20b0f
parent12fb59edc49c52a0800fa08b2f518cda06fc8d87 (diff)
downloadnumpy-acad872c5bb8138cd2b0a065830cb88270f1d55f.tar.gz
UPD: Use prefixed macros in *.c files except numarray and linalg.
-rw-r--r--numpy/core/src/multiarray/arrayobject.c40
-rw-r--r--numpy/core/src/multiarray/buffer.c2
-rw-r--r--numpy/core/src/multiarray/calculation.c10
-rw-r--r--numpy/core/src/multiarray/common.c36
-rw-r--r--numpy/core/src/multiarray/conversion_utils.c144
-rw-r--r--numpy/core/src/multiarray/convert_datatype.c6
-rw-r--r--numpy/core/src/multiarray/ctors.c16
-rw-r--r--numpy/core/src/multiarray/descriptor.c90
-rw-r--r--numpy/core/src/multiarray/flagsobject.c8
-rw-r--r--numpy/core/src/multiarray/getset.c40
-rw-r--r--numpy/core/src/multiarray/item_selection.c172
-rw-r--r--numpy/core/src/multiarray/iterators.c26
-rw-r--r--numpy/core/src/multiarray/mapping.c10
-rw-r--r--numpy/core/src/multiarray/methods.c34
-rw-r--r--numpy/core/src/multiarray/multiarraymodule.c34
-rw-r--r--numpy/core/src/multiarray/number.c2
-rw-r--r--numpy/core/src/multiarray/refcount.c6
-rw-r--r--numpy/core/src/multiarray/scalarapi.c16
-rw-r--r--numpy/core/src/multiarray/sequence.c4
-rw-r--r--numpy/core/src/multiarray/shape.c16
-rw-r--r--numpy/core/src/multiarray/ucsnarrow.c2
-rw-r--r--numpy/core/src/multiarray/usertypes.c6
-rw-r--r--numpy/core/src/umath/ufunc_object.c14
-rw-r--r--numpy/f2py/doc/multiarray/array_from_pyobj.c12
-rw-r--r--numpy/lib/src/_compiled_base.c2
25 files changed, 374 insertions, 374 deletions
diff --git a/numpy/core/src/multiarray/arrayobject.c b/numpy/core/src/multiarray/arrayobject.c
index 202ff6813..8f67820ac 100644
--- a/numpy/core/src/multiarray/arrayobject.c
+++ b/numpy/core/src/multiarray/arrayobject.c
@@ -426,7 +426,7 @@ dump_data(char **string, int *n, int *max_n, char *data, int nd,
#define CHECK_MEMORY do { if (*n >= *max_n-16) { \
*max_n *= 2; \
- *string = (char *)_pya_realloc(*string, *max_n); \
+ *string = (char *)PyArray_realloc(*string, *max_n); \
}} while (0)
if (nd == 0) {
@@ -513,17 +513,17 @@ PyArray_DebugPrint(PyArrayObject *obj)
printf(" flags :");
if (fobj->flags & NPY_ARRAY_C_CONTIGUOUS)
- printf(" C_CONTIGUOUS");
+ printf(" NPY_C_CONTIGUOUS");
if (fobj->flags & NPY_ARRAY_F_CONTIGUOUS)
- printf(" F_CONTIGUOUS");
+ printf(" NPY_F_CONTIGUOUS");
if (fobj->flags & NPY_ARRAY_OWNDATA)
- printf(" OWNDATA");
+ printf(" NPY_OWNDATA");
if (fobj->flags & NPY_ARRAY_ALIGNED)
- printf(" ALIGNED");
+ printf(" NPY_ALIGNED");
if (fobj->flags & NPY_ARRAY_WRITEABLE)
- printf(" WRITEABLE");
+ printf(" NPY_WRITEABLE");
if (fobj->flags & NPY_ARRAY_UPDATEIFCOPY)
- printf(" UPDATEIFCOPY");
+ printf(" NPY_UPDATEIFCOPY");
if (fobj->flags & NPY_ARRAY_MASKNA)
printf(" MASKNA");
if (fobj->flags & NPY_ARRAY_OWNMASKNA)
@@ -561,7 +561,7 @@ array_repr_builtin(PyArrayObject *self, int repr)
max_n = PyArray_NBYTES(self)*4*sizeof(char) + 7;
- if ((string = (char *)_pya_malloc(max_n)) == NULL) {
+ if ((string = (char *)PyArray_malloc(max_n)) == NULL) {
return PyErr_NoMemory();
}
@@ -575,7 +575,7 @@ array_repr_builtin(PyArrayObject *self, int repr)
if (dump_data(&string, &n, &max_n, PyArray_DATA(self),
PyArray_NDIM(self), PyArray_DIMS(self),
PyArray_STRIDES(self), self) < 0) {
- _pya_free(string);
+ PyArray_free(string);
return NULL;
}
@@ -595,7 +595,7 @@ array_repr_builtin(PyArrayObject *self, int repr)
ret = PyUString_FromStringAndSize(string, n);
}
- _pya_free(string);
+ PyArray_free(string);
return ret;
}
@@ -730,7 +730,7 @@ _myunincmp(npy_ucs4 *s1, npy_ucs4 *s2, int len1, int len2)
s2t = malloc(size);
memcpy(s2t, s2, size);
}
- val = PyArray_CompareUCS4(s1t, s2t, MIN(len1,len2));
+ val = PyArray_CompareUCS4(s1t, s2t, PyArray_MIN(len1,len2));
if ((val != 0) || (len1 == len2)) {
goto finish;
}
@@ -778,7 +778,7 @@ _mystrncmp(char *s1, char *s2, int len1, int len2)
int val;
int diff;
- val = memcmp(s1, s2, MIN(len1, len2));
+ val = memcmp(s1, s2, PyArray_MIN(len1, len2));
if ((val != 0) || (len1 == len2)) {
return val;
}
@@ -927,7 +927,7 @@ _compare_strings(PyArrayObject *result, PyArrayMultiIterObject *multi,
int cmp_op, void *func, int rstrip)
{
PyArrayIterObject *iself, *iother;
- Bool *dptr;
+ npy_bool *dptr;
npy_intp size;
int val;
int N1, N2;
@@ -936,7 +936,7 @@ _compare_strings(PyArrayObject *result, PyArrayMultiIterObject *multi,
char* (*stripfunc)(char *, char *, int);
compfunc = func;
- dptr = (Bool *)PyArray_DATA(result);
+ dptr = (npy_bool *)PyArray_DATA(result);
iself = multi->iters[0];
iother = multi->iters[1];
size = multi->size;
@@ -1163,7 +1163,7 @@ _void_compare(PyArrayObject *self, PyArrayObject *other, int cmp_op)
newdims.ptr = dimensions;
newdims.len = result_ndim+1;
memcpy(dimensions, PyArray_DIMS((PyArrayObject *)temp),
- sizeof(intp)*result_ndim);
+ sizeof(npy_intp)*result_ndim);
dimensions[result_ndim] = -1;
temp2 = PyArray_Newshape((PyArrayObject *)temp,
&newdims, NPY_ANYORDER);
@@ -1415,7 +1415,7 @@ PyArray_ElementStrides(PyObject *obj)
*/
/*NUMPY_API*/
-NPY_NO_EXPORT Bool
+NPY_NO_EXPORT npy_bool
PyArray_CheckStrides(int elsize, int nd, npy_intp numbytes, npy_intp offset,
npy_intp *dims, npy_intp *newstrides)
{
@@ -1432,10 +1432,10 @@ PyArray_CheckStrides(int elsize, int nd, npy_intp numbytes, npy_intp offset,
for (i = 0; i < nd; i++) {
byte_begin = newstrides[i]*(dims[i] - 1);
if ((byte_begin < begin) || (byte_begin > end)) {
- return FALSE;
+ return NPY_FALSE;
}
}
- return TRUE;
+ return NPY_TRUE;
}
@@ -1449,7 +1449,7 @@ array_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)
PyArray_Dims dims = {NULL, 0};
PyArray_Dims strides = {NULL, 0};
PyArray_Chunk buffer;
- longlong offset = 0;
+ npy_longlong offset = 0;
NPY_ORDER order = NPY_CORDER;
int is_f_order = 0;
PyArrayObject *ret;
@@ -1608,7 +1608,7 @@ array_alloc(PyTypeObject *type, Py_ssize_t NPY_UNUSED(nitems))
{
PyObject *obj;
/* nitems will always be 0 */
- obj = (PyObject *)_pya_malloc(NPY_SIZEOF_PYARRAYOBJECT);
+ obj = (PyObject *)PyArray_malloc(NPY_SIZEOF_PYARRAYOBJECT);
PyObject_Init(obj, type);
return obj;
}
diff --git a/numpy/core/src/multiarray/buffer.c b/numpy/core/src/multiarray/buffer.c
index 11bf711f1..e2c03e17c 100644
--- a/numpy/core/src/multiarray/buffer.c
+++ b/numpy/core/src/multiarray/buffer.c
@@ -338,7 +338,7 @@ _buffer_format_string(PyArray_Descr *descr, _tmp_string_t *str,
if (is_native_only_type) {
/* It's not possible to express native-only data types
- in non-native byte orders */
+ in non-native npy_byte orders */
PyErr_Format(PyExc_ValueError,
"cannot expose native-only dtype '%c' in "
"non-native byte order '%c' via buffer interface",
diff --git a/numpy/core/src/multiarray/calculation.c b/numpy/core/src/multiarray/calculation.c
index b993ea3ec..7221825c6 100644
--- a/numpy/core/src/multiarray/calculation.c
+++ b/numpy/core/src/multiarray/calculation.c
@@ -56,7 +56,7 @@ PyArray_ArgMax(PyArrayObject *op, int axis, PyArrayObject *out)
*/
if (axis != PyArray_NDIM(ap)-1) {
PyArray_Dims newaxes;
- npy_intp dims[MAX_DIMS];
+ npy_intp dims[NPY_MAXDIMS];
int j;
newaxes.ptr = dims;
@@ -155,8 +155,8 @@ PyArray_ArgMin(PyArrayObject *op, int axis, PyArrayObject *out)
PyArrayObject *ap = NULL, *rp = NULL;
PyArray_ArgFunc* arg_func;
char *ip;
- intp *rptr;
- intp i, n, m;
+ npy_intp *rptr;
+ npy_intp i, n, m;
int elsize;
NPY_BEGIN_THREADS_DEF;
@@ -169,7 +169,7 @@ PyArray_ArgMin(PyArrayObject *op, int axis, PyArrayObject *out)
*/
if (axis != PyArray_NDIM(ap)-1) {
PyArray_Dims newaxes;
- intp dims[MAX_DIMS];
+ npy_intp dims[NPY_MAXDIMS];
int i;
newaxes.ptr = dims;
@@ -237,7 +237,7 @@ PyArray_ArgMin(PyArrayObject *op, int axis, PyArrayObject *out)
NPY_BEGIN_THREADS_DESCR(PyArray_DESCR(ap));
n = PyArray_SIZE(ap)/m;
- rptr = (intp *)PyArray_DATA(rp);
+ rptr = (npy_intp *)PyArray_DATA(rp);
for (ip = PyArray_DATA(ap), i = 0; i < n; i++, ip += elsize*m) {
arg_func(ip, m, rptr, ap);
rptr += 1;
diff --git a/numpy/core/src/multiarray/common.c b/numpy/core/src/multiarray/common.c
index 1d3948bf6..25fef273d 100644
--- a/numpy/core/src/multiarray/common.c
+++ b/numpy/core/src/multiarray/common.c
@@ -372,7 +372,7 @@ _array_typedescr_fromstr(char *str)
size = atoi(str + 1);
switch (typechar) {
case 'b':
- if (size == sizeof(Bool)) {
+ if (size == sizeof(npy_bool)) {
type_num = NPY_BOOL;
}
else {
@@ -381,7 +381,7 @@ _array_typedescr_fromstr(char *str)
}
break;
case 'u':
- if (size == sizeof(uintp)) {
+ if (size == sizeof(npy_uintp)) {
type_num = NPY_UINTP;
}
else if (size == sizeof(char)) {
@@ -390,13 +390,13 @@ _array_typedescr_fromstr(char *str)
else if (size == sizeof(short)) {
type_num = NPY_USHORT;
}
- else if (size == sizeof(ulong)) {
+ else if (size == sizeof(npy_ulong)) {
type_num = NPY_ULONG;
}
else if (size == sizeof(int)) {
type_num = NPY_UINT;
}
- else if (size == sizeof(ulonglong)) {
+ else if (size == sizeof(npy_ulonglong)) {
type_num = NPY_ULONGLONG;
}
else {
@@ -405,7 +405,7 @@ _array_typedescr_fromstr(char *str)
}
break;
case 'i':
- if (size == sizeof(intp)) {
+ if (size == sizeof(npy_intp)) {
type_num = NPY_INTP;
}
else if (size == sizeof(char)) {
@@ -420,7 +420,7 @@ _array_typedescr_fromstr(char *str)
else if (size == sizeof(int)) {
type_num = NPY_INT;
}
- else if (size == sizeof(longlong)) {
+ else if (size == sizeof(npy_longlong)) {
type_num = NPY_LONGLONG;
}
else {
@@ -435,7 +435,7 @@ _array_typedescr_fromstr(char *str)
else if (size == sizeof(double)) {
type_num = NPY_DOUBLE;
}
- else if (size == sizeof(longdouble)) {
+ else if (size == sizeof(npy_longdouble)) {
type_num = NPY_LONGDOUBLE;
}
else {
@@ -450,7 +450,7 @@ _array_typedescr_fromstr(char *str)
else if (size == sizeof(double)*2) {
type_num = NPY_CDOUBLE;
}
- else if (size == sizeof(longdouble)*2) {
+ else if (size == sizeof(npy_longdouble)*2) {
type_num = NPY_CLONGDOUBLE;
}
else {
@@ -504,9 +504,9 @@ _array_typedescr_fromstr(char *str)
}
NPY_NO_EXPORT char *
-index2ptr(PyArrayObject *mp, intp i)
+index2ptr(PyArrayObject *mp, npy_intp i)
{
- intp dim0;
+ npy_intp dim0;
if (PyArray_NDIM(mp) == 0) {
PyErr_SetString(PyExc_IndexError, "0-d arrays can't be indexed");
@@ -539,7 +539,7 @@ _zerofill(PyArrayObject *ret)
}
}
else {
- intp n = PyArray_NBYTES(ret);
+ npy_intp n = PyArray_NBYTES(ret);
memset(PyArray_DATA(ret), 0, n);
}
return 0;
@@ -549,7 +549,7 @@ NPY_NO_EXPORT int
_IsAligned(PyArrayObject *ap)
{
int i, alignment, aligned = 1;
- intp ptr;
+ npy_intp ptr;
/* The special casing for STRING and VOID types was removed
* in accordance with http://projects.scipy.org/numpy/ticket/1227
@@ -562,7 +562,7 @@ _IsAligned(PyArrayObject *ap)
if (alignment == 1) {
return 1;
}
- ptr = (intp) PyArray_DATA(ap);
+ ptr = (npy_intp) PyArray_DATA(ap);
aligned = (ptr % alignment) == 0;
for (i = 0; i < PyArray_NDIM(ap); i++) {
aligned &= ((PyArray_STRIDES(ap)[i] % alignment) == 0);
@@ -570,7 +570,7 @@ _IsAligned(PyArrayObject *ap)
return aligned != 0;
}
-NPY_NO_EXPORT Bool
+NPY_NO_EXPORT npy_bool
_IsWriteable(PyArrayObject *ap)
{
PyObject *base=PyArray_BASE(ap);
@@ -579,7 +579,7 @@ _IsWriteable(PyArrayObject *ap)
/* If we own our own data, then no-problem */
if ((base == NULL) || (PyArray_FLAGS(ap) & NPY_ARRAY_OWNDATA)) {
- return TRUE;
+ return NPY_TRUE;
}
/*
* Get to the final base object
@@ -607,10 +607,10 @@ _IsWriteable(PyArrayObject *ap)
* -- could be abused --
*/
if (PyString_Check(base)) {
- return TRUE;
+ return NPY_TRUE;
}
if (PyObject_AsWriteBuffer(base, &dummy, &n) < 0) {
- return FALSE;
+ return NPY_FALSE;
}
- return TRUE;
+ return NPY_TRUE;
}
diff --git a/numpy/core/src/multiarray/conversion_utils.c b/numpy/core/src/multiarray/conversion_utils.c
index 68d6e75fb..9a225561b 100644
--- a/numpy/core/src/multiarray/conversion_utils.c
+++ b/numpy/core/src/multiarray/conversion_utils.c
@@ -41,15 +41,15 @@ PyArray_Converter(PyObject *object, PyObject **address)
if (PyArray_Check(object) && !PyArray_HASMASKNA((PyArrayObject *)object)) {
*address = object;
Py_INCREF(object);
- return PY_SUCCEED;
+ return NPY_SUCCEED;
}
else {
*address = PyArray_FromAny(object, NULL, 0, 0,
NPY_ARRAY_CARRAY, NULL);
if (*address == NULL) {
- return PY_FAIL;
+ return NPY_FAIL;
}
- return PY_SUCCEED;
+ return NPY_SUCCEED;
}
}
@@ -72,15 +72,15 @@ PyArray_AllowNAConverter(PyObject *object, PyObject **address)
if (PyArray_Check(object)) {
*address = object;
Py_INCREF(object);
- return PY_SUCCEED;
+ return NPY_SUCCEED;
}
else {
*address = PyArray_FromAny(object, NULL, 0, 0,
NPY_ARRAY_CARRAY | NPY_ARRAY_ALLOWNA, NULL);
if (*address == NULL) {
- return PY_FAIL;
+ return NPY_FAIL;
}
- return PY_SUCCEED;
+ return NPY_SUCCEED;
}
}
@@ -93,7 +93,7 @@ PyArray_OutputConverter(PyObject *object, PyArrayObject **address)
{
if (object == NULL || object == Py_None) {
*address = NULL;
- return PY_SUCCEED;
+ return NPY_SUCCEED;
}
if (PyArray_Check(object)) {
if (PyArray_HASMASKNA((PyArrayObject *)object)) {
@@ -101,16 +101,16 @@ PyArray_OutputConverter(PyObject *object, PyArrayObject **address)
"this operation does not yet support output "
"arrays with NA support");
*address = NULL;
- return PY_FAIL;
+ return NPY_FAIL;
}
*address = (PyArrayObject *)object;
- return PY_SUCCEED;
+ return NPY_SUCCEED;
}
else {
PyErr_SetString(PyExc_TypeError,
"output must be an array");
*address = NULL;
- return PY_FAIL;
+ return NPY_FAIL;
}
}
@@ -123,17 +123,17 @@ PyArray_OutputAllowNAConverter(PyObject *object, PyArrayObject **address)
{
if (object == NULL || object == Py_None) {
*address = NULL;
- return PY_SUCCEED;
+ return NPY_SUCCEED;
}
if (PyArray_Check(object)) {
*address = (PyArrayObject *)object;
- return PY_SUCCEED;
+ return NPY_SUCCEED;
}
else {
PyErr_SetString(PyExc_TypeError,
"output must be an array");
*address = NULL;
- return PY_FAIL;
+ return NPY_FAIL;
}
}
@@ -155,7 +155,7 @@ PyArray_IntpConverter(PyObject *obj, PyArray_Dims *seq)
seq->ptr = NULL;
seq->len = 0;
if (obj == Py_None) {
- return PY_SUCCEED;
+ return NPY_SUCCEED;
}
len = PySequence_Size(obj);
if (len == -1) {
@@ -167,18 +167,18 @@ PyArray_IntpConverter(PyObject *obj, PyArray_Dims *seq)
if (len < 0) {
PyErr_SetString(PyExc_TypeError,
"expected sequence object with len >= 0");
- return PY_FAIL;
+ return NPY_FAIL;
}
if (len > NPY_MAXDIMS) {
PyErr_Format(PyExc_ValueError, "sequence too large; "
"must be smaller than %d", NPY_MAXDIMS);
- return PY_FAIL;
+ return NPY_FAIL;
}
if (len > 0) {
seq->ptr = PyDimMem_NEW(len);
if (seq->ptr == NULL) {
PyErr_NoMemory();
- return PY_FAIL;
+ return NPY_FAIL;
}
}
seq->len = len;
@@ -186,9 +186,9 @@ PyArray_IntpConverter(PyObject *obj, PyArray_Dims *seq)
if (nd == -1 || nd != len) {
PyDimMem_FREE(seq->ptr);
seq->ptr = NULL;
- return PY_FAIL;
+ return NPY_FAIL;
}
- return PY_SUCCEED;
+ return NPY_SUCCEED;
}
/*NUMPY_API
@@ -212,14 +212,14 @@ PyArray_BufferConverter(PyObject *obj, PyArray_Chunk *buf)
buf->flags = NPY_ARRAY_BEHAVED;
buf->base = NULL;
if (obj == Py_None) {
- return PY_SUCCEED;
+ return NPY_SUCCEED;
}
if (PyObject_AsWriteBuffer(obj, &(buf->ptr), &buflen) < 0) {
PyErr_Clear();
buf->flags &= ~NPY_ARRAY_WRITEABLE;
if (PyObject_AsReadBuffer(obj, (const void **)&(buf->ptr),
&buflen) < 0) {
- return PY_FAIL;
+ return NPY_FAIL;
}
}
buf->len = (npy_intp) buflen;
@@ -237,7 +237,7 @@ PyArray_BufferConverter(PyObject *obj, PyArray_Chunk *buf)
if (buf->base == NULL) {
buf->base = obj;
}
- return PY_SUCCEED;
+ return NPY_SUCCEED;
}
/*NUMPY_API
@@ -254,10 +254,10 @@ PyArray_AxisConverter(PyObject *obj, int *axis)
else {
*axis = (int) PyInt_AsLong(obj);
if (PyErr_Occurred()) {
- return PY_FAIL;
+ return NPY_FAIL;
}
}
- return PY_SUCCEED;
+ return NPY_SUCCEED;
}
/*
@@ -352,18 +352,18 @@ PyArray_ConvertMultiAxis(PyObject *axis_in, int ndim, npy_bool *out_axis_flags)
* Convert an object to true / false
*/
NPY_NO_EXPORT int
-PyArray_BoolConverter(PyObject *object, Bool *val)
+PyArray_BoolConverter(PyObject *object, npy_bool *val)
{
if (PyObject_IsTrue(object)) {
- *val = TRUE;
+ *val = NPY_TRUE;
}
else {
- *val = FALSE;
+ *val = NPY_FALSE;
}
if (PyErr_Occurred()) {
- return PY_FAIL;
+ return NPY_FAIL;
}
- return PY_SUCCEED;
+ return NPY_SUCCEED;
}
/*NUMPY_API
@@ -383,13 +383,13 @@ PyArray_ByteorderConverter(PyObject *obj, char *endian)
str = PyBytes_AsString(obj);
if (!str) {
Py_XDECREF(tmp);
- return PY_FAIL;
+ return NPY_FAIL;
}
if (strlen(str) < 1) {
PyErr_SetString(PyExc_ValueError,
"Byteorder string must be at least length 1");
Py_XDECREF(tmp);
- return PY_FAIL;
+ return NPY_FAIL;
}
*endian = str[0];
if (str[0] != NPY_BIG && str[0] != NPY_LITTLE
@@ -414,11 +414,11 @@ PyArray_ByteorderConverter(PyObject *obj, char *endian)
"%s is an unrecognized byteorder",
str);
Py_XDECREF(tmp);
- return PY_FAIL;
+ return NPY_FAIL;
}
}
Py_XDECREF(tmp);
- return PY_SUCCEED;
+ return NPY_SUCCEED;
}
/*NUMPY_API
@@ -438,13 +438,13 @@ PyArray_SortkindConverter(PyObject *obj, NPY_SORTKIND *sortkind)
str = PyBytes_AsString(obj);
if (!str) {
Py_XDECREF(tmp);
- return PY_FAIL;
+ return NPY_FAIL;
}
if (strlen(str) < 1) {
PyErr_SetString(PyExc_ValueError,
"Sort kind string must be at least length 1");
Py_XDECREF(tmp);
- return PY_FAIL;
+ return NPY_FAIL;
}
if (str[0] == 'q' || str[0] == 'Q') {
*sortkind = NPY_QUICKSORT;
@@ -460,10 +460,10 @@ PyArray_SortkindConverter(PyObject *obj, NPY_SORTKIND *sortkind)
"%s is an unrecognized kind of sort",
str);
Py_XDECREF(tmp);
- return PY_FAIL;
+ return NPY_FAIL;
}
Py_XDECREF(tmp);
- return PY_SUCCEED;
+ return NPY_SUCCEED;
}
/*NUMPY_API
@@ -485,7 +485,7 @@ PyArray_SearchsideConverter(PyObject *obj, void *addr)
PyErr_SetString(PyExc_ValueError,
"expected nonempty string for keyword 'side'");
Py_XDECREF(tmp);
- return PY_FAIL;
+ return NPY_FAIL;
}
if (str[0] == 'l' || str[0] == 'L') {
@@ -498,10 +498,10 @@ PyArray_SearchsideConverter(PyObject *obj, void *addr)
PyErr_Format(PyExc_ValueError,
"'%s' is an invalid value for keyword 'side'", str);
Py_XDECREF(tmp);
- return PY_FAIL;
+ return NPY_FAIL;
}
Py_XDECREF(tmp);
- return PY_SUCCEED;
+ return NPY_SUCCEED;
}
/*NUMPY_API
@@ -513,7 +513,7 @@ PyArray_OrderConverter(PyObject *object, NPY_ORDER *val)
char *str;
/* Leave the desired default from the caller for NULL/Py_None */
if (object == NULL || object == Py_None) {
- return PY_SUCCEED;
+ return NPY_SUCCEED;
}
else if (PyUnicode_Check(object)) {
PyObject *tmp;
@@ -531,9 +531,9 @@ PyArray_OrderConverter(PyObject *object, NPY_ORDER *val)
*val = NPY_CORDER;
}
if (PyErr_Occurred()) {
- return PY_FAIL;
+ return NPY_FAIL;
}
- return PY_SUCCEED;
+ return NPY_SUCCEED;
}
else {
str = PyBytes_AS_STRING(object);
@@ -552,10 +552,10 @@ PyArray_OrderConverter(PyObject *object, NPY_ORDER *val)
else {
PyErr_SetString(PyExc_TypeError,
"order not understood");
- return PY_FAIL;
+ return NPY_FAIL;
}
}
- return PY_SUCCEED;
+ return NPY_SUCCEED;
}
/*NUMPY_API
@@ -582,7 +582,7 @@ PyArray_ClipmodeConverter(PyObject *object, NPY_CLIPMODE *val)
else {
PyErr_SetString(PyExc_TypeError,
"clipmode not understood");
- return PY_FAIL;
+ return NPY_FAIL;
}
}
else if (PyUnicode_Check(object)) {
@@ -606,12 +606,12 @@ PyArray_ClipmodeConverter(PyObject *object, NPY_CLIPMODE *val)
goto fail;
}
}
- return PY_SUCCEED;
+ return NPY_SUCCEED;
fail:
PyErr_SetString(PyExc_TypeError,
"clipmode not understood");
- return PY_FAIL;
+ return NPY_FAIL;
}
/*NUMPY_API
@@ -629,32 +629,32 @@ PyArray_ConvertClipmodeSequence(PyObject *object, NPY_CLIPMODE *modes, int n)
PyErr_Format(PyExc_ValueError,
"list of clipmodes has wrong length (%d instead of %d)",
(int)PySequence_Size(object), n);
- return PY_FAIL;
+ return NPY_FAIL;
}
for (i = 0; i < n; ++i) {
PyObject *item = PySequence_GetItem(object, i);
if(item == NULL) {
- return PY_FAIL;
+ return NPY_FAIL;
}
- if(PyArray_ClipmodeConverter(item, &modes[i]) != PY_SUCCEED) {
+ if(PyArray_ClipmodeConverter(item, &modes[i]) != NPY_SUCCEED) {
Py_DECREF(item);
- return PY_FAIL;
+ return NPY_FAIL;
}
Py_DECREF(item);
}
}
- else if (PyArray_ClipmodeConverter(object, &modes[0]) == PY_SUCCEED) {
+ else if (PyArray_ClipmodeConverter(object, &modes[0]) == NPY_SUCCEED) {
for (i = 1; i < n; ++i) {
modes[i] = modes[0];
}
}
else {
- return PY_FAIL;
+ return NPY_FAIL;
}
- return PY_SUCCEED;
+ return NPY_SUCCEED;
}
/*NUMPY_API
@@ -773,7 +773,7 @@ PyArray_PyIntAsInt(PyObject *o)
#if (PY_VERSION_HEX >= 0x02050000)
if (PyIndex_Check(o)) {
PyObject* value = PyNumber_Index(o);
- long_value = (longlong) PyInt_AsSsize_t(value);
+ long_value = (npy_longlong) PyInt_AsSsize_t(value);
goto finish;
}
#endif
@@ -820,7 +820,7 @@ PyArray_PyIntAsInt(PyObject *o)
NPY_NO_EXPORT npy_intp
PyArray_PyIntAsIntp(PyObject *o)
{
- longlong long_value = -1;
+ npy_longlong long_value = -1;
PyObject *obj;
static char *msg = "an integer is required";
PyArrayObject *arr;
@@ -832,16 +832,16 @@ PyArray_PyIntAsIntp(PyObject *o)
return -1;
}
if (PyInt_Check(o)) {
- long_value = (longlong) PyInt_AS_LONG(o);
+ long_value = (npy_longlong) PyInt_AS_LONG(o);
goto finish;
} else if (PyLong_Check(o)) {
- long_value = (longlong) PyLong_AsLongLong(o);
+ long_value = (npy_longlong) PyLong_AsLongLong(o);
goto finish;
}
-#if SIZEOF_INTP == SIZEOF_LONG
+#if NPY_SIZEOF_INTP == SIZEOF_LONG
descr = &LONG_Descr;
-#elif SIZEOF_INTP == SIZEOF_INT
+#elif NPY_SIZEOF_INTP == SIZEOF_INT
descr = &INT_Descr;
#else
descr = &LONGLONG_Descr;
@@ -874,7 +874,7 @@ PyArray_PyIntAsIntp(PyObject *o)
if (value == NULL) {
return -1;
}
- long_value = (longlong) PyInt_AsSsize_t(value);
+ long_value = (npy_longlong) PyInt_AsSsize_t(value);
goto finish;
}
#endif
@@ -883,7 +883,7 @@ PyArray_PyIntAsIntp(PyObject *o)
Py_TYPE(o)->tp_as_number->nb_long != NULL) {
obj = Py_TYPE(o)->tp_as_number->nb_long(o);
if (obj != NULL) {
- long_value = (longlong) PyLong_AsLongLong(obj);
+ long_value = (npy_longlong) PyLong_AsLongLong(obj);
Py_DECREF(obj);
}
}
@@ -893,7 +893,7 @@ PyArray_PyIntAsIntp(PyObject *o)
Py_TYPE(o)->tp_as_number->nb_int != NULL) {
obj = Py_TYPE(o)->tp_as_number->nb_int(o);
if (obj != NULL) {
- long_value = (longlong) PyLong_AsLongLong(obj);
+ long_value = (npy_longlong) PyLong_AsLongLong(obj);
Py_DECREF(obj);
}
}
@@ -907,8 +907,8 @@ PyArray_PyIntAsIntp(PyObject *o)
return -1;
}
-#if (SIZEOF_LONGLONG > SIZEOF_INTP)
- if ((long_value < MIN_INTP) || (long_value > MAX_INTP)) {
+#if (NPY_SIZEOF_LONGLONG > NPY_SIZEOF_INTP)
+ if ((long_value < NPY_MIN_INTP) || (long_value > NPY_MAX_INTP)) {
PyErr_SetString(PyExc_ValueError,
"integer won't fit into a C intp");
return -1;
@@ -934,7 +934,7 @@ PyArray_IntpFromSequence(PyObject *seq, npy_intp *vals, int maxvals)
*/
if ((nd=PySequence_Length(seq)) == -1) {
if (PyErr_Occurred()) PyErr_Clear();
-#if SIZEOF_LONG >= SIZEOF_INTP && !defined(NPY_PY3K)
+#if SIZEOF_LONG >= NPY_SIZEOF_INTP && !defined(NPY_PY3K)
if (!(op = PyNumber_Int(seq))) {
return -1;
}
@@ -944,7 +944,7 @@ PyArray_IntpFromSequence(PyObject *seq, npy_intp *vals, int maxvals)
}
#endif
nd = 1;
-#if SIZEOF_LONG >= SIZEOF_INTP
+#if SIZEOF_LONG >= NPY_SIZEOF_INTP
vals[0] = (npy_intp ) PyInt_AsLong(op);
#else
vals[0] = (npy_intp ) PyLong_AsLongLong(op);
@@ -968,12 +968,12 @@ PyArray_IntpFromSequence(PyObject *seq, npy_intp *vals, int maxvals)
}
}
else {
- for (i = 0; i < MIN(nd,maxvals); i++) {
+ for (i = 0; i < PyArray_MIN(nd,maxvals); i++) {
op = PySequence_GetItem(seq, i);
if (op == NULL) {
return -1;
}
-#if SIZEOF_LONG >= SIZEOF_INTP
+#if SIZEOF_LONG >= NPY_SIZEOF_INTP
vals[i]=(npy_intp )PyInt_AsLong(op);
#else
vals[i]=(npy_intp )PyLong_AsLongLong(op);
@@ -1168,10 +1168,10 @@ PyArray_IntTupleFromIntp(int len, npy_intp *vals)
goto fail;
}
for (i = 0; i < len; i++) {
-#if SIZEOF_INTP <= SIZEOF_LONG
+#if NPY_SIZEOF_INTP <= SIZEOF_LONG
PyObject *o = PyInt_FromLong((long) vals[i]);
#else
- PyObject *o = PyLong_FromLongLong((longlong) vals[i]);
+ PyObject *o = PyLong_FromLongLong((npy_longlong) vals[i]);
#endif
if (!o) {
Py_DECREF(intTuple);
diff --git a/numpy/core/src/multiarray/convert_datatype.c b/numpy/core/src/multiarray/convert_datatype.c
index 88463c6b5..873496426 100644
--- a/numpy/core/src/multiarray/convert_datatype.c
+++ b/numpy/core/src/multiarray/convert_datatype.c
@@ -735,7 +735,7 @@ PyArray_CanCastScalar(PyTypeObject *from, PyTypeObject *to)
fromtype = _typenum_fromtypeobj((PyObject *)from, 0);
totype = _typenum_fromtypeobj((PyObject *)to, 0);
if (fromtype == NPY_NOTYPE || totype == NPY_NOTYPE) {
- return FALSE;
+ return NPY_FALSE;
}
return (npy_bool) PyArray_CanCastSafely(fromtype, totype);
}
@@ -1620,11 +1620,11 @@ NPY_NO_EXPORT int
PyArray_ValidType(int type)
{
PyArray_Descr *descr;
- int res=TRUE;
+ int res=NPY_TRUE;
descr = PyArray_DescrFromType(type);
if (descr == NULL) {
- res = FALSE;
+ res = NPY_FALSE;
}
Py_DECREF(descr);
return res;
diff --git a/numpy/core/src/multiarray/ctors.c b/numpy/core/src/multiarray/ctors.c
index fec6e63c1..7da014a89 100644
--- a/numpy/core/src/multiarray/ctors.c
+++ b/numpy/core/src/multiarray/ctors.c
@@ -556,7 +556,7 @@ discover_itemsize(PyObject *s, int nd, int *itemsize)
int n, r, i;
if (PyArray_Check(s)) {
- *itemsize = MAX(*itemsize, PyArray_ITEMSIZE((PyArrayObject *)s));
+ *itemsize = PyArray_MAX(*itemsize, PyArray_ITEMSIZE((PyArrayObject *)s));
return 0;
}
@@ -574,7 +574,7 @@ discover_itemsize(PyObject *s, int nd, int *itemsize)
PyErr_Clear();
}
else {
- *itemsize = MAX(*itemsize, n);
+ *itemsize = PyArray_MAX(*itemsize, n);
}
return 0;
}
@@ -2161,8 +2161,8 @@ PyArray_FromStructInterface(PyObject *input)
inter->flags &= ~NPY_ARRAY_NOTSWAPPED;
}
- if (inter->flags & ARR_HAS_DESCR) {
- if (PyArray_DescrConverter(inter->descr, &thetype) == PY_FAIL) {
+ if (inter->flags & NPY_ARR_HAS_DESCR) {
+ if (PyArray_DescrConverter(inter->descr, &thetype) == NPY_FAIL) {
thetype = NULL;
PyErr_Clear();
}
@@ -2211,7 +2211,7 @@ PyArray_FromInterface(PyObject *input)
char *data;
Py_ssize_t buffer_len;
int res, i, n;
- intp dims[NPY_MAXDIMS], strides[NPY_MAXDIMS];
+ npy_intp dims[NPY_MAXDIMS], strides[NPY_MAXDIMS];
int dataflags = NPY_ARRAY_BEHAVED;
/* Get the memory from __array_data__ and __array_offset__ */
@@ -2266,7 +2266,7 @@ PyArray_FromInterface(PyObject *input)
}
attr = PyDict_GetItemString(inter, "offset");
if (attr) {
- longlong num = PyLong_AsLongLong(attr);
+ npy_longlong num = PyLong_AsLongLong(attr);
if (error_converting(num)) {
PyErr_SetString(PyExc_TypeError,
"__array_interface__ offset must be an integer");
@@ -3170,7 +3170,7 @@ _calc_length(PyObject *start, PyObject *stop, PyObject *step, PyObject **next, i
"arange: overflow while computing length");
return -1;
}
- len = MIN(len, tmp);
+ len = PyArray_MIN(len, tmp);
}
else {
value = PyFloat_AsDouble(val);
@@ -3702,7 +3702,7 @@ PyArray_FromString(char *data, npy_intp slen, PyArray_Descr *dtype,
{
int itemsize;
PyArrayObject *ret;
- Bool binary;
+ npy_bool binary;
if (dtype == NULL) {
dtype=PyArray_DescrFromType(NPY_DEFAULT_TYPE);
diff --git a/numpy/core/src/multiarray/descriptor.c b/numpy/core/src/multiarray/descriptor.c
index 16aab402a..69edd576a 100644
--- a/numpy/core/src/multiarray/descriptor.c
+++ b/numpy/core/src/multiarray/descriptor.c
@@ -47,7 +47,7 @@ _arraydescr_fromobj(PyObject *obj)
if (dtypedescr) {
ret = PyArray_DescrConverter(dtypedescr, &new);
Py_DECREF(dtypedescr);
- if (ret == PY_SUCCEED) {
+ if (ret == NPY_SUCCEED) {
return new;
}
PyErr_Clear();
@@ -58,7 +58,7 @@ _arraydescr_fromobj(PyObject *obj)
if (dtypedescr) {
ret = PyArray_DescrConverter(dtypedescr, &new);
Py_DECREF(dtypedescr);
- if (ret == PY_SUCCEED) {
+ if (ret == NPY_SUCCEED) {
PyObject *length;
length = PyObject_GetAttrString(obj, "_length_");
PyErr_Clear();
@@ -69,7 +69,7 @@ _arraydescr_fromobj(PyObject *obj)
newtup = Py_BuildValue("NO", new, length);
ret = PyArray_DescrConverter(newtup, &derived);
Py_DECREF(newtup);
- if (ret == PY_SUCCEED) {
+ if (ret == NPY_SUCCEED) {
return derived;
}
PyErr_Clear();
@@ -88,7 +88,7 @@ _arraydescr_fromobj(PyObject *obj)
if (dtypedescr) {
ret = PyArray_DescrAlignConverter(dtypedescr, &new);
Py_DECREF(dtypedescr);
- if (ret == PY_SUCCEED) {
+ if (ret == NPY_SUCCEED) {
return new;
}
PyErr_Clear();
@@ -250,7 +250,7 @@ _convert_from_tuple(PyObject *obj)
PyArray_Dims shape = {NULL, -1};
PyArray_Descr *newdescr;
- if (!(PyArray_IntpConverter(val, &shape)) || (shape.len > MAX_DIMS)) {
+ if (!(PyArray_IntpConverter(val, &shape)) || (shape.len > NPY_MAXDIMS)) {
PyDimMem_FREE(shape.ptr);
PyErr_SetString(PyExc_ValueError,
"invalid shape in fixed-type tuple.");
@@ -393,7 +393,7 @@ _convert_from_array_descr(PyObject *obj, int align)
else {
ret = PyArray_DescrConverter(PyTuple_GET_ITEM(item, 1), &conv);
}
- if (ret == PY_FAIL) {
+ if (ret == NPY_FAIL) {
PyObject_Print(PyTuple_GET_ITEM(item, 1), stderr, 0);
}
}
@@ -410,7 +410,7 @@ _convert_from_array_descr(PyObject *obj, int align)
else {
goto fail;
}
- if (ret == PY_FAIL) {
+ if (ret == NPY_FAIL) {
goto fail;
}
if ((PyDict_GetItem(fields, name) != NULL)
@@ -435,7 +435,7 @@ _convert_from_array_descr(PyObject *obj, int align)
if (_align > 1) {
totalsize = NPY_NEXT_ALIGNED_OFFSET(totalsize, _align);
}
- maxalign = MAX(maxalign, _align);
+ maxalign = PyArray_MAX(maxalign, _align);
}
PyTuple_SET_ITEM(tup, 1, PyInt_FromLong((long) totalsize));
@@ -543,7 +543,7 @@ _convert_from_list(PyObject *obj, int align)
else {
ret = PyArray_DescrConverter(PyList_GET_ITEM(obj, i), &conv);
}
- if (ret == PY_FAIL) {
+ if (ret == NPY_FAIL) {
Py_DECREF(tup);
Py_DECREF(key);
goto fail;
@@ -557,7 +557,7 @@ _convert_from_list(PyObject *obj, int align)
if (_align > 1) {
totalsize = NPY_NEXT_ALIGNED_OFFSET(totalsize, _align);
}
- maxalign = MAX(maxalign, _align);
+ maxalign = PyArray_MAX(maxalign, _align);
}
PyTuple_SET_ITEM(tup, 1, PyInt_FromLong((long) totalsize));
PyDict_SetItem(fields, key, tup);
@@ -919,7 +919,7 @@ _convert_from_dict(PyObject *obj, int align)
ret = PyArray_DescrConverter(descr, &newdescr);
}
Py_DECREF(descr);
- if (ret == PY_FAIL) {
+ if (ret == NPY_FAIL) {
Py_DECREF(tup);
Py_DECREF(ind);
goto fail;
@@ -927,7 +927,7 @@ _convert_from_dict(PyObject *obj, int align)
PyTuple_SET_ITEM(tup, 0, (PyObject *)newdescr);
if (align) {
_align = newdescr->alignment;
- maxalign = MAX(maxalign,_align);
+ maxalign = PyArray_MAX(maxalign,_align);
}
if (offsets) {
long offset;
@@ -948,7 +948,7 @@ _convert_from_dict(PyObject *obj, int align)
"not divisible by the field alignment %d "
"with align=True",
(int)offset, (int)newdescr->alignment);
- ret = PY_FAIL;
+ ret = NPY_FAIL;
}
else if (offset + newdescr->elsize > totalsize) {
totalsize = offset + newdescr->elsize;
@@ -976,14 +976,14 @@ _convert_from_dict(PyObject *obj, int align)
#endif
PyErr_SetString(PyExc_ValueError,
"field names must be strings");
- ret = PY_FAIL;
+ ret = NPY_FAIL;
}
/* Insert into dictionary */
if (PyDict_GetItem(fields, name) != NULL) {
PyErr_SetString(PyExc_ValueError,
"name already used as a name or title");
- ret = PY_FAIL;
+ ret = NPY_FAIL;
}
PyDict_SetItem(fields, name, tup);
Py_DECREF(name);
@@ -996,13 +996,13 @@ _convert_from_dict(PyObject *obj, int align)
if (PyDict_GetItem(fields, title) != NULL) {
PyErr_SetString(PyExc_ValueError,
"title already used as a name or title.");
- ret=PY_FAIL;
+ ret=NPY_FAIL;
}
PyDict_SetItem(fields, title, tup);
}
}
Py_DECREF(tup);
- if ((ret == PY_FAIL) || (newdescr->elsize == 0)) {
+ if ((ret == NPY_FAIL) || (newdescr->elsize == 0)) {
goto fail;
}
dtypeflags |= (newdescr->flags & NPY_FROM_FIELDS);
@@ -1117,7 +1117,7 @@ PyArray_DescrConverter2(PyObject *obj, PyArray_Descr **at)
{
if (obj == Py_None) {
*at = NULL;
- return PY_SUCCEED;
+ return NPY_SUCCEED;
}
else {
return PyArray_DescrConverter(obj, at);
@@ -1152,19 +1152,19 @@ PyArray_DescrConverter(PyObject *obj, PyArray_Descr **at)
/* default */
if (obj == Py_None) {
*at = PyArray_DescrFromType(NPY_DEFAULT_TYPE);
- return PY_SUCCEED;
+ return NPY_SUCCEED;
}
if (PyArray_DescrCheck(obj)) {
*at = (PyArray_Descr *)obj;
Py_INCREF(*at);
- return PY_SUCCEED;
+ return NPY_SUCCEED;
}
if (PyType_Check(obj)) {
if (PyType_IsSubtype((PyTypeObject *)obj, &PyGenericArrType_Type)) {
*at = PyArray_DescrFromTypeObject(obj);
- return (*at) ? PY_SUCCEED : PY_FAIL;
+ return (*at) ? NPY_SUCCEED : NPY_FAIL;
}
check_num = NPY_OBJECT;
#if !defined(NPY_PY3K)
@@ -1204,7 +1204,7 @@ PyArray_DescrConverter(PyObject *obj, PyArray_Descr **at)
else {
*at = _arraydescr_fromobj(obj);
if (*at) {
- return PY_SUCCEED;
+ return NPY_SUCCEED;
}
}
goto finish;
@@ -1218,7 +1218,7 @@ PyArray_DescrConverter(PyObject *obj, PyArray_Descr **at)
PyObject *obj2;
obj2 = PyUnicode_AsASCIIString(obj);
if (obj2 == NULL) {
- return PY_FAIL;
+ return NPY_FAIL;
}
retval = PyArray_DescrConverter(obj2, at);
Py_DECREF(obj2);
@@ -1242,7 +1242,7 @@ PyArray_DescrConverter(PyObject *obj, PyArray_Descr **at)
/* check for commas present or first (or second) element a digit */
if (_check_for_commastring(type, len)) {
*at = _convert_from_commastring(obj, 0);
- return (*at) ? PY_SUCCEED : PY_FAIL;
+ return (*at) ? NPY_SUCCEED : NPY_FAIL;
}
/* Process the endian character */
@@ -1270,7 +1270,7 @@ PyArray_DescrConverter(PyObject *obj, PyArray_Descr **at)
/* Check for datetime format */
if (is_datetime_typestr(type, len)) {
*at = parse_dtype_from_datetime_typestr(type, len);
- return (*at) ? PY_SUCCEED : PY_FAIL;
+ return (*at) ? NPY_SUCCEED : NPY_FAIL;
}
/* A typecode like 'd' */
@@ -1330,33 +1330,33 @@ PyArray_DescrConverter(PyObject *obj, PyArray_Descr **at)
*at = _convert_from_tuple(obj);
if (*at == NULL){
if (PyErr_Occurred()) {
- return PY_FAIL;
+ return NPY_FAIL;
}
goto fail;
}
- return PY_SUCCEED;
+ return NPY_SUCCEED;
}
else if (PyList_Check(obj)) {
/* or a list */
*at = _convert_from_array_descr(obj,0);
if (*at == NULL) {
if (PyErr_Occurred()) {
- return PY_FAIL;
+ return NPY_FAIL;
}
goto fail;
}
- return PY_SUCCEED;
+ return NPY_SUCCEED;
}
else if (PyDict_Check(obj)) {
/* or a dictionary */
*at = _convert_from_dict(obj,0);
if (*at == NULL) {
if (PyErr_Occurred()) {
- return PY_FAIL;
+ return NPY_FAIL;
}
goto fail;
}
- return PY_SUCCEED;
+ return NPY_SUCCEED;
}
else if (PyArray_Check(obj)) {
goto fail;
@@ -1364,10 +1364,10 @@ PyArray_DescrConverter(PyObject *obj, PyArray_Descr **at)
else {
*at = _arraydescr_fromobj(obj);
if (*at) {
- return PY_SUCCEED;
+ return NPY_SUCCEED;
}
if (PyErr_Occurred()) {
- return PY_FAIL;
+ return NPY_FAIL;
}
goto fail;
}
@@ -1411,7 +1411,7 @@ finish:
PyArray_DESCR_REPLACE(*at);
(*at)->byteorder = endian;
}
- return PY_SUCCEED;
+ return NPY_SUCCEED;
fail:
if (PyBytes_Check(obj)) {
@@ -1424,7 +1424,7 @@ fail:
error:
*at = NULL;
- return PY_FAIL;
+ return NPY_FAIL;
}
/** Array Descr Objects for dynamic types **/
@@ -1944,9 +1944,9 @@ arraydescr_new(PyTypeObject *NPY_UNUSED(subtype),
{
PyObject *odescr, *metadata=NULL;
PyArray_Descr *descr, *conv;
- npy_bool align = FALSE;
- npy_bool copy = FALSE;
- npy_bool copied = FALSE;
+ npy_bool align = NPY_FALSE;
+ npy_bool copy = NPY_FALSE;
+ npy_bool copied = NPY_FALSE;
static char *kwlist[] = {"dtype", "align", "copy", "metadata", NULL};
@@ -1976,7 +1976,7 @@ arraydescr_new(PyTypeObject *NPY_UNUSED(subtype),
descr = PyArray_DescrNew(conv);
Py_DECREF(conv);
conv = descr;
- copied = TRUE;
+ copied = NPY_TRUE;
}
if ((metadata != NULL)) {
@@ -1985,7 +1985,7 @@ arraydescr_new(PyTypeObject *NPY_UNUSED(subtype),
* underlying dictionary
*/
if (!copied) {
- copied = TRUE;
+ copied = NPY_TRUE;
descr = PyArray_DescrNew(conv);
Py_DECREF(conv);
conv = descr;
@@ -2511,9 +2511,9 @@ PyArray_DescrAlignConverter(PyObject *obj, PyArray_Descr **at)
PyErr_SetString(PyExc_ValueError,
"data-type-descriptor not understood");
}
- return PY_FAIL;
+ return NPY_FAIL;
}
- return PY_SUCCEED;
+ return NPY_SUCCEED;
}
/*NUMPY_API
@@ -2547,9 +2547,9 @@ PyArray_DescrAlignConverter2(PyObject *obj, PyArray_Descr **at)
PyErr_SetString(PyExc_ValueError,
"data-type-descriptor not understood");
}
- return PY_FAIL;
+ return NPY_FAIL;
}
- return PY_SUCCEED;
+ return NPY_SUCCEED;
}
@@ -3154,7 +3154,7 @@ arraydescr_richcompare(PyArray_Descr *self, PyObject *other, int cmp_op)
PyArray_Descr *new = NULL;
PyObject *result = Py_NotImplemented;
if (!PyArray_DescrCheck(other)) {
- if (PyArray_DescrConverter(other, &new) == PY_FAIL) {
+ if (PyArray_DescrConverter(other, &new) == NPY_FAIL) {
return NULL;
}
}
diff --git a/numpy/core/src/multiarray/flagsobject.c b/numpy/core/src/multiarray/flagsobject.c
index 3de49b74c..582b7f2df 100644
--- a/numpy/core/src/multiarray/flagsobject.c
+++ b/numpy/core/src/multiarray/flagsobject.c
@@ -118,8 +118,8 @@ PyArray_UpdateFlags(PyArrayObject *ret, int flagmask)
static int
_IsContiguous(PyArrayObject *ap)
{
- intp sd;
- intp dim;
+ npy_intp sd;
+ npy_intp dim;
int i;
if (PyArray_NDIM(ap) == 0) {
@@ -148,8 +148,8 @@ _IsContiguous(PyArrayObject *ap)
static int
_IsFortranContiguous(PyArrayObject *ap)
{
- intp sd;
- intp dim;
+ npy_intp sd;
+ npy_intp dim;
int i;
if (PyArray_NDIM(ap) == 0) {
diff --git a/numpy/core/src/multiarray/getset.c b/numpy/core/src/multiarray/getset.c
index 8dddb592f..1bb210494 100644
--- a/numpy/core/src/multiarray/getset.c
+++ b/numpy/core/src/multiarray/getset.c
@@ -72,9 +72,9 @@ array_shape_set(PyArrayObject *self, PyObject *val)
}
((PyArrayObject_fields *)self)->strides = PyArray_DIMS(self) + nd;
((PyArrayObject_fields *)self)->maskna_strides = PyArray_DIMS(self) + 2*nd;
- memcpy(PyArray_DIMS(self), PyArray_DIMS(ret), nd*sizeof(intp));
- memcpy(PyArray_STRIDES(self), PyArray_STRIDES(ret), nd*sizeof(intp));
- memcpy(PyArray_MASKNA_STRIDES(self), PyArray_MASKNA_STRIDES(ret), nd*sizeof(intp));
+ memcpy(PyArray_DIMS(self), PyArray_DIMS(ret), nd*sizeof(npy_intp));
+ memcpy(PyArray_STRIDES(self), PyArray_STRIDES(ret), nd*sizeof(npy_intp));
+ memcpy(PyArray_MASKNA_STRIDES(self), PyArray_MASKNA_STRIDES(ret), nd*sizeof(npy_intp));
}
else {
((PyArrayObject_fields *)self)->dimensions = NULL;
@@ -97,8 +97,8 @@ array_strides_set(PyArrayObject *self, PyObject *obj)
{
PyArray_Dims newstrides = {NULL, 0};
PyArrayObject *new;
- intp numbytes = 0;
- intp offset = 0;
+ npy_intp numbytes = 0;
+ npy_intp offset = 0;
Py_ssize_t buf_len;
char *buf;
@@ -140,7 +140,7 @@ array_strides_set(PyArrayObject *self, PyObject *obj)
"compatible with available memory");
goto fail;
}
- memcpy(PyArray_STRIDES(self), newstrides.ptr, sizeof(intp)*newstrides.len);
+ memcpy(PyArray_STRIDES(self), newstrides.ptr, sizeof(npy_intp)*newstrides.len);
PyArray_UpdateFlags(self, NPY_ARRAY_C_CONTIGUOUS | NPY_ARRAY_F_CONTIGUOUS);
PyDimMem_FREE(newstrides.ptr);
return 0;
@@ -285,7 +285,7 @@ array_data_get(PyArrayObject *self)
#if defined(NPY_PY3K)
return PyMemoryView_FromObject((PyObject *)self);
#else
- intp nbytes;
+ npy_intp nbytes;
if (!(PyArray_ISONESEGMENT(self))) {
PyErr_SetString(PyExc_AttributeError, "cannot get single-"\
"segment buffer for discontiguous array");
@@ -362,11 +362,11 @@ array_itemsize_get(PyArrayObject *self)
static PyObject *
array_size_get(PyArrayObject *self)
{
- intp size=PyArray_SIZE(self);
-#if SIZEOF_INTP <= SIZEOF_LONG
+ npy_intp size=PyArray_SIZE(self);
+#if NPY_SIZEOF_INTP <= SIZEOF_LONG
return PyInt_FromLong((long) size);
#else
- if (size > MAX_LONG || size < MIN_LONG) {
+ if (size > NPY_MAX_LONG || size < NPY_MIN_LONG) {
return PyLong_FromLongLong(size);
}
else {
@@ -378,11 +378,11 @@ array_size_get(PyArrayObject *self)
static PyObject *
array_nbytes_get(PyArrayObject *self)
{
- intp nbytes = PyArray_NBYTES(self);
-#if SIZEOF_INTP <= SIZEOF_LONG
+ npy_intp nbytes = PyArray_NBYTES(self);
+#if NPY_SIZEOF_INTP <= SIZEOF_LONG
return PyInt_FromLong((long) nbytes);
#else
- if (nbytes > MAX_LONG || nbytes < MIN_LONG) {
+ if (nbytes > NPY_MAX_LONG || nbytes < NPY_MIN_LONG) {
return PyLong_FromLongLong(nbytes);
}
else {
@@ -405,7 +405,7 @@ static int
array_descr_set(PyArrayObject *self, PyObject *arg)
{
PyArray_Descr *newtype = NULL;
- intp newdim;
+ npy_intp newdim;
int i;
char *msg = "new type not compatible with array.";
@@ -527,7 +527,7 @@ array_struct_get(PyArrayObject *self)
PyArrayInterface *inter;
PyObject *ret;
- inter = (PyArrayInterface *)_pya_malloc(sizeof(PyArrayInterface));
+ inter = (PyArrayInterface *)PyArray_malloc(sizeof(PyArrayInterface));
if (inter==NULL) {
return PyErr_NoMemory();
}
@@ -544,14 +544,14 @@ array_struct_get(PyArrayObject *self)
*when the array is "reshaped".
*/
if (PyArray_NDIM(self) > 0) {
- inter->shape = (intp *)_pya_malloc(2*sizeof(intp)*PyArray_NDIM(self));
+ inter->shape = (npy_intp *)PyArray_malloc(2*sizeof(npy_intp)*PyArray_NDIM(self));
if (inter->shape == NULL) {
- _pya_free(inter);
+ PyArray_free(inter);
return PyErr_NoMemory();
}
inter->strides = inter->shape + PyArray_NDIM(self);
- memcpy(inter->shape, PyArray_DIMS(self), sizeof(intp)*PyArray_NDIM(self));
- memcpy(inter->strides, PyArray_STRIDES(self), sizeof(intp)*PyArray_NDIM(self));
+ memcpy(inter->shape, PyArray_DIMS(self), sizeof(npy_intp)*PyArray_NDIM(self));
+ memcpy(inter->strides, PyArray_STRIDES(self), sizeof(npy_intp)*PyArray_NDIM(self));
}
else {
inter->shape = NULL;
@@ -564,7 +564,7 @@ array_struct_get(PyArrayObject *self)
PyErr_Clear();
}
else {
- inter->flags &= ARR_HAS_DESCR;
+ inter->flags &= NPY_ARR_HAS_DESCR;
}
}
else {
diff --git a/numpy/core/src/multiarray/item_selection.c b/numpy/core/src/multiarray/item_selection.c
index 4aa52d230..c4c9f7fb2 100644
--- a/numpy/core/src/multiarray/item_selection.c
+++ b/numpy/core/src/multiarray/item_selection.c
@@ -33,8 +33,8 @@ PyArray_TakeFrom(PyArrayObject *self0, PyObject *indices0, int axis,
PyArray_Descr *dtype;
PyArray_FastTakeFunc *func;
PyArrayObject *obj = NULL, *self, *indices;
- intp nd, i, j, n, m, max_item, tmp, chunk, nelem;
- intp shape[MAX_DIMS];
+ npy_intp nd, i, j, n, m, max_item, tmp, chunk, nelem;
+ npy_intp shape[NPY_MAXDIMS];
char *src, *dest;
int err, use_maskna = 0;
@@ -174,7 +174,7 @@ PyArray_TakeFrom(PyArrayObject *self0, PyObject *indices0, int axis,
case NPY_RAISE:
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++) {
- tmp = ((intp *)(PyArray_DATA(indices)))[j];
+ tmp = ((npy_intp *)(PyArray_DATA(indices)))[j];
if (tmp < 0) {
tmp = tmp + max_item;
}
@@ -199,7 +199,7 @@ PyArray_TakeFrom(PyArrayObject *self0, PyObject *indices0, int axis,
case NPY_WRAP:
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++) {
- tmp = ((intp *)(PyArray_DATA(indices)))[j];
+ tmp = ((npy_intp *)(PyArray_DATA(indices)))[j];
if (tmp < 0) {
while (tmp < 0) {
tmp += max_item;
@@ -225,7 +225,7 @@ PyArray_TakeFrom(PyArrayObject *self0, PyObject *indices0, int axis,
case NPY_CLIP:
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++) {
- tmp = ((intp *)(PyArray_DATA(indices)))[j];
+ tmp = ((npy_intp *)(PyArray_DATA(indices)))[j];
if (tmp < 0) {
tmp = 0;
}
@@ -252,7 +252,7 @@ PyArray_TakeFrom(PyArrayObject *self0, PyObject *indices0, int axis,
case NPY_RAISE:
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++) {
- tmp = ((intp *)(PyArray_DATA(indices)))[j];
+ tmp = ((npy_intp *)(PyArray_DATA(indices)))[j];
if (tmp < 0) {
tmp = tmp + max_item;
}
@@ -271,7 +271,7 @@ PyArray_TakeFrom(PyArrayObject *self0, PyObject *indices0, int axis,
case NPY_WRAP:
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++) {
- tmp = ((intp *)(PyArray_DATA(indices)))[j];
+ tmp = ((npy_intp *)(PyArray_DATA(indices)))[j];
if (tmp < 0) {
while (tmp < 0) {
tmp += max_item;
@@ -291,7 +291,7 @@ PyArray_TakeFrom(PyArrayObject *self0, PyObject *indices0, int axis,
case NPY_CLIP:
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++) {
- tmp = ((intp *)(PyArray_DATA(indices)))[j];
+ tmp = ((npy_intp *)(PyArray_DATA(indices)))[j];
if (tmp < 0) {
tmp = 0;
}
@@ -307,7 +307,7 @@ PyArray_TakeFrom(PyArrayObject *self0, PyObject *indices0, int axis,
}
}
else {
- err = func(dest, src, (intp *)(PyArray_DATA(indices)),
+ err = func(dest, src, (npy_intp *)(PyArray_DATA(indices)),
max_item, n, m, nelem, clipmode);
if (err) {
goto fail;
@@ -339,7 +339,7 @@ PyArray_PutTo(PyArrayObject *self, PyObject* values0, PyObject *indices0,
NPY_CLIPMODE clipmode)
{
PyArrayObject *indices, *values;
- intp i, chunk, ni, max_item, nv, tmp;
+ npy_intp i, chunk, ni, max_item, nv, tmp;
char *src, *dest;
int copied = 0;
@@ -389,7 +389,7 @@ PyArray_PutTo(PyArrayObject *self, PyObject* values0, PyObject *indices0,
case NPY_RAISE:
for (i = 0; i < ni; i++) {
src = PyArray_DATA(values) + chunk*(i % nv);
- tmp = ((intp *)(PyArray_DATA(indices)))[i];
+ tmp = ((npy_intp *)(PyArray_DATA(indices)))[i];
if (tmp < 0) {
tmp = tmp + max_item;
}
@@ -407,7 +407,7 @@ PyArray_PutTo(PyArrayObject *self, PyObject* values0, PyObject *indices0,
case NPY_WRAP:
for (i = 0; i < ni; i++) {
src = PyArray_DATA(values) + chunk * (i % nv);
- tmp = ((intp *)(PyArray_DATA(indices)))[i];
+ tmp = ((npy_intp *)(PyArray_DATA(indices)))[i];
if (tmp < 0) {
while (tmp < 0) {
tmp += max_item;
@@ -426,7 +426,7 @@ PyArray_PutTo(PyArrayObject *self, PyObject* values0, PyObject *indices0,
case NPY_CLIP:
for (i = 0; i < ni; i++) {
src = PyArray_DATA(values) + chunk * (i % nv);
- tmp = ((intp *)(PyArray_DATA(indices)))[i];
+ tmp = ((npy_intp *)(PyArray_DATA(indices)))[i];
if (tmp < 0) {
tmp = 0;
}
@@ -445,7 +445,7 @@ PyArray_PutTo(PyArrayObject *self, PyObject* values0, PyObject *indices0,
case NPY_RAISE:
for (i = 0; i < ni; i++) {
src = PyArray_DATA(values) + chunk * (i % nv);
- tmp = ((intp *)(PyArray_DATA(indices)))[i];
+ tmp = ((npy_intp *)(PyArray_DATA(indices)))[i];
if (tmp < 0) {
tmp = tmp + max_item;
}
@@ -461,7 +461,7 @@ PyArray_PutTo(PyArrayObject *self, PyObject* values0, PyObject *indices0,
case NPY_WRAP:
for (i = 0; i < ni; i++) {
src = PyArray_DATA(values) + chunk * (i % nv);
- tmp = ((intp *)(PyArray_DATA(indices)))[i];
+ tmp = ((npy_intp *)(PyArray_DATA(indices)))[i];
if (tmp < 0) {
while (tmp < 0) {
tmp += max_item;
@@ -478,7 +478,7 @@ PyArray_PutTo(PyArrayObject *self, PyObject* values0, PyObject *indices0,
case NPY_CLIP:
for (i = 0; i < ni; i++) {
src = PyArray_DATA(values) + chunk * (i % nv);
- tmp = ((intp *)(PyArray_DATA(indices)))[i];
+ tmp = ((npy_intp *)(PyArray_DATA(indices)))[i];
if (tmp < 0) {
tmp = 0;
}
@@ -518,7 +518,7 @@ PyArray_PutMask(PyArrayObject *self, PyObject* values0, PyObject* mask0)
PyArray_FastPutmaskFunc *func;
PyArrayObject *mask, *values;
PyArray_Descr *dtype;
- intp i, chunk, ni, max_item, nv, tmp;
+ npy_intp i, chunk, ni, max_item, nv, tmp;
char *src, *dest;
int copied = 0;
@@ -622,9 +622,9 @@ PyArray_PutMask(PyArrayObject *self, PyObject* values0, PyObject* mask0)
NPY_NO_EXPORT PyObject *
PyArray_Repeat(PyArrayObject *aop, PyObject *op, int axis)
{
- intp *counts;
- intp n, n_outer, i, j, k, chunk, total;
- intp tmp;
+ npy_intp *counts;
+ npy_intp n, n_outer, i, j, k, chunk, total;
+ npy_intp tmp;
int nd;
PyArrayObject *repeats = NULL;
PyObject *ap = NULL;
@@ -730,11 +730,11 @@ PyArray_Choose(PyArrayObject *ip, PyObject *op, PyArrayObject *out,
PyArrayObject *obj = NULL;
PyArray_Descr *dtype;
int n, elsize;
- intp i;
+ npy_intp i;
char *ret_data;
PyArrayObject **mps, *ap;
PyArrayMultiIterObject *multi = NULL;
- intp mi;
+ npy_intp mi;
ap = NULL;
/*
@@ -804,7 +804,7 @@ PyArray_Choose(PyArrayObject *ip, PyObject *op, PyArrayObject *out,
ret_data = PyArray_DATA(obj);
while (PyArray_MultiIter_NOTDONE(multi)) {
- mi = *((intp *)PyArray_MultiIter_DATA(multi, n));
+ mi = *((npy_intp *)PyArray_MultiIter_DATA(multi, n));
if (mi < 0 || mi >= n) {
switch(clipmode) {
case NPY_RAISE:
@@ -877,11 +877,11 @@ _new_sort(PyArrayObject *op, int axis, NPY_SORTKIND which)
{
PyArrayIterObject *it;
int needcopy = 0, swap;
- intp N, size;
+ npy_intp N, size;
int elsize;
- intp astride;
+ npy_intp astride;
PyArray_SortFunc *sort;
- BEGIN_THREADS_DEF;
+ NPY_BEGIN_THREADS_DEF;
it = (PyArrayIterObject *)PyArray_IterAllButAxis((PyObject *)op, &axis);
swap = !PyArray_ISNOTSWAPPED(op);
@@ -897,25 +897,25 @@ _new_sort(PyArrayObject *op, int axis, NPY_SORTKIND which)
astride = PyArray_STRIDES(op)[axis];
needcopy = !(PyArray_FLAGS(op) & NPY_ARRAY_ALIGNED) ||
- (astride != (intp) elsize) || swap;
+ (astride != (npy_intp) elsize) || swap;
if (needcopy) {
char *buffer = PyDataMem_NEW(N*elsize);
while (size--) {
- _unaligned_strided_byte_copy(buffer, (intp) elsize, it->dataptr,
+ _unaligned_strided_byte_copy(buffer, (npy_intp) elsize, it->dataptr,
astride, N, elsize);
if (swap) {
- _strided_byte_swap(buffer, (intp) elsize, N, elsize);
+ _strided_byte_swap(buffer, (npy_intp) elsize, N, elsize);
}
if (sort(buffer, N, op) < 0) {
PyDataMem_FREE(buffer);
goto fail;
}
if (swap) {
- _strided_byte_swap(buffer, (intp) elsize, N, elsize);
+ _strided_byte_swap(buffer, (npy_intp) elsize, N, elsize);
}
_unaligned_strided_byte_copy(it->dataptr, astride, buffer,
- (intp) elsize, N, elsize);
+ (npy_intp) elsize, N, elsize);
PyArray_ITER_NEXT(it);
}
PyDataMem_FREE(buffer);
@@ -946,11 +946,11 @@ _new_argsort(PyArrayObject *op, int axis, NPY_SORTKIND which)
PyArrayIterObject *rit = NULL;
PyArrayObject *ret;
int needcopy = 0, i;
- intp N, size;
+ npy_intp N, size;
int elsize, swap;
- intp astride, rstride, *iptr;
+ npy_intp astride, rstride, *iptr;
PyArray_ArgSortFunc *argsort;
- BEGIN_THREADS_DEF;
+ NPY_BEGIN_THREADS_DEF;
ret = (PyArrayObject *)PyArray_New(Py_TYPE(op),
PyArray_NDIM(op),
@@ -976,30 +976,30 @@ _new_argsort(PyArrayObject *op, int axis, NPY_SORTKIND which)
rstride = PyArray_STRIDE(ret,axis);
needcopy = swap || !(PyArray_FLAGS(op) & NPY_ARRAY_ALIGNED) ||
- (astride != (intp) elsize) ||
- (rstride != sizeof(intp));
+ (astride != (npy_intp) elsize) ||
+ (rstride != sizeof(npy_intp));
if (needcopy) {
char *valbuffer, *indbuffer;
valbuffer = PyDataMem_NEW(N*elsize);
- indbuffer = PyDataMem_NEW(N*sizeof(intp));
+ indbuffer = PyDataMem_NEW(N*sizeof(npy_intp));
while (size--) {
- _unaligned_strided_byte_copy(valbuffer, (intp) elsize, it->dataptr,
+ _unaligned_strided_byte_copy(valbuffer, (npy_intp) elsize, it->dataptr,
astride, N, elsize);
if (swap) {
- _strided_byte_swap(valbuffer, (intp) elsize, N, elsize);
+ _strided_byte_swap(valbuffer, (npy_intp) elsize, N, elsize);
}
- iptr = (intp *)indbuffer;
+ iptr = (npy_intp *)indbuffer;
for (i = 0; i < N; i++) {
*iptr++ = i;
}
- if (argsort(valbuffer, (intp *)indbuffer, N, op) < 0) {
+ if (argsort(valbuffer, (npy_intp *)indbuffer, N, op) < 0) {
PyDataMem_FREE(valbuffer);
PyDataMem_FREE(indbuffer);
goto fail;
}
_unaligned_strided_byte_copy(rit->dataptr, rstride, indbuffer,
- sizeof(intp), N, sizeof(intp));
+ sizeof(npy_intp), N, sizeof(npy_intp));
PyArray_ITER_NEXT(it);
PyArray_ITER_NEXT(rit);
}
@@ -1008,11 +1008,11 @@ _new_argsort(PyArrayObject *op, int axis, NPY_SORTKIND which)
}
else {
while (size--) {
- iptr = (intp *)rit->dataptr;
+ iptr = (npy_intp *)rit->dataptr;
for (i = 0; i < N; i++) {
*iptr++ = i;
}
- if (argsort(it->dataptr, (intp *)rit->dataptr, N, op) < 0) {
+ if (argsort(it->dataptr, (npy_intp *)rit->dataptr, N, op) < 0) {
goto fail;
}
PyArray_ITER_NEXT(it);
@@ -1074,7 +1074,7 @@ qsortCompare (const void *a, const void *b)
}
/* These swap axes in-place if necessary */
-#define SWAPINTP(a,b) {intp c; c=(a); (a) = (b); (b) = c;}
+#define SWAPINTP(a,b) {npy_intp c; c=(a); (a) = (b); (b) = c;}
#define SWAPAXES2(ap) { \
orign = PyArray_NDIM(ap)-1; \
if (axis != orign) { \
@@ -1177,8 +1177,8 @@ static int
argsort_static_compare(const void *ip1, const void *ip2)
{
int isize = PyArray_DESCR(global_obj)->elsize;
- const intp *ipa = ip1;
- const intp *ipb = ip2;
+ const npy_intp *ipa = ip1;
+ const npy_intp *ipb = ip2;
return PyArray_DESCR(global_obj)->f->compare(global_data + (isize * *ipa),
global_data + (isize * *ipb),
global_obj);
@@ -1191,8 +1191,8 @@ NPY_NO_EXPORT PyObject *
PyArray_ArgSort(PyArrayObject *op, int axis, NPY_SORTKIND which)
{
PyArrayObject *ap = NULL, *ret = NULL, *store, *op2;
- intp *ip;
- intp i, j, n, m, orign;
+ npy_intp *ip;
+ npy_intp i, j, n, m, orign;
int argsort_elsize;
char *store_ptr;
@@ -1206,7 +1206,7 @@ PyArray_ArgSort(PyArrayObject *op, int axis, NPY_SORTKIND which)
if (ret == NULL) {
return NULL;
}
- *((intp *)PyArray_DATA(ret)) = 0;
+ *((npy_intp *)PyArray_DATA(ret)) = 0;
return (PyObject *)ret;
}
@@ -1244,7 +1244,7 @@ PyArray_ArgSort(PyArrayObject *op, int axis, NPY_SORTKIND which)
if (ret == NULL) {
goto fail;
}
- ip = (intp *)PyArray_DATA(ret);
+ ip = (npy_intp *)PyArray_DATA(ret);
argsort_elsize = PyArray_DESCR(op)->elsize;
m = PyArray_DIMS(op)[PyArray_NDIM(op)-1];
if (m == 0) {
@@ -1259,7 +1259,7 @@ PyArray_ArgSort(PyArrayObject *op, int axis, NPY_SORTKIND which)
for (j = 0; j < m; j++) {
ip[j] = j;
}
- qsort((char *)ip, m, sizeof(intp), argsort_static_compare);
+ qsort((char *)ip, m, sizeof(npy_intp), argsort_static_compare);
}
global_data = store_ptr;
global_obj = store;
@@ -1295,10 +1295,10 @@ PyArray_LexSort(PyObject *sort_keys, int axis)
int n;
int nd;
int needcopy = 0, i,j;
- intp N, size;
+ npy_intp N, size;
int elsize;
int maxelsize;
- intp astride, rstride, *iptr;
+ npy_intp astride, rstride, *iptr;
int object = 0;
PyArray_ArgSortFunc *argsort;
NPY_BEGIN_THREADS_DEF;
@@ -1309,13 +1309,13 @@ PyArray_LexSort(PyObject *sort_keys, int axis)
"need sequence of keys with len > 0 in lexsort");
return NULL;
}
- mps = (PyArrayObject **) _pya_malloc(n*NPY_SIZEOF_PYARRAYOBJECT);
+ mps = (PyArrayObject **) PyArray_malloc(n*NPY_SIZEOF_PYARRAYOBJECT);
if (mps == NULL) {
return PyErr_NoMemory();
}
- its = (PyArrayIterObject **) _pya_malloc(n*sizeof(PyArrayIterObject));
+ its = (PyArrayIterObject **) PyArray_malloc(n*sizeof(PyArrayIterObject));
if (its == NULL) {
- _pya_free(mps);
+ PyArray_free(mps);
return PyErr_NoMemory();
}
for (i = 0; i < n; i++) {
@@ -1368,7 +1368,7 @@ PyArray_LexSort(PyObject *sort_keys, int axis)
if (ret == NULL) {
goto fail;
}
- *((intp *)(PyArray_DATA(ret))) = 0;
+ *((npy_intp *)(PyArray_DATA(ret))) = 0;
goto finish;
}
if (axis < 0) {
@@ -1399,12 +1399,12 @@ PyArray_LexSort(PyObject *sort_keys, int axis)
N = PyArray_DIMS(mps[0])[axis];
rstride = PyArray_STRIDE(ret, axis);
maxelsize = PyArray_DESCR(mps[0])->elsize;
- needcopy = (rstride != sizeof(intp));
+ needcopy = (rstride != sizeof(npy_intp));
for (j = 0; j < n; j++) {
needcopy = needcopy
|| PyArray_ISBYTESWAPPED(mps[j])
|| !(PyArray_FLAGS(mps[j]) & NPY_ARRAY_ALIGNED)
- || (PyArray_STRIDES(mps[j])[axis] != (intp)PyArray_DESCR(mps[j])->elsize);
+ || (PyArray_STRIDES(mps[j])[axis] != (npy_intp)PyArray_DESCR(mps[j])->elsize);
if (PyArray_DESCR(mps[j])->elsize > maxelsize) {
maxelsize = PyArray_DESCR(mps[j])->elsize;
}
@@ -1415,13 +1415,13 @@ PyArray_LexSort(PyObject *sort_keys, int axis)
int *swaps;
valbuffer = PyDataMem_NEW(N*maxelsize);
- indbuffer = PyDataMem_NEW(N*sizeof(intp));
+ indbuffer = PyDataMem_NEW(N*sizeof(npy_intp));
swaps = malloc(n*sizeof(int));
for (j = 0; j < n; j++) {
swaps[j] = PyArray_ISBYTESWAPPED(mps[j]);
}
while (size--) {
- iptr = (intp *)indbuffer;
+ iptr = (npy_intp *)indbuffer;
for (i = 0; i < N; i++) {
*iptr++ = i;
}
@@ -1429,12 +1429,12 @@ PyArray_LexSort(PyObject *sort_keys, int axis)
elsize = PyArray_DESCR(mps[j])->elsize;
astride = PyArray_STRIDES(mps[j])[axis];
argsort = PyArray_DESCR(mps[j])->f->argsort[NPY_MERGESORT];
- _unaligned_strided_byte_copy(valbuffer, (intp) elsize,
+ _unaligned_strided_byte_copy(valbuffer, (npy_intp) elsize,
its[j]->dataptr, astride, N, elsize);
if (swaps[j]) {
- _strided_byte_swap(valbuffer, (intp) elsize, N, elsize);
+ _strided_byte_swap(valbuffer, (npy_intp) elsize, N, elsize);
}
- if (argsort(valbuffer, (intp *)indbuffer, N, mps[j]) < 0) {
+ if (argsort(valbuffer, (npy_intp *)indbuffer, N, mps[j]) < 0) {
PyDataMem_FREE(valbuffer);
PyDataMem_FREE(indbuffer);
free(swaps);
@@ -1443,7 +1443,7 @@ PyArray_LexSort(PyObject *sort_keys, int axis)
PyArray_ITER_NEXT(its[j]);
}
_unaligned_strided_byte_copy(rit->dataptr, rstride, indbuffer,
- sizeof(intp), N, sizeof(intp));
+ sizeof(npy_intp), N, sizeof(npy_intp));
PyArray_ITER_NEXT(rit);
}
PyDataMem_FREE(valbuffer);
@@ -1452,13 +1452,13 @@ PyArray_LexSort(PyObject *sort_keys, int axis)
}
else {
while (size--) {
- iptr = (intp *)rit->dataptr;
+ iptr = (npy_intp *)rit->dataptr;
for (i = 0; i < N; i++) {
*iptr++ = i;
}
for (j = 0; j < n; j++) {
argsort = PyArray_DESCR(mps[j])->f->argsort[NPY_MERGESORT];
- if (argsort(its[j]->dataptr, (intp *)rit->dataptr,
+ if (argsort(its[j]->dataptr, (npy_intp *)rit->dataptr,
N, mps[j]) < 0) {
goto fail;
}
@@ -1478,8 +1478,8 @@ PyArray_LexSort(PyObject *sort_keys, int axis)
Py_XDECREF(its[i]);
}
Py_XDECREF(rit);
- _pya_free(mps);
- _pya_free(its);
+ PyArray_free(mps);
+ PyArray_free(its);
return (PyObject *)ret;
fail:
@@ -1490,8 +1490,8 @@ PyArray_LexSort(PyObject *sort_keys, int axis)
Py_XDECREF(mps[i]);
Py_XDECREF(its[i]);
}
- _pya_free(mps);
- _pya_free(its);
+ PyArray_free(mps);
+ PyArray_free(its);
return NULL;
}
@@ -1512,19 +1512,19 @@ static void
local_search_left(PyArrayObject *arr, PyArrayObject *key, PyArrayObject *ret)
{
PyArray_CompareFunc *compare = PyArray_DESCR(key)->f->compare;
- intp nelts = PyArray_DIMS(arr)[PyArray_NDIM(arr) - 1];
- intp nkeys = PyArray_SIZE(key);
+ npy_intp nelts = PyArray_DIMS(arr)[PyArray_NDIM(arr) - 1];
+ npy_intp nkeys = PyArray_SIZE(key);
char *parr = PyArray_DATA(arr);
char *pkey = PyArray_DATA(key);
- intp *pret = (intp *)PyArray_DATA(ret);
+ npy_intp *pret = (npy_intp *)PyArray_DATA(ret);
int elsize = PyArray_DESCR(arr)->elsize;
- intp i;
+ npy_intp i;
for (i = 0; i < nkeys; ++i) {
- intp imin = 0;
- intp imax = nelts;
+ npy_intp imin = 0;
+ npy_intp imax = nelts;
while (imin < imax) {
- intp imid = imin + ((imax - imin) >> 1);
+ npy_intp imid = imin + ((imax - imin) >> 1);
if (compare(parr + elsize*imid, pkey, key) < 0) {
imin = imid + 1;
}
@@ -1555,19 +1555,19 @@ static void
local_search_right(PyArrayObject *arr, PyArrayObject *key, PyArrayObject *ret)
{
PyArray_CompareFunc *compare = PyArray_DESCR(key)->f->compare;
- intp nelts = PyArray_DIMS(arr)[PyArray_NDIM(arr) - 1];
- intp nkeys = PyArray_SIZE(key);
+ npy_intp nelts = PyArray_DIMS(arr)[PyArray_NDIM(arr) - 1];
+ npy_intp nkeys = PyArray_SIZE(key);
char *parr = PyArray_DATA(arr);
char *pkey = PyArray_DATA(key);
- intp *pret = (intp *)PyArray_DATA(ret);
+ npy_intp *pret = (npy_intp *)PyArray_DATA(ret);
int elsize = PyArray_DESCR(arr)->elsize;
- intp i;
+ npy_intp i;
for(i = 0; i < nkeys; ++i) {
- intp imin = 0;
- intp imax = nelts;
+ npy_intp imin = 0;
+ npy_intp imax = nelts;
while (imin < imax) {
- intp imid = imin + ((imax - imin) >> 1);
+ npy_intp imid = imin + ((imax - imin) >> 1);
if (compare(parr + elsize*imid, pkey, key) <= 0) {
imin = imid + 1;
}
diff --git a/numpy/core/src/multiarray/iterators.c b/numpy/core/src/multiarray/iterators.c
index 4347b9aee..c92132733 100644
--- a/numpy/core/src/multiarray/iterators.c
+++ b/numpy/core/src/multiarray/iterators.c
@@ -632,7 +632,7 @@ static void
arrayiter_dealloc(PyArrayIterObject *it)
{
array_iter_base_dealloc(it);
- _pya_free(it);
+ PyArray_free(it);
}
static Py_ssize_t
@@ -670,7 +670,7 @@ iter_subscript_Bool(PyArrayIterObject *self, PyArrayObject *ind)
dptr = PyArray_DATA(ind);
/* Get size of return array */
while (counter--) {
- if (*((Bool *)dptr) != 0) {
+ if (*((npy_bool *)dptr) != 0) {
count++;
}
dptr += strides;
@@ -692,7 +692,7 @@ iter_subscript_Bool(PyArrayIterObject *self, PyArrayObject *ind)
/* Loop over Boolean array */
swap = (PyArray_ISNOTSWAPPED(self->ao) != PyArray_ISNOTSWAPPED(ret));
while (counter--) {
- if (*((Bool *)dptr) != 0) {
+ if (*((npy_bool *)dptr) != 0) {
copyswap(optr, self->dataptr, swap, self->ao);
optr += itemsize;
}
@@ -964,7 +964,7 @@ iter_ass_sub_Bool(PyArrayIterObject *self, PyArrayObject *ind,
/* Loop over Boolean array */
copyswap = PyArray_DESCR(self->ao)->f->copyswap;
while (counter--) {
- if (*((Bool *)dptr) != 0) {
+ if (*((npy_bool *)dptr) != 0) {
copyswap(self->dataptr, val->dataptr, swap, self->ao);
PyArray_ITER_NEXT(val);
if (val->index == val->size) {
@@ -1425,7 +1425,7 @@ PyArray_Broadcast(PyArrayMultiIterObject *mit)
/* Discover the broadcast number of dimensions */
for (i = 0, nd = 0; i < mit->numiter; i++) {
- nd = MAX(nd, PyArray_NDIM(mit->iters[i]->ao));
+ nd = PyArray_MAX(nd, PyArray_NDIM(mit->iters[i]->ao));
}
mit->nd = nd;
@@ -1724,14 +1724,14 @@ arraymultiter_dealloc(PyArrayMultiIterObject *multi)
static PyObject *
arraymultiter_size_get(PyArrayMultiIterObject *self)
{
-#if SIZEOF_INTP <= SIZEOF_LONG
+#if NPY_SIZEOF_INTP <= SIZEOF_LONG
return PyInt_FromLong((long) self->size);
#else
- if (self->size < MAX_LONG) {
+ if (self->size < NPY_MAX_LONG) {
return PyInt_FromLong((long) self->size);
}
else {
- return PyLong_FromLongLong((longlong) self->size);
+ return PyLong_FromLongLong((npy_longlong) self->size);
}
#endif
}
@@ -1739,14 +1739,14 @@ arraymultiter_size_get(PyArrayMultiIterObject *self)
static PyObject *
arraymultiter_index_get(PyArrayMultiIterObject *self)
{
-#if SIZEOF_INTP <= SIZEOF_LONG
+#if NPY_SIZEOF_INTP <= SIZEOF_LONG
return PyInt_FromLong((long) self->index);
#else
- if (self->size < MAX_LONG) {
+ if (self->size < NPY_MAX_LONG) {
return PyInt_FromLong((long) self->index);
}
else {
- return PyLong_FromLongLong((longlong) self->index);
+ return PyLong_FromLongLong((npy_longlong) self->index);
}
#endif
}
@@ -2138,7 +2138,7 @@ PyArray_NeighborhoodIterNew(PyArrayIterObject *x, npy_intp *bounds,
clean_x:
Py_DECREF(ret->_internal_iter);
array_iter_base_dealloc((PyArrayIterObject*)ret);
- _pya_free((PyArrayObject*)ret);
+ PyArray_free((PyArrayObject*)ret);
return NULL;
}
@@ -2155,7 +2155,7 @@ static void neighiter_dealloc(PyArrayNeighborhoodIterObject* iter)
Py_DECREF(iter->_internal_iter);
array_iter_base_dealloc((PyArrayIterObject*)iter);
- _pya_free((PyArrayObject*)iter);
+ PyArray_free((PyArrayObject*)iter);
}
NPY_NO_EXPORT PyTypeObject PyArrayNeighborhoodIter_Type = {
diff --git a/numpy/core/src/multiarray/mapping.c b/numpy/core/src/multiarray/mapping.c
index 15952fe93..4d81dd468 100644
--- a/numpy/core/src/multiarray/mapping.c
+++ b/numpy/core/src/multiarray/mapping.c
@@ -1834,15 +1834,15 @@ array_subscript_nice(PyArrayObject *self, PyObject *op)
*/
if (PyArray_Check(mp) && PyArray_NDIM(mp) == 0) {
- npy_bool noellipses = TRUE;
+ npy_bool noellipses = NPY_TRUE;
if ((op == Py_Ellipsis) || PyString_Check(op) || PyUnicode_Check(op)) {
- noellipses = FALSE;
+ noellipses = NPY_FALSE;
}
else if (PyBool_Check(op) || PyArray_IsScalar(op, Bool) ||
(PyArray_Check(op) &&
(PyArray_DIMS((PyArrayObject *)op)==0) &&
PyArray_ISBOOL((PyArrayObject *)op))) {
- noellipses = FALSE;
+ noellipses = NPY_FALSE;
}
else if (PySequence_Check(op)) {
Py_ssize_t n, i;
@@ -1853,7 +1853,7 @@ array_subscript_nice(PyArrayObject *self, PyObject *op)
while (i < n && noellipses) {
temp = PySequence_GetItem(op, i);
if (temp == Py_Ellipsis) {
- noellipses = FALSE;
+ noellipses = NPY_FALSE;
}
Py_DECREF(temp);
i++;
@@ -1915,7 +1915,7 @@ _nonzero_indices(PyObject *myBool, PyArrayIterObject **iters)
iters[j] = NULL;
}
size = PyArray_SIZE(ba);
- ptr = (Bool *)PyArray_DATA(ba);
+ ptr = (npy_bool *)PyArray_DATA(ba);
count = 0;
/* pre-determine how many nonzero entries there are */
diff --git a/numpy/core/src/multiarray/methods.c b/numpy/core/src/multiarray/methods.c
index 24af4db5b..a221f8127 100644
--- a/numpy/core/src/multiarray/methods.c
+++ b/numpy/core/src/multiarray/methods.c
@@ -124,7 +124,7 @@ forward_ndarray_method(PyArrayObject *self, PyObject *args, PyObject *kwds,
static PyObject *
array_take(PyArrayObject *self, PyObject *args, PyObject *kwds)
{
- int dimension = MAX_DIMS;
+ int dimension = NPY_MAXDIMS;
PyObject *indices;
PyArrayObject *out = NULL;
NPY_CLIPMODE mode = NPY_RAISE;
@@ -301,7 +301,7 @@ array_view(PyArrayObject *self, PyObject *args, PyObject *kwds)
}
if ((out_dtype) &&
- (PyArray_DescrConverter(out_dtype, &dtype) == PY_FAIL)) {
+ (PyArray_DescrConverter(out_dtype, &dtype) == NPY_FAIL)) {
return NULL;
}
@@ -334,7 +334,7 @@ array_view(PyArrayObject *self, PyObject *args, PyObject *kwds)
static PyObject *
array_argmax(PyArrayObject *self, PyObject *args, PyObject *kwds)
{
- int axis = MAX_DIMS;
+ int axis = NPY_MAXDIMS;
PyArrayObject *out = NULL;
static char *kwlist[] = {"axis", "out", NULL};
@@ -349,7 +349,7 @@ array_argmax(PyArrayObject *self, PyObject *args, PyObject *kwds)
static PyObject *
array_argmin(PyArrayObject *self, PyObject *args, PyObject *kwds)
{
- int axis = MAX_DIMS;
+ int axis = NPY_MAXDIMS;
PyArrayObject *out = NULL;
static char *kwlist[] = {"axis", "out", NULL};
@@ -376,7 +376,7 @@ array_min(PyArrayObject *self, PyObject *args, PyObject *kwds)
static PyObject *
array_ptp(PyArrayObject *self, PyObject *args, PyObject *kwds)
{
- int axis = MAX_DIMS;
+ int axis = NPY_MAXDIMS;
PyArrayObject *out = NULL;
static char *kwlist[] = {"axis", "out", NULL};
@@ -524,7 +524,7 @@ array_setfield(PyArrayObject *self, PyObject *args, PyObject *kwds)
/*NUMPY_API*/
NPY_NO_EXPORT PyObject *
-PyArray_Byteswap(PyArrayObject *self, Bool inplace)
+PyArray_Byteswap(PyArrayObject *self, npy_bool inplace)
{
PyArrayObject *ret;
npy_intp size;
@@ -565,7 +565,7 @@ PyArray_Byteswap(PyArrayObject *self, Bool inplace)
if ((ret = (PyArrayObject *)PyArray_NewCopy(self,-1)) == NULL) {
return NULL;
}
- new = PyArray_Byteswap(ret, TRUE);
+ new = PyArray_Byteswap(ret, NPY_TRUE);
Py_DECREF(new);
return (PyObject *)ret;
}
@@ -575,7 +575,7 @@ PyArray_Byteswap(PyArrayObject *self, Bool inplace)
static PyObject *
array_byteswap(PyArrayObject *self, PyObject *args)
{
- Bool inplace = FALSE;
+ npy_bool inplace = NPY_FALSE;
if (!PyArg_ParseTuple(args, "|O&",
PyArray_BoolConverter, &inplace)) {
@@ -1204,7 +1204,7 @@ array_resize(PyArrayObject *self, PyObject *args, PyObject *kwds)
static PyObject *
array_repeat(PyArrayObject *self, PyObject *args, PyObject *kwds) {
PyObject *repeats;
- int axis = MAX_DIMS;
+ int axis = NPY_MAXDIMS;
static char *kwlist[] = {"repeats", "axis", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O&", kwlist,
@@ -1535,7 +1535,7 @@ array_reduce(PyArrayObject *self, PyObject *NPY_UNUSED(args))
1) an integer with the pickle version.
2) a Tuple giving the shape
3) a PyArray_Descr Object (with correct bytorder set)
- 4) a Bool stating if Fortran or not
+ 4) a npy_bool stating if Fortran or not
5) a Python object representing the data (a string, or
a list or any user-defined object).
@@ -1583,7 +1583,7 @@ array_setstate(PyArrayObject *self, PyObject *args)
PyObject *rawdata = NULL;
char *datastr;
Py_ssize_t len;
- npy_intp size, dimensions[MAX_DIMS];
+ npy_intp size, dimensions[NPY_MAXDIMS];
int nd;
PyArrayObject_fields *fa = (PyArrayObject_fields *)self;
@@ -1621,7 +1621,7 @@ array_setstate(PyArrayObject *self, PyObject *args)
Py_XDECREF(PyArray_DESCR(self));
fa->descr = typecode;
Py_INCREF(typecode);
- nd = PyArray_IntpFromSequence(shape, dimensions, MAX_DIMS);
+ nd = PyArray_IntpFromSequence(shape, dimensions, NPY_MAXDIMS);
if (nd < 0) {
return NULL;
}
@@ -1630,7 +1630,7 @@ array_setstate(PyArrayObject *self, PyObject *args)
PyErr_SetString(PyExc_ValueError, "Invalid data-type size.");
return NULL;
}
- if (size < 0 || size > MAX_INTP / PyArray_DESCR(self)->elsize) {
+ if (size < 0 || size > NPY_MAX_INTP / PyArray_DESCR(self)->elsize) {
PyErr_NoMemory();
return NULL;
}
@@ -1725,7 +1725,7 @@ array_setstate(PyArrayObject *self, PyObject *args)
Py_DECREF(rawdata);
return PyErr_NoMemory();
}
- if (swap) { /* byte-swap on pickle-read */
+ if (swap) { /* npy_byte-swap on pickle-read */
npy_intp numels = num / PyArray_DESCR(self)->elsize;
PyArray_DESCR(self)->f->copyswapn(PyArray_DATA(self),
PyArray_DESCR(self)->elsize,
@@ -1918,7 +1918,7 @@ array_sum(PyArrayObject *self, PyObject *args, PyObject *kwds)
static PyObject *
array_cumsum(PyArrayObject *self, PyObject *args, PyObject *kwds)
{
- int axis = MAX_DIMS;
+ int axis = NPY_MAXDIMS;
PyArray_Descr *dtype = NULL;
PyArrayObject *out = NULL;
int rtype;
@@ -1946,7 +1946,7 @@ array_prod(PyArrayObject *self, PyObject *args, PyObject *kwds)
static PyObject *
array_cumprod(PyArrayObject *self, PyObject *args, PyObject *kwds)
{
- int axis = MAX_DIMS;
+ int axis = NPY_MAXDIMS;
PyArray_Descr *dtype = NULL;
PyArrayObject *out = NULL;
int rtype;
@@ -2075,7 +2075,7 @@ array_variance(PyArrayObject *self, PyObject *args, PyObject *kwds)
static PyObject *
array_compress(PyArrayObject *self, PyObject *args, PyObject *kwds)
{
- int axis = MAX_DIMS;
+ int axis = NPY_MAXDIMS;
PyObject *condition;
PyArrayObject *out = NULL;
static char *kwlist[] = {"condition", "axis", "out", NULL};
diff --git a/numpy/core/src/multiarray/multiarraymodule.c b/numpy/core/src/multiarray/multiarraymodule.c
index fff1c5ce3..599ff8576 100644
--- a/numpy/core/src/multiarray/multiarraymodule.c
+++ b/numpy/core/src/multiarray/multiarraymodule.c
@@ -654,7 +654,7 @@ static int
_signbit_set(PyArrayObject *arr)
{
static char bitmask = (char) 0x80;
- char *ptr; /* points to the byte to test */
+ char *ptr; /* points to the npy_byte to test */
char byteorder;
int elsize;
@@ -1491,7 +1491,7 @@ PyArray_EquivTypes(PyArray_Descr *type1, PyArray_Descr *type2)
int type_num1, type_num2, size1, size2;
if (type1 == type2) {
- return TRUE;
+ return NPY_TRUE;
}
type_num1 = type1->type_num;
@@ -1500,10 +1500,10 @@ PyArray_EquivTypes(PyArray_Descr *type1, PyArray_Descr *type2)
size2 = type2->elsize;
if (size1 != size2) {
- return FALSE;
+ return NPY_FALSE;
}
if (PyArray_ISNBO(type1->byteorder) != PyArray_ISNBO(type2->byteorder)) {
- return FALSE;
+ return NPY_FALSE;
}
if (type1->subarray || type2->subarray) {
return ((type_num1 == type_num2)
@@ -1529,7 +1529,7 @@ NPY_NO_EXPORT unsigned char
PyArray_EquivTypenums(int typenum1, int typenum2)
{
PyArray_Descr *d1, *d2;
- Bool ret;
+ npy_bool ret;
d1 = PyArray_DescrFromType(typenum1);
d2 = PyArray_DescrFromType(typenum2);
@@ -1609,8 +1609,8 @@ _array_fromobject(PyObject *NPY_UNUSED(ignored), PyObject *args, PyObject *kws)
{
PyObject *op;
PyArrayObject *oparr = NULL, *ret = NULL;
- Bool subok = FALSE;
- Bool copy = TRUE;
+ npy_bool subok = NPY_FALSE;
+ npy_bool copy = NPY_TRUE;
int ndmin = 0, nd;
PyArray_Descr *type = NULL;
PyArray_Descr *oldtype = NULL;
@@ -1854,10 +1854,10 @@ array_empty(PyObject *NPY_UNUSED(ignored), PyObject *args, PyObject *kwds)
switch (order) {
case NPY_CORDER:
- is_f_order = FALSE;
+ is_f_order = NPY_FALSE;
break;
case NPY_FORTRANORDER:
- is_f_order = TRUE;
+ is_f_order = NPY_TRUE;
break;
default:
PyErr_SetString(PyExc_ValueError,
@@ -2002,7 +2002,7 @@ array_zeros(PyObject *NPY_UNUSED(ignored), PyObject *args, PyObject *kwds)
PyArray_Descr *typecode = NULL;
PyArray_Dims shape = {NULL, 0};
NPY_ORDER order = NPY_CORDER;
- npy_bool is_f_order = FALSE;
+ npy_bool is_f_order = NPY_FALSE;
PyArrayObject *ret = NULL;
int maskna = 0;
@@ -2016,10 +2016,10 @@ array_zeros(PyObject *NPY_UNUSED(ignored), PyObject *args, PyObject *kwds)
switch (order) {
case NPY_CORDER:
- is_f_order = FALSE;
+ is_f_order = NPY_FALSE;
break;
case NPY_FORTRANORDER:
- is_f_order = TRUE;
+ is_f_order = NPY_TRUE;
break;
default:
PyErr_SetString(PyExc_ValueError,
@@ -2938,7 +2938,7 @@ array_can_cast_safely(PyObject *NPY_UNUSED(self), PyObject *args,
PyObject *from_obj = NULL;
PyArray_Descr *d1 = NULL;
PyArray_Descr *d2 = NULL;
- Bool ret;
+ npy_bool ret;
PyObject *retobj = NULL;
NPY_CASTING casting = NPY_SAFE_CASTING;
static char *kwlist[] = {"from", "to", "casting", NULL};
@@ -3186,7 +3186,7 @@ as_buffer(PyObject *NPY_UNUSED(dummy), PyObject *args, PyObject *kwds)
{
PyObject *mem;
Py_ssize_t size;
- Bool ro = FALSE, check = TRUE;
+ npy_bool ro = NPY_FALSE, check = NPY_TRUE;
void *memptr;
static char *kwlist[] = {"mem", "size", "readonly", "check", NULL};
@@ -3253,7 +3253,7 @@ format_longfloat(PyObject *NPY_UNUSED(dummy), PyObject *args, PyObject *kwds)
{
PyObject *obj;
unsigned int precision;
- longdouble x;
+ npy_longdouble x;
static char *kwlist[] = {"x", "precision", NULL};
static char repr[100];
@@ -3281,7 +3281,7 @@ compare_chararrays(PyObject *NPY_UNUSED(dummy), PyObject *args, PyObject *kwds)
PyObject *other;
PyArrayObject *newarr, *newoth;
int cmp_op;
- Bool rstrip;
+ npy_bool rstrip;
char *cmp_str;
Py_ssize_t strlength;
PyObject *res = NULL;
@@ -3906,7 +3906,7 @@ setup_scalartypes(PyObject *NPY_UNUSED(dict))
#else
SINGLE_INHERIT(Long, SignedInteger);
#endif
-#if SIZEOF_LONGLONG == SIZEOF_LONG && !defined(NPY_PY3K)
+#if NPY_SIZEOF_LONGLONG == SIZEOF_LONG && !defined(NPY_PY3K)
DUAL_INHERIT(LongLong, Int, SignedInteger);
#else
SINGLE_INHERIT(LongLong, SignedInteger);
diff --git a/numpy/core/src/multiarray/number.c b/numpy/core/src/multiarray/number.c
index a4e42ead0..2ff8c9b71 100644
--- a/numpy/core/src/multiarray/number.c
+++ b/numpy/core/src/multiarray/number.c
@@ -547,7 +547,7 @@ array_inplace_true_divide(PyArrayObject *m1, PyObject *m2)
static int
_array_nonzero(PyArrayObject *mp)
{
- intp n;
+ npy_intp n;
n = PyArray_SIZE(mp);
if (n == 1) {
diff --git a/numpy/core/src/multiarray/refcount.c b/numpy/core/src/multiarray/refcount.c
index 9e5bd888e..d1e9addb4 100644
--- a/numpy/core/src/multiarray/refcount.c
+++ b/numpy/core/src/multiarray/refcount.c
@@ -99,7 +99,7 @@ PyArray_Item_XDECREF(char *data, PyArray_Descr *descr)
NPY_NO_EXPORT int
PyArray_INCREF(PyArrayObject *mp)
{
- intp i, n;
+ npy_intp i, n;
PyObject **data;
PyObject *temp;
PyArrayIterObject *it;
@@ -157,7 +157,7 @@ PyArray_INCREF(PyArrayObject *mp)
NPY_NO_EXPORT int
PyArray_XDECREF(PyArrayObject *mp)
{
- intp i, n;
+ npy_intp i, n;
PyObject **data;
PyObject *temp;
PyArrayIterObject *it;
@@ -212,7 +212,7 @@ PyArray_XDECREF(PyArrayObject *mp)
NPY_NO_EXPORT void
PyArray_FillObjectArray(PyArrayObject *arr, PyObject *obj)
{
- intp i,n;
+ npy_intp i,n;
n = PyArray_SIZE(arr);
if (PyArray_DESCR(arr)->type_num == NPY_OBJECT) {
PyObject **optr;
diff --git a/numpy/core/src/multiarray/scalarapi.c b/numpy/core/src/multiarray/scalarapi.c
index 0cee4b2ea..504c400aa 100644
--- a/numpy/core/src/multiarray/scalarapi.c
+++ b/numpy/core/src/multiarray/scalarapi.c
@@ -37,7 +37,7 @@ scalar_value(PyObject *scalar, PyArray_Descr *descr)
{
int type_num;
int align;
- intp memloc;
+ npy_intp memloc;
if (descr == NULL) {
descr = PyArray_DescrFromScalar(scalar);
type_num = descr->type_num;
@@ -149,7 +149,7 @@ scalar_value(PyObject *scalar, PyArray_Descr *descr)
* Use the alignment flag to figure out where the data begins
* after a PyObject_HEAD
*/
- memloc = (intp)scalar;
+ memloc = (npy_intp)scalar;
memloc += sizeof(PyObject);
/* now round-up to the nearest alignment value */
align = descr->alignment;
@@ -399,7 +399,7 @@ PyArray_ScalarFromObject(PyObject *object)
PyArrayScalar_VAL(ret, CDouble).imag = PyComplex_ImagAsDouble(object);
}
else if (PyLong_Check(object)) {
- longlong val;
+ npy_longlong val;
val = PyLong_AsLongLong(object);
if (val==-1 && PyErr_Occurred()) {
PyErr_Clear();
@@ -536,7 +536,7 @@ PyArray_DescrFromScalar(PyObject *sc)
PyObject *cobj;
PyArray_DatetimeMetaData *dt_data;
- dt_data = _pya_malloc(sizeof(PyArray_DatetimeMetaData));
+ dt_data = PyArray_malloc(sizeof(PyArray_DatetimeMetaData));
if (PyArray_IsScalar(sc, Datetime)) {
descr = PyArray_DescrNewFromType(NPY_DATETIME);
memcpy(dt_data, &((PyDatetimeScalarObject *)sc)->obmeta,
@@ -637,7 +637,7 @@ PyArray_Scalar(void *data, PyArray_Descr *descr, PyObject *base)
type_num = descr->type_num;
if (type_num == NPY_BOOL) {
- PyArrayScalar_RETURN_BOOL_FROM_LONG(*(Bool*)data);
+ PyArrayScalar_RETURN_BOOL_FROM_LONG(*(npy_bool*)data);
}
else if (PyDataType_FLAGCHK(descr, NPY_USE_GETITEM)) {
return descr->f->getitem(data, base);
@@ -726,8 +726,8 @@ PyArray_Scalar(void *data, PyArray_Descr *descr, PyObject *base)
}
#else
/* need aligned data buffer */
- if ((swap) || ((((intp)data) % descr->alignment) != 0)) {
- buffer = _pya_malloc(itemsize);
+ if ((swap) || ((((npy_intp)data) % descr->alignment) != 0)) {
+ buffer = PyArray_malloc(itemsize);
if (buffer == NULL) {
return PyErr_NoMemory();
}
@@ -748,7 +748,7 @@ PyArray_Scalar(void *data, PyArray_Descr *descr, PyObject *base)
length = PyUCS2Buffer_FromUCS4(uni->str,
(npy_ucs4 *)buffer, itemsize >> 2);
if (alloc) {
- _pya_free(buffer);
+ PyArray_free(buffer);
}
/* Resize the unicode result */
if (MyPyUnicode_Resize(uni, length) < 0) {
diff --git a/numpy/core/src/multiarray/sequence.c b/numpy/core/src/multiarray/sequence.c
index 92607b3b9..f8f8b3066 100644
--- a/numpy/core/src/multiarray/sequence.c
+++ b/numpy/core/src/multiarray/sequence.c
@@ -192,7 +192,7 @@ array_any_nonzero(PyArrayObject *arr)
{
npy_intp counter;
PyArrayIterObject *it;
- Bool anyTRUE = FALSE;
+ npy_bool anyTRUE = NPY_FALSE;
it = (PyArrayIterObject *)PyArray_IterNew((PyObject *)arr);
if (it == NULL) {
@@ -201,7 +201,7 @@ array_any_nonzero(PyArrayObject *arr)
counter = it->size;
while (counter--) {
if (PyArray_DESCR(arr)->f->nonzero(it->dataptr, arr)) {
- anyTRUE = TRUE;
+ anyTRUE = NPY_TRUE;
break;
}
PyArray_ITER_NEXT(it);
diff --git a/numpy/core/src/multiarray/shape.c b/numpy/core/src/multiarray/shape.c
index 611071cc0..5cdbaed43 100644
--- a/numpy/core/src/multiarray/shape.c
+++ b/numpy/core/src/multiarray/shape.c
@@ -65,7 +65,7 @@ PyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape, int refcheck,
return NULL;
}
newsize = 1;
- largest = MAX_INTP / PyArray_DESCR(self)->elsize;
+ largest = NPY_MAX_INTP / PyArray_DESCR(self)->elsize;
for(k = 0; k < new_nd; k++) {
if (new_dimensions[k] == 0) {
break;
@@ -90,7 +90,7 @@ PyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape, int refcheck,
}
if (refcheck) {
- refcnt = REFCOUNT(self);
+ refcnt = PyArray_REFCOUNT(self);
}
else {
refcnt = 1;
@@ -182,7 +182,7 @@ PyArray_Newshape(PyArrayObject *self, PyArray_Dims *newdims,
npy_intp *dimensions = newdims->ptr;
PyArrayObject *ret;
int ndim = newdims->len;
- npy_bool same, incref = TRUE;
+ npy_bool same, incref = NPY_TRUE;
npy_intp *strides = NULL;
npy_intp newstrides[NPY_MAXDIMS];
npy_intp newmasknastrides[NPY_MAXDIMS];
@@ -193,11 +193,11 @@ PyArray_Newshape(PyArrayObject *self, PyArray_Dims *newdims,
}
/* Quick check to make sure anything actually needs to be done */
if (ndim == PyArray_NDIM(self)) {
- same = TRUE;
+ same = NPY_TRUE;
i = 0;
while (same && i < ndim) {
if (PyArray_DIM(self,i) != dimensions[i]) {
- same=FALSE;
+ same=NPY_FALSE;
}
i++;
}
@@ -253,7 +253,7 @@ PyArray_Newshape(PyArrayObject *self, PyArray_Dims *newdims,
if (newcopy == NULL) {
return NULL;
}
- incref = FALSE;
+ incref = NPY_FALSE;
self = (PyArrayObject *)newcopy;
build_maskna_strides = 1;
}
@@ -391,7 +391,7 @@ _check_ones(PyArrayObject *self, int newnd,
{
int nd;
npy_intp *dims;
- npy_bool done=FALSE;
+ npy_bool done=NPY_FALSE;
int j, k;
int has_maskna = PyArray_HASMASKNA(self);
@@ -418,7 +418,7 @@ _check_ones(PyArrayObject *self, int newnd,
j++;
}
else {
- done = TRUE;
+ done = NPY_TRUE;
}
}
if (done) {
diff --git a/numpy/core/src/multiarray/ucsnarrow.c b/numpy/core/src/multiarray/ucsnarrow.c
index 689b53d69..ec53ba7ad 100644
--- a/numpy/core/src/multiarray/ucsnarrow.c
+++ b/numpy/core/src/multiarray/ucsnarrow.c
@@ -16,7 +16,7 @@
/* Functions only needed on narrow builds of Python
for converting back and forth between the NumPy Unicode data-type
- (always 4-byte)
+ (always 4-npy_byte)
and the Python Unicode scalar (2-bytes on a narrow build).
*/
diff --git a/numpy/core/src/multiarray/usertypes.c b/numpy/core/src/multiarray/usertypes.c
index 49f9618ed..7ca7c223c 100644
--- a/numpy/core/src/multiarray/usertypes.c
+++ b/numpy/core/src/multiarray/usertypes.c
@@ -56,17 +56,17 @@ _append_new(int *types, int insert)
return newtypes;
}
-static Bool
+static npy_bool
_default_nonzero(void *ip, void *arr)
{
int elsize = PyArray_ITEMSIZE(arr);
char *ptr = ip;
while (elsize--) {
if (*ptr++ != 0) {
- return TRUE;
+ return NPY_TRUE;
}
}
- return FALSE;
+ return NPY_FALSE;
}
static void
diff --git a/numpy/core/src/umath/ufunc_object.c b/numpy/core/src/umath/ufunc_object.c
index 0c7f6b3db..42f45218f 100644
--- a/numpy/core/src/umath/ufunc_object.c
+++ b/numpy/core/src/umath/ufunc_object.c
@@ -91,9 +91,9 @@ _error_handler(int method, PyObject *errobj, char *errtype, int retstatus, int *
PyObject *pyfunc, *ret, *args;
char *name = PyBytes_AS_STRING(PyTuple_GET_ITEM(errobj,0));
char msg[100];
- ALLOW_C_API_DEF;
+ NPY_ALLOW_C_API_DEF;
- ALLOW_C_API;
+ NPY_ALLOW_C_API;
switch(method) {
case UFUNC_ERR_WARN:
PyOS_snprintf(msg, sizeof(msg), "%s encountered in %s", errtype, name);
@@ -153,11 +153,11 @@ _error_handler(int method, PyObject *errobj, char *errtype, int retstatus, int *
}
break;
}
- DISABLE_C_API;
+ NPY_DISABLE_C_API;
return 0;
fail:
- DISABLE_C_API;
+ NPY_DISABLE_C_API;
return -1;
}
@@ -392,8 +392,8 @@ _extract_pyvals(PyObject *ref, char *name, int *bufsize,
PyErr_Format(PyExc_ValueError,
"buffer size (%d) is not in range "
"(%"INTP_FMT" - %"INTP_FMT") or not a multiple of 16",
- *bufsize, (intp) NPY_MIN_BUFSIZE,
- (intp) NPY_MAX_BUFSIZE);
+ *bufsize, (npy_intp) NPY_MIN_BUFSIZE,
+ (npy_intp) NPY_MAX_BUFSIZE);
return -1;
}
@@ -4710,7 +4710,7 @@ ufunc_outer(PyUFuncObject *ufunc, PyObject *args, PyObject *kwds)
}
for (i = 0; i < PyArray_NDIM(ap1); i++) {
PyTuple_SET_ITEM(shape1, i,
- PyLong_FromLongLong((longlong)PyArray_DIMS(ap1)[i]));
+ PyLong_FromLongLong((npy_longlong)PyArray_DIMS(ap1)[i]));
}
shape2 = PyTuple_New(PyArray_NDIM(ap2));
for (i = 0; i < PyArray_NDIM(ap2); i++) {
diff --git a/numpy/f2py/doc/multiarray/array_from_pyobj.c b/numpy/f2py/doc/multiarray/array_from_pyobj.c
index 5a700eecf..03d4aacf6 100644
--- a/numpy/f2py/doc/multiarray/array_from_pyobj.c
+++ b/numpy/f2py/doc/multiarray/array_from_pyobj.c
@@ -113,7 +113,7 @@ PyArrayObject* array_from_pyobj(const int type_num,
if (intent & F2PY_INTENT_OUT) {
if ((!(intent & F2PY_INTENT_C)) && (rank>1)) {
lazy_transpose(arr);
- arr->flags &= ~CONTIGUOUS;
+ arr->flags &= ~NPY_CONTIGUOUS;
}
Py_INCREF(arr);
}
@@ -155,7 +155,7 @@ PyArrayObject* array_from_pyobj(const int type_num,
if ((rank>1) && (! (intent & F2PY_INTENT_C))) {
lazy_transpose(arr);
lazy_transpose(tmp_arr);
- tmp_arr->flags &= ~CONTIGUOUS;
+ tmp_arr->flags &= ~NPY_CONTIGUOUS;
}
arr = tmp_arr;
}
@@ -172,7 +172,7 @@ PyArrayObject* array_from_pyobj(const int type_num,
if (intent & F2PY_INTENT_OUT) {
if ((!(intent & F2PY_INTENT_C)) && (rank>1)) {
lazy_transpose(arr);
- arr->flags &= ~CONTIGUOUS;
+ arr->flags &= ~NPY_CONTIGUOUS;
}
Py_INCREF(arr);
}
@@ -192,13 +192,13 @@ PyArrayObject* array_from_pyobj(const int type_num,
if ((rank>1) && (! (intent & F2PY_INTENT_C))) {
PyArrayObject *tmp_arr = NULL;
lazy_transpose(arr);
- arr->flags &= ~CONTIGUOUS;
+ arr->flags &= ~NPY_CONTIGUOUS;
tmp_arr = (PyArrayObject *) PyArray_CopyFromObject((PyObject *)arr,type_num,0,0);
Py_DECREF(arr);
arr = tmp_arr;
ARR_IS_NULL(arr,"CopyFromObject(Array) failed: intent(fortran)\n");
lazy_transpose(arr);
- arr->flags &= ~CONTIGUOUS;
+ arr->flags &= ~NPY_CONTIGUOUS;
}
if (intent & F2PY_INTENT_OUT)
Py_INCREF(arr);
@@ -238,7 +238,7 @@ void lazy_transpose(PyArrayObject* arr) {
Changes the order of array strides and dimensions. This
corresponds to the lazy transpose of a Numeric array in-situ.
Note that this function is assumed to be used even times for a
- given array. Otherwise, the caller should set flags &= ~CONTIGUOUS.
+ given array. Otherwise, the caller should set flags &= ~NPY_CONTIGUOUS.
*/
int rank,i,s,j;
rank = arr->nd;
diff --git a/numpy/lib/src/_compiled_base.c b/numpy/lib/src/_compiled_base.c
index 536b048f5..20f8e02fa 100644
--- a/numpy/lib/src/_compiled_base.c
+++ b/numpy/lib/src/_compiled_base.c
@@ -1378,7 +1378,7 @@ pack_or_unpack_bits(PyObject *input, int axis, int unpack)
PyArrayObject *inp;
PyArrayObject *new = NULL;
PyArrayObject *out = NULL;
- npy_intp outdims[MAX_DIMS];
+ npy_intp outdims[NPY_MAXDIMS];
int i;
void (*thefunc)(void *, int, npy_intp, npy_intp, void *, npy_intp, npy_intp);
PyArrayIterObject *it, *ot;