diff options
author | Mark Wiebe <mwwiebe@gmail.com> | 2011-03-17 22:22:04 -0700 |
---|---|---|
committer | Mark Wiebe <mwwiebe@gmail.com> | 2011-03-17 22:22:04 -0700 |
commit | 3692b16d8a844c0c042af7c27e7cef93170ea37d (patch) | |
tree | faa8e9798978a832f9e323ea341a7a519fc7854a /numpy | |
parent | d1506b4b72966ed23caa03ecadc087a848cdcfe6 (diff) | |
download | numpy-3692b16d8a844c0c042af7c27e7cef93170ea37d.tar.gz |
API: Rename 'niter' to 'nop' in the nditer
This name was chosen partially based on the previous multi-iter,
which stored an array of iterators, so 'niter' made sense. In the
new nditer, it doesn't, and 'nop' for number of operands seems better.
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/add_newdocs.py | 2 | ||||
-rw-r--r-- | numpy/core/code_generators/numpy_api.py | 2 | ||||
-rw-r--r-- | numpy/core/src/multiarray/nditer.c.src | 1432 | ||||
-rw-r--r-- | numpy/core/src/multiarray/nditer_pywrap.c | 322 | ||||
-rw-r--r-- | numpy/core/src/umath/ufunc_object.c | 92 |
5 files changed, 925 insertions, 925 deletions
diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 414f6f7d1..a7e9ba229 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -266,7 +266,7 @@ add_newdoc('numpy.core', 'nditer', accessed and `has_multi_index` is False. ndim : int The iterator's dimension. - niter : int + nop : int The number of iterator operands. operands : tuple of operand(s) The array(s) to be iterated over. diff --git a/numpy/core/code_generators/numpy_api.py b/numpy/core/code_generators/numpy_api.py index b314f9f84..db2c368dd 100644 --- a/numpy/core/code_generators/numpy_api.py +++ b/numpy/core/code_generators/numpy_api.py @@ -271,7 +271,7 @@ multiarray_funcs_api = { 'NpyIter_ResetBasePointers': 235, 'NpyIter_ResetToIterIndexRange': 236, 'NpyIter_GetNDim': 237, - 'NpyIter_GetNIter': 238, + 'NpyIter_GetNOp': 238, 'NpyIter_GetIterNext': 239, 'NpyIter_GetIterSize': 240, 'NpyIter_GetIterIndexRange': 241, diff --git a/numpy/core/src/multiarray/nditer.c.src b/numpy/core/src/multiarray/nditer.c.src index e12767fbb..ab7cd4ef2 100644 --- a/numpy/core/src/multiarray/nditer.c.src +++ b/numpy/core/src/multiarray/nditer.c.src @@ -115,7 +115,7 @@ /* * The data layout of the iterator is fully specified by - * a triple (itflags, ndim, niter). These three variables + * a triple (itflags, ndim, nop). These three variables * are expected to exist in all functions calling these macros, * either as true variables initialized to the correct values * from the iterator, or as constants in the case of specialized @@ -125,7 +125,7 @@ struct NpyIter_InternalOnly { /* Initial fixed position data */ npy_uint32 itflags; - npy_uint16 ndim, niter; + npy_uint16 ndim, nop; npy_intp itersize, iterstart, iterend; /* iterindex is only used if RANGED or BUFFERED is set */ npy_intp iterindex; @@ -137,53 +137,53 @@ typedef struct NpyIter_AD NpyIter_AxisData; typedef struct NpyIter_BD NpyIter_BufferData; /* Byte sizes of the iterator members */ -#define NIT_PERM_SIZEOF(itflags, ndim, niter) \ +#define NIT_PERM_SIZEOF(itflags, ndim, nop) \ NPY_INTP_ALIGNED(NPY_MAXDIMS) -#define NIT_DTYPES_SIZEOF(itflags, ndim, niter) \ - ((NPY_SIZEOF_INTP)*(niter)) -#define NIT_RESETDATAPTR_SIZEOF(itflags, ndim, niter) \ - ((NPY_SIZEOF_INTP)*(niter+1)) -#define NIT_BASEOFFSETS_SIZEOF(itflags, ndim, niter) \ - ((NPY_SIZEOF_INTP)*(niter+1)) -#define NIT_OPERANDS_SIZEOF(itflags, ndim, niter) \ - ((NPY_SIZEOF_INTP)*(niter)) -#define NIT_OPITFLAGS_SIZEOF(itflags, ndim, niter) \ - (NPY_INTP_ALIGNED(niter)) -#define NIT_BUFFERDATA_SIZEOF(itflags, ndim, niter) \ - ((itflags&NPY_ITFLAG_BUFFER) ? ((NPY_SIZEOF_INTP)*(6 + 9*niter)) : 0) +#define NIT_DTYPES_SIZEOF(itflags, ndim, nop) \ + ((NPY_SIZEOF_INTP)*(nop)) +#define NIT_RESETDATAPTR_SIZEOF(itflags, ndim, nop) \ + ((NPY_SIZEOF_INTP)*(nop+1)) +#define NIT_BASEOFFSETS_SIZEOF(itflags, ndim, nop) \ + ((NPY_SIZEOF_INTP)*(nop+1)) +#define NIT_OPERANDS_SIZEOF(itflags, ndim, nop) \ + ((NPY_SIZEOF_INTP)*(nop)) +#define NIT_OPITFLAGS_SIZEOF(itflags, ndim, nop) \ + (NPY_INTP_ALIGNED(nop)) +#define NIT_BUFFERDATA_SIZEOF(itflags, ndim, nop) \ + ((itflags&NPY_ITFLAG_BUFFER) ? ((NPY_SIZEOF_INTP)*(6 + 9*nop)) : 0) /* Byte offsets of the iterator members starting from iter->iter_flexdata */ #define NIT_PERM_OFFSET() \ (0) -#define NIT_DTYPES_OFFSET(itflags, ndim, niter) \ +#define NIT_DTYPES_OFFSET(itflags, ndim, nop) \ (NIT_PERM_OFFSET() + \ - NIT_PERM_SIZEOF(itflags, ndim, niter)) -#define NIT_RESETDATAPTR_OFFSET(itflags, ndim, niter) \ - (NIT_DTYPES_OFFSET(itflags, ndim, niter) + \ - NIT_DTYPES_SIZEOF(itflags, ndim, niter)) -#define NIT_BASEOFFSETS_OFFSET(itflags, ndim, niter) \ - (NIT_RESETDATAPTR_OFFSET(itflags, ndim, niter) + \ - NIT_RESETDATAPTR_SIZEOF(itflags, ndim, niter)) -#define NIT_OPERANDS_OFFSET(itflags, ndim, niter) \ - (NIT_BASEOFFSETS_OFFSET(itflags, ndim, niter) + \ - NIT_BASEOFFSETS_SIZEOF(itflags, ndim, niter)) -#define NIT_OPITFLAGS_OFFSET(itflags, ndim, niter) \ - (NIT_OPERANDS_OFFSET(itflags, ndim, niter) + \ - NIT_OPERANDS_SIZEOF(itflags, ndim, niter)) -#define NIT_BUFFERDATA_OFFSET(itflags, ndim, niter) \ - (NIT_OPITFLAGS_OFFSET(itflags, ndim, niter) + \ - NIT_OPITFLAGS_SIZEOF(itflags, ndim, niter)) -#define NIT_AXISDATA_OFFSET(itflags, ndim, niter) \ - (NIT_BUFFERDATA_OFFSET(itflags, ndim, niter) + \ - NIT_BUFFERDATA_SIZEOF(itflags, ndim, niter)) + NIT_PERM_SIZEOF(itflags, ndim, nop)) +#define NIT_RESETDATAPTR_OFFSET(itflags, ndim, nop) \ + (NIT_DTYPES_OFFSET(itflags, ndim, nop) + \ + NIT_DTYPES_SIZEOF(itflags, ndim, nop)) +#define NIT_BASEOFFSETS_OFFSET(itflags, ndim, nop) \ + (NIT_RESETDATAPTR_OFFSET(itflags, ndim, nop) + \ + NIT_RESETDATAPTR_SIZEOF(itflags, ndim, nop)) +#define NIT_OPERANDS_OFFSET(itflags, ndim, nop) \ + (NIT_BASEOFFSETS_OFFSET(itflags, ndim, nop) + \ + NIT_BASEOFFSETS_SIZEOF(itflags, ndim, nop)) +#define NIT_OPITFLAGS_OFFSET(itflags, ndim, nop) \ + (NIT_OPERANDS_OFFSET(itflags, ndim, nop) + \ + NIT_OPERANDS_SIZEOF(itflags, ndim, nop)) +#define NIT_BUFFERDATA_OFFSET(itflags, ndim, nop) \ + (NIT_OPITFLAGS_OFFSET(itflags, ndim, nop) + \ + NIT_OPITFLAGS_SIZEOF(itflags, ndim, nop)) +#define NIT_AXISDATA_OFFSET(itflags, ndim, nop) \ + (NIT_BUFFERDATA_OFFSET(itflags, ndim, nop) + \ + NIT_BUFFERDATA_SIZEOF(itflags, ndim, nop)) /* Internal-only ITERATOR DATA MEMBER ACCESS */ #define NIT_ITFLAGS(iter) \ ((iter)->itflags) #define NIT_NDIM(iter) \ ((iter)->ndim) -#define NIT_NITER(iter) \ - ((iter)->niter) +#define NIT_NOP(iter) \ + ((iter)->nop) #define NIT_ITERSIZE(iter) \ (iter->itersize) #define NIT_ITERSTART(iter) \ @@ -195,19 +195,19 @@ typedef struct NpyIter_BD NpyIter_BufferData; #define NIT_PERM(iter) ((char*)( \ &(iter)->iter_flexdata + NIT_PERM_OFFSET())) #define NIT_DTYPES(iter) ((PyArray_Descr **)( \ - &(iter)->iter_flexdata + NIT_DTYPES_OFFSET(itflags, ndim, niter))) + &(iter)->iter_flexdata + NIT_DTYPES_OFFSET(itflags, ndim, nop))) #define NIT_RESETDATAPTR(iter) ((char **)( \ - &(iter)->iter_flexdata + NIT_RESETDATAPTR_OFFSET(itflags, ndim, niter))) + &(iter)->iter_flexdata + NIT_RESETDATAPTR_OFFSET(itflags, ndim, nop))) #define NIT_BASEOFFSETS(iter) ((npy_intp *)( \ - &(iter)->iter_flexdata + NIT_BASEOFFSETS_OFFSET(itflags, ndim, niter))) + &(iter)->iter_flexdata + NIT_BASEOFFSETS_OFFSET(itflags, ndim, nop))) #define NIT_OPERANDS(iter) ((PyArrayObject **)( \ - &(iter)->iter_flexdata + NIT_OPERANDS_OFFSET(itflags, ndim, niter))) + &(iter)->iter_flexdata + NIT_OPERANDS_OFFSET(itflags, ndim, nop))) #define NIT_OPITFLAGS(iter) ( \ - &(iter)->iter_flexdata + NIT_OPITFLAGS_OFFSET(itflags, ndim, niter)) + &(iter)->iter_flexdata + NIT_OPITFLAGS_OFFSET(itflags, ndim, nop)) #define NIT_BUFFERDATA(iter) ((NpyIter_BufferData *)( \ - &(iter)->iter_flexdata + NIT_BUFFERDATA_OFFSET(itflags, ndim, niter))) + &(iter)->iter_flexdata + NIT_BUFFERDATA_OFFSET(itflags, ndim, nop))) #define NIT_AXISDATA(iter) ((NpyIter_AxisData *)( \ - &(iter)->iter_flexdata + NIT_AXISDATA_OFFSET(itflags, ndim, niter))) + &(iter)->iter_flexdata + NIT_AXISDATA_OFFSET(itflags, ndim, nop))) /* Internal-only BUFFERDATA MEMBER ACCESS */ struct NpyIter_BD { @@ -224,21 +224,21 @@ struct NpyIter_BD { #define NBF_STRIDES(bufferdata) ( \ &(bufferdata)->bd_flexdata + 0) #define NBF_PTRS(bufferdata) ((char **) \ - (&(bufferdata)->bd_flexdata + 1*(niter))) + (&(bufferdata)->bd_flexdata + 1*(nop))) #define NBF_REDUCE_OUTERSTRIDES(bufferdata) ( \ - (&(bufferdata)->bd_flexdata + 2*(niter))) + (&(bufferdata)->bd_flexdata + 2*(nop))) #define NBF_REDUCE_OUTERPTRS(bufferdata) ((char **) \ - (&(bufferdata)->bd_flexdata + 3*(niter))) + (&(bufferdata)->bd_flexdata + 3*(nop))) #define NBF_READTRANSFERFN(bufferdata) ((PyArray_StridedTransferFn **) \ - (&(bufferdata)->bd_flexdata + 4*(niter))) + (&(bufferdata)->bd_flexdata + 4*(nop))) #define NBF_READTRANSFERDATA(bufferdata) ((void **) \ - (&(bufferdata)->bd_flexdata + 5*(niter))) + (&(bufferdata)->bd_flexdata + 5*(nop))) #define NBF_WRITETRANSFERFN(bufferdata) ((PyArray_StridedTransferFn **) \ - (&(bufferdata)->bd_flexdata + 6*(niter))) + (&(bufferdata)->bd_flexdata + 6*(nop))) #define NBF_WRITETRANSFERDATA(bufferdata) ((void **) \ - (&(bufferdata)->bd_flexdata + 7*(niter))) + (&(bufferdata)->bd_flexdata + 7*(nop))) #define NBF_BUFFERS(bufferdata) ((char **) \ - (&(bufferdata)->bd_flexdata + 8*(niter))) + (&(bufferdata)->bd_flexdata + 8*(nop))) /* Internal-only AXISDATA MEMBER ACCESS. */ struct NpyIter_AD { @@ -250,25 +250,25 @@ struct NpyIter_AD { #define NAD_STRIDES(axisdata) ( \ &(axisdata)->ad_flexdata + 0) #define NAD_PTRS(axisdata) ((char **) \ - &(axisdata)->ad_flexdata + 1*(niter+1)) + &(axisdata)->ad_flexdata + 1*(nop+1)) #define NAD_NSTRIDES() \ - ((niter) + ((itflags&NPY_ITFLAG_HASINDEX) ? 1 : 0)) + ((nop) + ((itflags&NPY_ITFLAG_HASINDEX) ? 1 : 0)) /* Size of one AXISDATA struct within the iterator */ -#define NIT_AXISDATA_SIZEOF(itflags, ndim, niter) (( \ +#define NIT_AXISDATA_SIZEOF(itflags, ndim, nop) (( \ /* intp shape */ \ 1 + \ /* intp index */ \ 1 + \ - /* intp stride[niter+1] AND char* ptr[niter+1] */ \ - 2*((niter)+1) \ + /* intp stride[nop+1] AND char* ptr[nop+1] */ \ + 2*((nop)+1) \ )*NPY_SIZEOF_INTP ) /* * Macro to advance an AXISDATA pointer by a specified count. * Requires that sizeof_axisdata be previously initialized - * to NIT_AXISDATA_SIZEOF(itflags, ndim, niter). + * to NIT_AXISDATA_SIZEOF(itflags, ndim, nop). */ #define NIT_INDEX_AXISDATA(axisdata, index) ((NpyIter_AxisData *) \ (((char *)(axisdata)) + (index)*sizeof_axisdata)) @@ -276,19 +276,19 @@ struct NpyIter_AD { axisdata = NIT_INDEX_AXISDATA(axisdata, count) /* Size of the whole iterator */ -#define NIT_SIZEOF_ITERATOR(itflags, ndim, niter) ( \ +#define NIT_SIZEOF_ITERATOR(itflags, ndim, nop) ( \ sizeof(struct NpyIter_InternalOnly) + \ - NIT_AXISDATA_OFFSET(itflags, ndim, niter) + \ - NIT_AXISDATA_SIZEOF(itflags, ndim, niter)*(ndim)) + NIT_AXISDATA_OFFSET(itflags, ndim, nop) + \ + NIT_AXISDATA_SIZEOF(itflags, ndim, nop)*(ndim)) /* Internal helper functions */ static int npyiter_check_global_flags(npy_uint32 flags, npy_uint32* itflags); static int -npyiter_check_op_axes(int niter, int oa_ndim, int **op_axes, +npyiter_check_op_axes(int nop, int oa_ndim, int **op_axes, npy_intp *itershape); static int -npyiter_calculate_ndim(int niter, PyArrayObject **op_in, +npyiter_calculate_ndim(int nop, PyArrayObject **op_in, int oa_ndim); static int npyiter_check_per_op_flags(npy_uint32 flags, char *op_itflags); @@ -300,7 +300,7 @@ npyiter_prepare_one_operand(PyArrayObject **op, npy_uint32 flags, npy_uint32 op_flags, char *op_itflags); static int -npyiter_prepare_operands(int niter, PyArrayObject **op_in, +npyiter_prepare_operands(int nop, PyArrayObject **op_in, PyArrayObject **op, char **op_dataptr, PyArray_Descr **op_request_dtypes, @@ -308,7 +308,7 @@ npyiter_prepare_operands(int niter, PyArrayObject **op_in, npy_uint32 flags, npy_uint32 *op_flags, char *op_itflags); static int -npyiter_check_casting(int niter, PyArrayObject **op, +npyiter_check_casting(int nop, PyArrayObject **op, PyArray_Descr **op_dtype, NPY_CASTING casting, char *op_itflags); @@ -319,7 +319,7 @@ npyiter_fill_axisdata(NpyIter *iter, npy_uint32 flags, char *op_itflags, npy_intp *itershape, int output_scalars); static void -npyiter_replace_axisdata(NpyIter *iter, int iiter, +npyiter_replace_axisdata(NpyIter *iter, int iop, PyArrayObject *op, int op_ndim, char *op_dataptr, int *op_axes); @@ -338,7 +338,7 @@ static void npyiter_coalesce_axes(NpyIter *iter); static PyArray_Descr * -npyiter_get_common_dtype(int niter, PyArrayObject **op, +npyiter_get_common_dtype(int nop, PyArrayObject **op, char *op_itflags, PyArray_Descr **op_dtype, PyArray_Descr **op_request_dtypes, int only_inputs, int output_scalars); @@ -355,7 +355,7 @@ npyiter_allocate_arrays(NpyIter *iter, npy_uint32 *op_flags, char *op_itflags, int **op_axes, int output_scalars); static void -npyiter_get_priority_subtype(int niter, PyArrayObject **op, +npyiter_get_priority_subtype(int nop, PyArrayObject **op, char *op_itflags, double *subtype_priority, PyTypeObject **subtype); @@ -378,7 +378,7 @@ npyiter_checkreducesize(NpyIter *iter, npy_intp count, * options for controlling the broadcasting, shape, and buffer size. */ NPY_NO_EXPORT NpyIter * -NpyIter_AdvancedNew(int niter, PyArrayObject **op_in, npy_uint32 flags, +NpyIter_AdvancedNew(int nop, PyArrayObject **op_in, npy_uint32 flags, NPY_ORDER order, NPY_CASTING casting, npy_uint32 *op_flags, PyArray_Descr **op_request_dtypes, @@ -387,7 +387,7 @@ NpyIter_AdvancedNew(int niter, PyArrayObject **op_in, npy_uint32 flags, { npy_uint32 itflags = NPY_ITFLAG_IDENTPERM; int idim, ndim; - int iiter; + int iop; /* The iterator being constructed */ NpyIter *iter; @@ -429,15 +429,15 @@ NpyIter_AdvancedNew(int niter, PyArrayObject **op_in, npy_uint32 flags, NPY_IT_TIME_POINT(c_start); - if (niter > NPY_MAXARGS) { + if (nop > NPY_MAXARGS) { PyErr_Format(PyExc_ValueError, "Cannot construct an iterator with more than %d operands " - "(%d were requested)", (int)NPY_MAXARGS, (int)niter); + "(%d were requested)", (int)NPY_MAXARGS, (int)nop); return NULL; } /* Error check 'oa_ndim' and 'op_axes', which must be used together */ - if (!npyiter_check_op_axes(niter, oa_ndim, op_axes, itershape)) { + if (!npyiter_check_op_axes(nop, oa_ndim, op_axes, itershape)) { return NULL; } @@ -451,7 +451,7 @@ NpyIter_AdvancedNew(int niter, PyArrayObject **op_in, npy_uint32 flags, NPY_IT_TIME_POINT(c_check_global_flags); /* Calculate how many dimensions the iterator should have */ - ndim = npyiter_calculate_ndim(niter, op_in, oa_ndim); + ndim = npyiter_calculate_ndim(nop, op_in, oa_ndim); /* If 'ndim' is zero, any outputs should be scalars */ if (ndim == 0) { @@ -463,16 +463,16 @@ NpyIter_AdvancedNew(int niter, PyArrayObject **op_in, npy_uint32 flags, /* Allocate memory for the iterator */ iter = (NpyIter*) - PyArray_malloc(NIT_SIZEOF_ITERATOR(itflags, ndim, niter)); + PyArray_malloc(NIT_SIZEOF_ITERATOR(itflags, ndim, nop)); NPY_IT_TIME_POINT(c_malloc); /* Fill in the basic data */ NIT_ITFLAGS(iter) = itflags; NIT_NDIM(iter) = ndim; - NIT_NITER(iter) = niter; + NIT_NOP(iter) = nop; NIT_ITERINDEX(iter) = 0; - memset(NIT_BASEOFFSETS(iter), 0, (niter+1)*NPY_SIZEOF_INTP); + memset(NIT_BASEOFFSETS(iter), 0, (nop+1)*NPY_SIZEOF_INTP); op = NIT_OPERANDS(iter); op_dtype = NIT_DTYPES(iter); @@ -480,7 +480,7 @@ NpyIter_AdvancedNew(int niter, PyArrayObject **op_in, npy_uint32 flags, op_dataptr = NIT_RESETDATAPTR(iter); /* Prepare all the operands */ - if (!npyiter_prepare_operands(niter, op_in, op, op_dataptr, + if (!npyiter_prepare_operands(nop, op_in, op, op_dataptr, op_request_dtypes, op_dtype, flags, op_flags, op_itflags)) { @@ -488,7 +488,7 @@ NpyIter_AdvancedNew(int niter, PyArrayObject **op_in, npy_uint32 flags, return NULL; } /* Set resetindex to zero as well (it's just after the resetdataptr) */ - op_dataptr[niter] = 0; + op_dataptr[nop] = 0; NPY_IT_TIME_POINT(c_prepare_operands); @@ -499,9 +499,9 @@ NpyIter_AdvancedNew(int niter, PyArrayObject **op_in, npy_uint32 flags, if (itflags&NPY_ITFLAG_BUFFER) { bufferdata = NIT_BUFFERDATA(iter); NBF_SIZE(bufferdata) = 0; - memset(NBF_BUFFERS(bufferdata), 0, niter*NPY_SIZEOF_INTP); - memset(NBF_READTRANSFERDATA(bufferdata), 0, niter*NPY_SIZEOF_INTP); - memset(NBF_WRITETRANSFERDATA(bufferdata), 0, niter*NPY_SIZEOF_INTP); + memset(NBF_BUFFERS(bufferdata), 0, nop*NPY_SIZEOF_INTP); + memset(NBF_READTRANSFERDATA(bufferdata), 0, nop*NPY_SIZEOF_INTP); + memset(NBF_WRITETRANSFERDATA(bufferdata), 0, nop*NPY_SIZEOF_INTP); } /* Fill in the AXISDATA arrays and set the ITERSIZE field */ @@ -554,19 +554,19 @@ NpyIter_AdvancedNew(int niter, PyArrayObject **op_in, npy_uint32 flags, NPY_IT_TIME_POINT(c_apply_forced_iteration_order); /* Set some flags for allocated outputs */ - for (iiter = 0; iiter < niter; ++iiter) { - if (op[iiter] == NULL) { + for (iop = 0; iop < nop; ++iop) { + if (op[iop] == NULL) { /* Flag this so later we can avoid flipping axes */ any_allocate = 1; /* If a subtype may be used, indicate so */ - if (!(op_flags[iiter]&NPY_ITER_NO_SUBTYPE)) { + if (!(op_flags[iop]&NPY_ITER_NO_SUBTYPE)) { need_subtype = 1; } /* * If the data type wasn't provided, will need to * calculate it. */ - if (op_dtype[iiter] == NULL) { + if (op_dtype[iop] == NULL) { any_missing_dtypes = 1; } } @@ -593,7 +593,7 @@ NpyIter_AdvancedNew(int niter, PyArrayObject **op_in, npy_uint32 flags, NPY_IT_TIME_POINT(c_find_best_axis_ordering); if (need_subtype) { - npyiter_get_priority_subtype(niter, op, op_itflags, + npyiter_get_priority_subtype(nop, op, op_itflags, &subtype_priority, &subtype); } @@ -610,7 +610,7 @@ NpyIter_AdvancedNew(int niter, PyArrayObject **op_in, npy_uint32 flags, op = NIT_OPERANDS(iter); op_dtype = NIT_DTYPES(iter); - dtype = npyiter_get_common_dtype(niter, op, + dtype = npyiter_get_common_dtype(nop, op, op_itflags, op_dtype, op_request_dtypes, only_inputs, @@ -622,21 +622,21 @@ NpyIter_AdvancedNew(int niter, PyArrayObject **op_in, npy_uint32 flags, if (flags&NPY_ITER_COMMON_DTYPE) { NPY_IT_DBG_PRINT("Iterator: Replacing all data types\n"); /* Replace all the data types */ - for (iiter = 0; iiter < niter; ++iiter) { - if (op_dtype[iiter] != dtype) { - Py_XDECREF(op_dtype[iiter]); + for (iop = 0; iop < nop; ++iop) { + if (op_dtype[iop] != dtype) { + Py_XDECREF(op_dtype[iop]); Py_INCREF(dtype); - op_dtype[iiter] = dtype; + op_dtype[iop] = dtype; } } } else { NPY_IT_DBG_PRINT("Iterator: Setting unset output data types\n"); /* Replace the NULL data types */ - for (iiter = 0; iiter < niter; ++iiter) { - if (op_dtype[iiter] == NULL) { + for (iop = 0; iop < nop; ++iop) { + if (op_dtype[iop] == NULL) { Py_INCREF(dtype); - op_dtype[iiter] = dtype; + op_dtype[iop] = dtype; } } } @@ -650,7 +650,7 @@ NpyIter_AdvancedNew(int niter, PyArrayObject **op_in, npy_uint32 flags, * to check that data type conversions are following the * casting rules. */ - if (!npyiter_check_casting(niter, op, op_dtype, casting, op_itflags)) { + if (!npyiter_check_casting(nop, op, op_dtype, casting, op_itflags)) { NpyIter_Deallocate(iter); return NULL; } @@ -712,8 +712,8 @@ NpyIter_AdvancedNew(int niter, PyArrayObject **op_in, npy_uint32 flags, * reference arrays and flag it if so. */ if (flags&NPY_ITER_REFS_OK) { - for (iiter = 0; iiter < niter; ++iiter) { - PyArray_Descr *rdt = op_dtype[iiter]; + for (iop = 0; iop < nop; ++iop) { + PyArray_Descr *rdt = op_dtype[iop]; if ((rdt->flags&(NPY_ITEM_REFCOUNT| NPY_ITEM_IS_POINTER| NPY_NEEDS_PYAPI)) != 0) { @@ -732,7 +732,7 @@ NpyIter_AdvancedNew(int niter, PyArrayObject **op_in, npy_uint32 flags, if (itflags&NPY_ITFLAG_DELAYBUF) { bufferdata = NIT_BUFFERDATA(iter); /* Make the data pointers NULL */ - memset(NBF_PTRS(bufferdata), 0, niter*NPY_SIZEOF_INTP); + memset(NBF_PTRS(bufferdata), 0, nop*NPY_SIZEOF_INTP); } else { /* Allocate the buffers */ @@ -777,12 +777,12 @@ NpyIter_AdvancedNew(int niter, PyArrayObject **op_in, npy_uint32 flags, * standard NumPy broadcasting rules and the default buffer size. */ NPY_NO_EXPORT NpyIter * -NpyIter_MultiNew(int niter, PyArrayObject **op_in, npy_uint32 flags, +NpyIter_MultiNew(int nop, PyArrayObject **op_in, npy_uint32 flags, NPY_ORDER order, NPY_CASTING casting, npy_uint32 *op_flags, PyArray_Descr **op_request_dtypes) { - return NpyIter_AdvancedNew(niter, op_in, flags, order, casting, + return NpyIter_AdvancedNew(nop, op_in, flags, order, casting, op_flags, op_request_dtypes, 0, NULL, NULL, 0); } @@ -812,7 +812,7 @@ NpyIter_Copy(NpyIter *iter) { npy_uint32 itflags = NIT_ITFLAGS(iter); int ndim = NIT_NDIM(iter); - int iiter, niter = NIT_NITER(iter); + int iop, nop = NIT_NOP(iter); int out_of_memory = 0; npy_intp size; @@ -821,7 +821,7 @@ NpyIter_Copy(NpyIter *iter) PyArray_Descr **dtypes; /* Allocate memory for the new iterator */ - size = NIT_SIZEOF_ITERATOR(itflags, ndim, niter); + size = NIT_SIZEOF_ITERATOR(itflags, ndim, nop); newiter = (NpyIter*)PyArray_malloc(size); /* Copy the raw values to the new iterator */ @@ -830,9 +830,9 @@ NpyIter_Copy(NpyIter *iter) /* Take ownership of references to the operands and dtypes */ objects = NIT_OPERANDS(newiter); dtypes = NIT_DTYPES(newiter); - for (iiter = 0; iiter < niter; ++iiter) { - Py_INCREF(objects[iiter]); - Py_INCREF(dtypes[iiter]); + for (iop = 0; iop < nop; ++iop) { + Py_INCREF(objects[iop]); + Py_INCREF(dtypes[iop]); } /* Allocate buffers and make copies of the transfer data if necessary */ @@ -848,41 +848,41 @@ NpyIter_Copy(NpyIter *iter) writetransferdata = NBF_WRITETRANSFERDATA(bufferdata); buffersize = NBF_BUFFERSIZE(bufferdata); - for (iiter = 0; iiter < niter; ++iiter) { - if (buffers[iiter] != NULL) { + for (iop = 0; iop < nop; ++iop) { + if (buffers[iop] != NULL) { if (out_of_memory) { - buffers[iiter] = NULL; + buffers[iop] = NULL; } else { - itemsize = dtypes[iiter]->elsize; - buffers[iiter] = PyArray_malloc(itemsize*buffersize); - if (buffers[iiter] == NULL) { + itemsize = dtypes[iop]->elsize; + buffers[iop] = PyArray_malloc(itemsize*buffersize); + if (buffers[iop] == NULL) { out_of_memory = 1; } } } - if (readtransferdata[iiter] != NULL) { + if (readtransferdata[iop] != NULL) { if (out_of_memory) { - readtransferdata[iiter] = NULL; + readtransferdata[iop] = NULL; } else { - readtransferdata[iiter] = - PyArray_CopyStridedTransferData(readtransferdata[iiter]); - if (readtransferdata[iiter] == NULL) { + readtransferdata[iop] = + PyArray_CopyStridedTransferData(readtransferdata[iop]); + if (readtransferdata[iop] == NULL) { out_of_memory = 1; } } } - if (writetransferdata[iiter] != NULL) { + if (writetransferdata[iop] != NULL) { if (out_of_memory) { - writetransferdata[iiter] = NULL; + writetransferdata[iop] = NULL; } else { - writetransferdata[iiter] = - PyArray_CopyStridedTransferData(writetransferdata[iiter]); - if (writetransferdata[iiter] == NULL) { + writetransferdata[iop] = + PyArray_CopyStridedTransferData(writetransferdata[iop]); + if (writetransferdata[iop] == NULL) { out_of_memory = 1; } } @@ -915,7 +915,7 @@ NpyIter_Deallocate(NpyIter *iter) { npy_uint32 itflags = NIT_ITFLAGS(iter); /*int ndim = NIT_NDIM(iter);*/ - int iiter, niter = NIT_NITER(iter); + int iop, nop = NIT_NOP(iter); PyArray_Descr **dtype = NIT_DTYPES(iter); PyArrayObject **object = NIT_OPERANDS(iter); @@ -928,21 +928,21 @@ NpyIter_Deallocate(NpyIter *iter) /* buffers */ buffers = NBF_BUFFERS(bufferdata); - for(iiter = 0; iiter < niter; ++iiter, ++buffers) { + for(iop = 0; iop < nop; ++iop, ++buffers) { if (*buffers) { PyArray_free(*buffers); } } /* read bufferdata */ transferdata = NBF_READTRANSFERDATA(bufferdata); - for(iiter = 0; iiter < niter; ++iiter, ++transferdata) { + for(iop = 0; iop < nop; ++iop, ++transferdata) { if (*transferdata) { PyArray_FreeStridedTransferData(*transferdata); } } /* write bufferdata */ transferdata = NBF_WRITETRANSFERDATA(bufferdata); - for(iiter = 0; iiter < niter; ++iiter, ++transferdata) { + for(iop = 0; iop < nop; ++iop, ++transferdata) { if (*transferdata) { PyArray_FreeStridedTransferData(*transferdata); } @@ -950,7 +950,7 @@ NpyIter_Deallocate(NpyIter *iter) } /* Deallocate all the dtypes and objects that were iterated */ - for(iiter = 0; iiter < niter; ++iiter, ++dtype, ++object) { + for(iop = 0; iop < nop; ++iop, ++dtype, ++object) { Py_XDECREF(*dtype); Py_XDECREF(*object); } @@ -973,12 +973,12 @@ NpyIter_RemoveAxis(NpyIter *iter, int axis) { npy_uint32 itflags = NIT_ITFLAGS(iter); int idim, ndim = NIT_NDIM(iter); - int iiter, niter = NIT_NITER(iter); + int iop, nop = NIT_NOP(iter); int xdim = 0; char *perm = NIT_PERM(iter); NpyIter_AxisData *axisdata_del = NIT_AXISDATA(iter), *axisdata; - npy_intp sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, niter); + npy_intp sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, nop); npy_intp *baseoffsets = NIT_BASEOFFSETS(iter); char **resetdataptr = NIT_RESETDATAPTR(iter); @@ -1028,10 +1028,10 @@ NpyIter_RemoveAxis(NpyIter *iter, int axis) * Adjust baseoffsets and resetbaseptr back to the start of * this axis. */ - for (iiter = 0; iiter < niter; ++iiter) { - offset = (shape-1)*strides[iiter]; - baseoffsets[iiter] += offset; - resetdataptr[iiter] += offset; + for (iop = 0; iop < nop; ++iop) { + offset = (shape-1)*strides[iop]; + baseoffsets[iop] += offset; + resetdataptr[iop] += offset; } break; } @@ -1082,8 +1082,8 @@ NpyIter_RemoveAxis(NpyIter *iter, int axis) else { npy_intp *strides = NAD_STRIDES(axisdata_del); NAD_SHAPE(axisdata_del) = 1; - for (iiter = 0; iiter < niter; ++iiter) { - strides[iiter] = 0; + for (iop = 0; iop < nop; ++iop) { + strides[iop] = 0; } NIT_ITFLAGS(iter) |= NPY_ITFLAG_ONEITERATION; } @@ -1123,7 +1123,7 @@ NpyIter_EnableExternalLoop(NpyIter *iter) { npy_uint32 itflags = NIT_ITFLAGS(iter); /*int ndim = NIT_NDIM(iter);*/ - int niter = NIT_NITER(iter); + int nop = NIT_NOP(iter); /* Check conditions under which this can be done */ if (itflags&(NPY_ITFLAG_HASINDEX|NPY_ITFLAG_HASMULTIINDEX)) { @@ -1173,7 +1173,7 @@ NpyIter_Reset(NpyIter *iter, char **errmsg) { npy_uint32 itflags = NIT_ITFLAGS(iter); /*int ndim = NIT_NDIM(iter);*/ - int niter = NIT_NITER(iter); + int nop = NIT_NOP(iter); if (itflags&NPY_ITFLAG_BUFFER) { NpyIter_BufferData *bufferdata; @@ -1225,7 +1225,7 @@ NpyIter_ResetBasePointers(NpyIter *iter, char **baseptrs, char **errmsg) { npy_uint32 itflags = NIT_ITFLAGS(iter); /*int ndim = NIT_NDIM(iter);*/ - int iiter, niter = NIT_NITER(iter); + int iop, nop = NIT_NOP(iter); char **resetdataptr = NIT_RESETDATAPTR(iter); npy_intp *baseoffsets = NIT_BASEOFFSETS(iter); @@ -1245,8 +1245,8 @@ NpyIter_ResetBasePointers(NpyIter *iter, char **baseptrs, char **errmsg) } /* The new data pointers for resetting */ - for (iiter = 0; iiter < niter; ++iiter) { - resetdataptr[iiter] = baseptrs[iiter] + baseoffsets[iiter]; + for (iop = 0; iop < nop; ++iop) { + resetdataptr[iop] = baseptrs[iop] + baseoffsets[iop]; } npyiter_goto_iterindex(iter, NIT_ITERSTART(iter)); @@ -1273,7 +1273,7 @@ NpyIter_ResetToIterIndexRange(NpyIter *iter, { npy_uint32 itflags = NIT_ITFLAGS(iter); /*int ndim = NIT_NDIM(iter);*/ - /*int niter = NIT_NITER(iter);*/ + /*int nop = NIT_NOP(iter);*/ if (!(itflags&NPY_ITFLAG_RANGE)) { if (errmsg == NULL) { @@ -1331,7 +1331,7 @@ NpyIter_GotoMultiIndex(NpyIter *iter, npy_intp *multi_index) { npy_uint32 itflags = NIT_ITFLAGS(iter); int idim, ndim = NIT_NDIM(iter); - int niter = NIT_NITER(iter); + int nop = NIT_NOP(iter); npy_intp iterindex, factor; NpyIter_AxisData *axisdata; @@ -1361,7 +1361,7 @@ NpyIter_GotoMultiIndex(NpyIter *iter, npy_intp *multi_index) perm = NIT_PERM(iter); axisdata = NIT_AXISDATA(iter); - sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, niter); + sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, nop); /* Compute the iterindex corresponding to the multi-index */ iterindex = 0; @@ -1417,7 +1417,7 @@ NpyIter_GotoIndex(NpyIter *iter, npy_intp flat_index) { npy_uint32 itflags = NIT_ITFLAGS(iter); int idim, ndim = NIT_NDIM(iter); - int niter = NIT_NITER(iter); + int nop = NIT_NOP(iter); npy_intp iterindex, factor; NpyIter_AxisData *axisdata; @@ -1452,7 +1452,7 @@ NpyIter_GotoIndex(NpyIter *iter, npy_intp flat_index) } axisdata = NIT_AXISDATA(iter); - sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, niter); + sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, nop); /* Compute the iterindex corresponding to the flat_index */ iterindex = 0; @@ -1460,7 +1460,7 @@ NpyIter_GotoIndex(NpyIter *iter, npy_intp flat_index) for (idim = 0; idim < ndim; ++idim) { npy_intp i, shape, iterstride; - iterstride = NAD_STRIDES(axisdata)[niter]; + iterstride = NAD_STRIDES(axisdata)[nop]; shape = NAD_SHAPE(axisdata); /* Extract the index from the flat_index */ @@ -1505,7 +1505,7 @@ NpyIter_GotoIterIndex(NpyIter *iter, npy_intp iterindex) { npy_uint32 itflags = NIT_ITFLAGS(iter); /*int ndim = NIT_NDIM(iter);*/ - int iiter, niter = NIT_NITER(iter); + int iop, nop = NIT_NOP(iter); if (itflags&NPY_ITFLAG_EXLOOP) { PyErr_SetString(PyExc_ValueError, @@ -1537,8 +1537,8 @@ NpyIter_GotoIterIndex(NpyIter *iter, npy_intp iterindex) ptrs = NBF_PTRS(bufferdata); delta = iterindex - NIT_ITERINDEX(iter); - for (iiter = 0; iiter < niter; ++iiter) { - ptrs[iiter] += delta * strides[iiter]; + for (iop = 0; iop < nop; ++iop) { + ptrs[iop] += delta * strides[iop]; } NIT_ITERINDEX(iter) = iterindex; @@ -1569,7 +1569,7 @@ NpyIter_GetIterIndex(NpyIter *iter) { npy_uint32 itflags = NIT_ITFLAGS(iter); int idim, ndim = NIT_NDIM(iter); - int niter = NIT_NITER(iter); + int nop = NIT_NOP(iter); /* iterindex is only used if NPY_ITER_RANGED or NPY_ITER_BUFFERED was set */ if (itflags&(NPY_ITFLAG_RANGE|NPY_ITFLAG_BUFFER)) { @@ -1581,7 +1581,7 @@ NpyIter_GetIterIndex(NpyIter *iter) npy_intp sizeof_axisdata; iterindex = 0; - sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, niter); + sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, nop); axisdata = NIT_INDEX_AXISDATA(NIT_AXISDATA(iter), ndim-1); for (idim = ndim-2; idim >= 0; --idim) { @@ -1610,23 +1610,23 @@ NpyIter_GetIterIndex(NpyIter *iter) * #tag_ndim = 1, 2, ANY# */ /**begin repeat2 - * #const_niter = 1, 2, NPY_MAXDIMS# - * #tag_niter = 1, 2, ANY# + * #const_nop = 1, 2, NPY_MAXDIMS# + * #tag_nop = 1, 2, ANY# */ -/* Specialized iternext (@const_itflags@,@tag_ndim@,@tag_niter@) */ +/* Specialized iternext (@const_itflags@,@tag_ndim@,@tag_nop@) */ static int -npyiter_iternext_itflags@tag_itflags@_dims@tag_ndim@_iters@tag_niter@( +npyiter_iternext_itflags@tag_itflags@_dims@tag_ndim@_iters@tag_nop@( NpyIter *iter) { const npy_uint32 itflags = @const_itflags@; #if @const_ndim@ >= NPY_MAXDIMS int idim, ndim = NIT_NDIM(iter); #endif -#if @const_niter@ < NPY_MAXDIMS - const int niter = @const_niter@; +#if @const_nop@ < NPY_MAXDIMS + const int nop = @const_nop@; #else - int niter = NIT_NITER(iter); + int nop = NIT_NOP(iter); #endif npy_intp istrides, nstrides, sizeof_axisdata; @@ -1648,7 +1648,7 @@ npyiter_iternext_itflags@tag_itflags@_dims@tag_ndim@_iters@tag_niter@( #endif nstrides = NAD_NSTRIDES(); - sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, niter); + sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, nop); axisdata0 = NIT_AXISDATA(iter); # if !(@const_itflags@&NPY_ITFLAG_EXLOOP) @@ -1763,8 +1763,8 @@ npyiter_iternext_itflags@tag_itflags@_dims@tag_ndim@_iters@tag_niter@( /**begin repeat - * #const_niter = 1, 2, 3, 4, NPY_MAXDIMS# - * #tag_niter = 1, 2, 3, 4, ANY# + * #const_nop = 1, 2, 3, 4, NPY_MAXDIMS# + * #tag_nop = 1, 2, 3, 4, ANY# */ /* @@ -1772,17 +1772,17 @@ npyiter_iternext_itflags@tag_itflags@_dims@tag_ndim@_iters@tag_niter@( * is done with a double loop to avoid frequent re-buffering. */ static int -npyiter_buffered_reduce_iternext_iters@tag_niter@(NpyIter *iter) +npyiter_buffered_reduce_iternext_iters@tag_nop@(NpyIter *iter) { npy_uint32 itflags = NIT_ITFLAGS(iter); /*int ndim = NIT_NDIM(iter);*/ -#if @const_niter@ >= NPY_MAXDIMS - int niter = NIT_NITER(iter); +#if @const_nop@ >= NPY_MAXDIMS + int nop = NIT_NOP(iter); #else - const int niter = @const_niter@; + const int nop = @const_nop@; #endif - int iiter; + int iop; NpyIter_AxisData *axisdata; NpyIter_BufferData *bufferdata = NIT_BUFFERDATA(iter); @@ -1801,8 +1801,8 @@ npyiter_buffered_reduce_iternext_iters@tag_niter@(NpyIter *iter) npy_intp *strides; strides = NBF_STRIDES(bufferdata); - for (iiter = 0; iiter < niter; ++iiter) { - ptrs[iiter] += strides[iiter]; + for (iop = 0; iop < nop; ++iop) { + ptrs[iop] += strides[iop]; } return 1; } @@ -1817,10 +1817,10 @@ npyiter_buffered_reduce_iternext_iters@tag_niter@(NpyIter *iter) if (++NBF_REDUCE_POS(bufferdata) < NBF_REDUCE_OUTERSIZE(bufferdata)) { npy_intp *reduce_outerstrides = NBF_REDUCE_OUTERSTRIDES(bufferdata); char **reduce_outerptrs = NBF_REDUCE_OUTERPTRS(bufferdata); - for (iiter = 0; iiter < niter; ++iiter) { - char *ptr = reduce_outerptrs[iiter] + reduce_outerstrides[iiter]; - ptrs[iiter] = ptr; - reduce_outerptrs[iiter] = ptr; + for (iop = 0; iop < nop; ++iop) { + char *ptr = reduce_outerptrs[iop] + reduce_outerstrides[iop]; + ptrs[iop] = ptr; + reduce_outerptrs[iop] = ptr; } NBF_BUFITEREND(bufferdata) = NIT_ITERINDEX(iter) + NBF_SIZE(bufferdata); return 1; @@ -1828,7 +1828,7 @@ npyiter_buffered_reduce_iternext_iters@tag_niter@(NpyIter *iter) /* Save the previously used data pointers */ axisdata = NIT_AXISDATA(iter); - memcpy(prev_dataptrs, NAD_PTRS(axisdata), NPY_SIZEOF_INTP*niter); + memcpy(prev_dataptrs, NAD_PTRS(axisdata), NPY_SIZEOF_INTP*nop); /* Write back to the arrays */ npyiter_copy_from_buffers(iter); @@ -1857,7 +1857,7 @@ npyiter_buffered_iternext(NpyIter *iter) { npy_uint32 itflags = NIT_ITFLAGS(iter); /*int ndim = NIT_NDIM(iter);*/ - int niter = NIT_NITER(iter); + int nop = NIT_NOP(iter); NpyIter_BufferData *bufferdata = NIT_BUFFERDATA(iter); @@ -1868,14 +1868,14 @@ npyiter_buffered_iternext(NpyIter *iter) if (!(itflags&NPY_ITFLAG_EXLOOP)) { /* Increment within the buffer */ if (++NIT_ITERINDEX(iter) < NBF_BUFITEREND(bufferdata)) { - int iiter; + int iop; npy_intp *strides; char **ptrs; strides = NBF_STRIDES(bufferdata); ptrs = NBF_PTRS(bufferdata); - for (iiter = 0; iiter < niter; ++iiter) { - ptrs[iiter] += strides[iiter]; + for (iop = 0; iop < nop; ++iop) { + ptrs[iop] += strides[iop]; } return 1; } @@ -1927,7 +1927,7 @@ NpyIter_GetIterNext(NpyIter *iter, char **errmsg) { npy_uint32 itflags = NIT_ITFLAGS(iter); int ndim = NIT_NDIM(iter); - int niter = NIT_NITER(iter); + int nop = NIT_NOP(iter); /* * When there is just one iteration and buffering is disabled @@ -1942,7 +1942,7 @@ NpyIter_GetIterNext(NpyIter *iter, char **errmsg) */ if (itflags&NPY_ITFLAG_BUFFER) { if (itflags&NPY_ITFLAG_REDUCE) { - switch (niter) { + switch (nop) { case 1: return &npyiter_buffered_reduce_iternext_iters1; case 2: @@ -1988,30 +1988,30 @@ NpyIter_GetIterNext(NpyIter *iter, char **errmsg) * #tag_ndim = 1, 2# */ case @const_ndim@: - switch (niter) { + switch (nop) { /**begin repeat2 - * #const_niter = 1, 2# - * #tag_niter = 1, 2# + * #const_nop = 1, 2# + * #tag_nop = 1, 2# */ - case @const_niter@: - return &npyiter_iternext_itflags@tag_itflags@_dims@tag_ndim@_iters@tag_niter@; + case @const_nop@: + return &npyiter_iternext_itflags@tag_itflags@_dims@tag_ndim@_iters@tag_nop@; /**end repeat2**/ - /* Not specialized on niter */ + /* Not specialized on nop */ default: return &npyiter_iternext_itflags@tag_itflags@_dims@tag_ndim@_itersANY; } /**end repeat1**/ /* Not specialized on ndim */ default: - switch (niter) { + switch (nop) { /**begin repeat1 - * #const_niter = 1, 2# - * #tag_niter = 1, 2# + * #const_nop = 1, 2# + * #tag_nop = 1, 2# */ - case @const_niter@: - return &npyiter_iternext_itflags@tag_itflags@_dimsANY_iters@tag_niter@; + case @const_nop@: + return &npyiter_iternext_itflags@tag_itflags@_dimsANY_iters@tag_nop@; /**end repeat1**/ - /* Not specialized on niter */ + /* Not specialized on nop */ default: return &npyiter_iternext_itflags@tag_itflags@_dimsANY_itersANY; } @@ -2022,12 +2022,12 @@ NpyIter_GetIterNext(NpyIter *iter, char **errmsg) if (errmsg == NULL) { PyErr_Format(PyExc_ValueError, "GetIterNext internal iterator error - unexpected " - "itflags/ndim/niter combination (%04x/%d/%d)", - (int)itflags, (int)ndim, (int)niter); + "itflags/ndim/nop combination (%04x/%d/%d)", + (int)itflags, (int)ndim, (int)nop); } else { *errmsg = "GetIterNext internal iterator error - unexpected " - "itflags/ndim/niter combination"; + "itflags/ndim/nop combination"; } return NULL; } @@ -2057,7 +2057,7 @@ npyiter_get_multi_index_itflags@tag_itflags@( { const npy_uint32 itflags = @const_itflags@; int idim, ndim = NIT_NDIM(iter); - int niter = NIT_NITER(iter); + int nop = NIT_NOP(iter); npy_intp sizeof_axisdata; NpyIter_AxisData *axisdata; @@ -2066,7 +2066,7 @@ npyiter_get_multi_index_itflags@tag_itflags@( #endif axisdata = NIT_AXISDATA(iter); - sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, niter); + sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, nop); #if ((@const_itflags@)&NPY_ITFLAG_IDENTPERM) out_multi_index += ndim-1; for(idim = 0; idim < ndim; ++idim, --out_multi_index, @@ -2106,7 +2106,7 @@ NpyIter_GetGetMultiIndex(NpyIter *iter, char **errmsg) { npy_uint32 itflags = NIT_ITFLAGS(iter); int ndim = NIT_NDIM(iter); - int niter = NIT_NITER(iter); + int nop = NIT_NOP(iter); /* These flags must be correct */ if ((itflags&(NPY_ITFLAG_HASMULTIINDEX|NPY_ITFLAG_DELAYBUF)) != @@ -2173,12 +2173,12 @@ NpyIter_GetGetMultiIndex(NpyIter *iter, char **errmsg) if (errmsg == NULL) { PyErr_Format(PyExc_ValueError, "GetGetMultiIndex internal iterator error - unexpected " - "itflags/ndim/niter combination (%04x/%d/%d)", - (int)itflags, (int)ndim, (int)niter); + "itflags/ndim/nop combination (%04x/%d/%d)", + (int)itflags, (int)ndim, (int)nop); } else { *errmsg = "GetGetMultiIndex internal iterator error - unexpected " - "itflags/ndim/niter combination"; + "itflags/ndim/nop combination"; } return NULL; @@ -2228,7 +2228,7 @@ NpyIter_RequiresBuffering(NpyIter *iter) { npy_uint32 itflags = NIT_ITFLAGS(iter); /*int ndim = NIT_NDIM(iter);*/ - int iiter, niter = NIT_NITER(iter); + int iop, nop = NIT_NOP(iter); char *op_itflags; @@ -2239,8 +2239,8 @@ NpyIter_RequiresBuffering(NpyIter *iter) op_itflags = NIT_OPITFLAGS(iter); /* If any operand requires a cast, buffering is mandatory */ - for (iiter = 0; iiter < niter; ++iiter) { - if (op_itflags[iiter]&NPY_OP_ITFLAG_CAST) { + for (iop = 0; iop < nop; ++iop) { + if (op_itflags[iop]&NPY_OP_ITFLAG_CAST) { return 1; } } @@ -2272,9 +2272,9 @@ NpyIter_GetNDim(NpyIter *iter) * Gets the number of operands being iterated */ NPY_NO_EXPORT int -NpyIter_GetNIter(NpyIter *iter) +NpyIter_GetNOp(NpyIter *iter) { - return NIT_NITER(iter); + return NIT_NOP(iter); } /*NUMPY_API @@ -2312,7 +2312,7 @@ NpyIter_GetBufferSize(NpyIter *iter) { npy_uint32 itflags = NIT_ITFLAGS(iter); /*int ndim = NIT_NDIM(iter);*/ - int niter = NIT_NITER(iter); + int nop = NIT_NOP(iter); if (itflags&NPY_ITFLAG_BUFFER) { NpyIter_BufferData *bufferdata = NIT_BUFFERDATA(iter); @@ -2354,14 +2354,14 @@ NpyIter_GetShape(NpyIter *iter, npy_intp *outshape) { npy_uint32 itflags = NIT_ITFLAGS(iter); int ndim = NIT_NDIM(iter); - int niter = NIT_NITER(iter); + int nop = NIT_NOP(iter); int idim, sizeof_axisdata; NpyIter_AxisData *axisdata; char *perm; axisdata = NIT_AXISDATA(iter); - sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, niter); + sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, nop); if (itflags&NPY_ITFLAG_HASMULTIINDEX) { perm = NIT_PERM(iter); @@ -2418,7 +2418,7 @@ NpyIter_CreateCompatibleStrides(NpyIter *iter, { npy_uint32 itflags = NIT_ITFLAGS(iter); int idim, ndim = NIT_NDIM(iter); - int niter = NIT_NITER(iter); + int nop = NIT_NOP(iter); npy_intp sizeof_axisdata; NpyIter_AxisData *axisdata; @@ -2432,7 +2432,7 @@ NpyIter_CreateCompatibleStrides(NpyIter *iter, } axisdata = NIT_AXISDATA(iter); - sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, niter); + sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, nop); perm = NIT_PERM(iter); for(idim = 0; idim < ndim; ++idim) { @@ -2465,7 +2465,7 @@ NpyIter_GetDataPtrArray(NpyIter *iter) { npy_uint32 itflags = NIT_ITFLAGS(iter); /*int ndim = NIT_NDIM(iter);*/ - int niter = NIT_NITER(iter); + int nop = NIT_NOP(iter); if (itflags&NPY_ITFLAG_BUFFER) { NpyIter_BufferData *bufferdata = NIT_BUFFERDATA(iter); @@ -2494,7 +2494,7 @@ NpyIter_GetInitialDataPtrArray(NpyIter *iter) { /*npy_uint32 itflags = NIT_ITFLAGS(iter);*/ /*int ndim = NIT_NDIM(iter);*/ - int niter = NIT_NITER(iter); + int nop = NIT_NOP(iter); return NIT_RESETDATAPTR(iter); } @@ -2507,7 +2507,7 @@ NpyIter_GetDescrArray(NpyIter *iter) { /*npy_uint32 itflags = NIT_ITFLAGS(iter);*/ /*int ndim = NIT_NDIM(iter);*/ - /*int niter = NIT_NITER(iter);*/ + /*int nop = NIT_NOP(iter);*/ return NIT_DTYPES(iter); } @@ -2520,7 +2520,7 @@ NpyIter_GetOperandArray(NpyIter *iter) { /*npy_uint32 itflags = NIT_ITFLAGS(iter);*/ /*int ndim = NIT_NDIM(iter);*/ - int niter = NIT_NITER(iter); + int nop = NIT_NOP(iter); return NIT_OPERANDS(iter); } @@ -2533,7 +2533,7 @@ NpyIter_GetIterView(NpyIter *iter, npy_intp i) { npy_uint32 itflags = NIT_ITFLAGS(iter); int idim, ndim = NIT_NDIM(iter); - int niter = NIT_NITER(iter); + int nop = NIT_NOP(iter); npy_intp shape[NPY_MAXDIMS], strides[NPY_MAXDIMS]; PyArrayObject *obj, *view; @@ -2543,7 +2543,7 @@ NpyIter_GetIterView(NpyIter *iter, npy_intp i) npy_intp sizeof_axisdata; int writeable; - if (i < 0 || i >= niter) { + if (i < 0 || i >= nop) { PyErr_SetString(PyExc_IndexError, "index provided for an iterator view was out of bounds"); return NULL; @@ -2561,7 +2561,7 @@ NpyIter_GetIterView(NpyIter *iter, npy_intp i) writeable = NIT_OPITFLAGS(iter)[i]&NPY_OP_ITFLAG_WRITE; dataptr = NIT_RESETDATAPTR(iter)[i]; axisdata = NIT_AXISDATA(iter); - sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, niter); + sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, nop); /* Retrieve the shape and strides from the axisdata */ for (idim = 0; idim < ndim; ++idim, NIT_ADVANCE_AXISDATA(axisdata, 1)) { @@ -2594,13 +2594,13 @@ NpyIter_GetIndexPtr(NpyIter *iter) { npy_uint32 itflags = NIT_ITFLAGS(iter); /*int ndim = NIT_NDIM(iter);*/ - int niter = NIT_NITER(iter); + int nop = NIT_NOP(iter); NpyIter_AxisData *axisdata = NIT_AXISDATA(iter); if (itflags&NPY_ITFLAG_HASINDEX) { /* The index is just after the data pointers */ - return (npy_intp*)NAD_PTRS(axisdata) + niter; + return (npy_intp*)NAD_PTRS(axisdata) + nop; } else { return NULL; @@ -2615,12 +2615,12 @@ NpyIter_GetReadFlags(NpyIter *iter, char *outreadflags) { /*npy_uint32 itflags = NIT_ITFLAGS(iter);*/ /*int ndim = NIT_NDIM(iter);*/ - int iiter, niter = NIT_NITER(iter); + int iop, nop = NIT_NOP(iter); char *op_itflags = NIT_OPITFLAGS(iter); - for (iiter = 0; iiter < niter; ++iiter) { - outreadflags[iiter] = (op_itflags[iiter]&NPY_OP_ITFLAG_READ) != 0; + for (iop = 0; iop < nop; ++iop) { + outreadflags[iop] = (op_itflags[iop]&NPY_OP_ITFLAG_READ) != 0; } } @@ -2632,12 +2632,12 @@ NpyIter_GetWriteFlags(NpyIter *iter, char *outwriteflags) { /*npy_uint32 itflags = NIT_ITFLAGS(iter);*/ /*int ndim = NIT_NDIM(iter);*/ - int iiter, niter = NIT_NITER(iter); + int iop, nop = NIT_NOP(iter); char *op_itflags = NIT_OPITFLAGS(iter); - for (iiter = 0; iiter < niter; ++iiter) { - outwriteflags[iiter] = (op_itflags[iiter]&NPY_OP_ITFLAG_WRITE) != 0; + for (iop = 0; iop < nop; ++iop) { + outwriteflags[iop] = (op_itflags[iop]&NPY_OP_ITFLAG_WRITE) != 0; } } @@ -2652,7 +2652,7 @@ NpyIter_GetInnerStrideArray(NpyIter *iter) { npy_uint32 itflags = NIT_ITFLAGS(iter); /*int ndim = NIT_NDIM(iter);*/ - int niter = NIT_NITER(iter); + int nop = NIT_NOP(iter); if (itflags&NPY_ITFLAG_BUFFER) { NpyIter_BufferData *data = NIT_BUFFERDATA(iter); @@ -2677,11 +2677,11 @@ NpyIter_GetAxisStrideArray(NpyIter *iter, int axis) { npy_uint32 itflags = NIT_ITFLAGS(iter); int idim, ndim = NIT_NDIM(iter); - int niter = NIT_NITER(iter); + int nop = NIT_NOP(iter); char *perm = NIT_PERM(iter); NpyIter_AxisData *axisdata = NIT_AXISDATA(iter); - npy_intp sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, niter); + npy_intp sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, nop); if (axis < 0 || axis >= ndim) { PyErr_SetString(PyExc_ValueError, @@ -2723,10 +2723,10 @@ NpyIter_GetInnerFixedStrideArray(NpyIter *iter, npy_intp *out_strides) { npy_uint32 itflags = NIT_ITFLAGS(iter); int ndim = NIT_NDIM(iter); - int iiter, niter = NIT_NITER(iter); + int iop, nop = NIT_NOP(iter); NpyIter_AxisData *axisdata0 = NIT_AXISDATA(iter); - npy_intp sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, niter); + npy_intp sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, nop); if (itflags&NPY_ITFLAG_BUFFER) { NpyIter_BufferData *data = NIT_BUFFERDATA(iter); @@ -2735,21 +2735,21 @@ NpyIter_GetInnerFixedStrideArray(NpyIter *iter, npy_intp *out_strides) *ad_strides = NAD_STRIDES(axisdata0); PyArray_Descr **dtypes = NIT_DTYPES(iter); - for (iiter = 0; iiter < niter; ++iiter) { - stride = strides[iiter]; + for (iop = 0; iop < nop; ++iop) { + stride = strides[iop]; /* * Operands which are always/never buffered have fixed strides, * and everything has fixed strides when ndim is 0 or 1 */ - if (ndim <= 1 || (op_itflags[iiter]& + if (ndim <= 1 || (op_itflags[iop]& (NPY_OP_ITFLAG_CAST|NPY_OP_ITFLAG_BUFNEVER))) { - out_strides[iiter] = stride; + out_strides[iop] = stride; } /* If it's a reduction, 0-stride inner loop may have fixed stride */ else if (stride == 0 && (itflags&NPY_ITFLAG_REDUCE)) { /* If it's a reduction operand, definitely fixed stride */ - if (op_itflags[iiter]&NPY_OP_ITFLAG_REDUCE) { - out_strides[iiter] = stride; + if (op_itflags[iop]&NPY_OP_ITFLAG_REDUCE) { + out_strides[iop] = stride; } /* * Otherwise it's a fixed stride if the stride is 0 @@ -2760,17 +2760,17 @@ NpyIter_GetInnerFixedStrideArray(NpyIter *iter, npy_intp *out_strides) int idim, reduce_outerdim = NBF_REDUCE_OUTERDIM(data); for (idim = 0; idim < reduce_outerdim; ++idim) { - if (NAD_STRIDES(axisdata)[iiter] != 0) { + if (NAD_STRIDES(axisdata)[iop] != 0) { break; } NIT_ADVANCE_AXISDATA(axisdata, 1); } /* If all the strides were 0, the stride won't change */ if (idim == reduce_outerdim) { - out_strides[iiter] = stride; + out_strides[iop] = stride; } else { - out_strides[iiter] = NPY_MAX_INTP; + out_strides[iop] = NPY_MAX_INTP; } } } @@ -2778,21 +2778,21 @@ NpyIter_GetInnerFixedStrideArray(NpyIter *iter, npy_intp *out_strides) * Inner loop contiguous array means its stride won't change when * switching between buffering and not buffering */ - else if (ad_strides[iiter] == dtypes[iiter]->elsize) { - out_strides[iiter] = ad_strides[iiter]; + else if (ad_strides[iop] == dtypes[iop]->elsize) { + out_strides[iop] = ad_strides[iop]; } /* * Otherwise the strides can change if the operand is sometimes * buffered, sometimes not. */ else { - out_strides[iiter] = NPY_MAX_INTP; + out_strides[iop] = NPY_MAX_INTP; } } } else { /* If there's no buffering, the strides are always fixed */ - memcpy(out_strides, NAD_STRIDES(axisdata0), niter*NPY_SIZEOF_INTP); + memcpy(out_strides, NAD_STRIDES(axisdata0), nop*NPY_SIZEOF_INTP); } } @@ -2807,7 +2807,7 @@ NpyIter_GetInnerLoopSizePtr(NpyIter *iter) { npy_uint32 itflags = NIT_ITFLAGS(iter); /*int ndim = NIT_NDIM(iter);*/ - int niter = NIT_NITER(iter); + int nop = NIT_NOP(iter); if (itflags&NPY_ITFLAG_BUFFER) { NpyIter_BufferData *data = NIT_BUFFERDATA(iter); @@ -2890,7 +2890,7 @@ npyiter_check_global_flags(npy_uint32 flags, npy_uint32* itflags) } static int -npyiter_calculate_ndim(int niter, PyArrayObject **op_in, +npyiter_calculate_ndim(int nop, PyArrayObject **op_in, int oa_ndim) { /* If 'op_axes' is being used, force 'ndim' */ @@ -2899,11 +2899,11 @@ npyiter_calculate_ndim(int niter, PyArrayObject **op_in, } /* Otherwise it's the maximum 'ndim' from the operands */ else { - int ndim = 0, iiter; + int ndim = 0, iop; - for (iiter = 0; iiter < niter; ++iiter) { - if (op_in[iiter] != NULL) { - int ondim = PyArray_NDIM(op_in[iiter]); + for (iop = 0; iop < nop; ++iop) { + if (op_in[iop] != NULL) { + int ondim = PyArray_NDIM(op_in[iop]); if (ondim > ndim) { ndim = ondim; } @@ -2916,11 +2916,11 @@ npyiter_calculate_ndim(int niter, PyArrayObject **op_in, } static int -npyiter_check_op_axes(int niter, int oa_ndim, int **op_axes, +npyiter_check_op_axes(int nop, int oa_ndim, int **op_axes, npy_intp *itershape) { char axes_dupcheck[NPY_MAXDIMS]; - int iiter, idim; + int iop, idim; if (oa_ndim == 0 && (op_axes != NULL || itershape != NULL)) { PyErr_Format(PyExc_ValueError, @@ -2944,8 +2944,8 @@ npyiter_check_op_axes(int niter, int oa_ndim, int **op_axes, } /* Check that there are no duplicates in op_axes */ - for (iiter = 0; iiter < niter; ++iiter) { - int *axes = op_axes[iiter]; + for (iop = 0; iop < nop; ++iop) { + int *axes = op_axes[iop]; if (axes != NULL) { memset(axes_dupcheck, 0, NPY_MAXDIMS); for (idim = 0; idim < oa_ndim; ++idim) { @@ -2956,14 +2956,14 @@ npyiter_check_op_axes(int niter, int oa_ndim, int **op_axes, "The 'op_axes' provided to the iterator " "constructor for operand %d " "contained invalid " - "values %d", (int)iiter, (int)i); + "values %d", (int)iop, (int)i); return 0; } else if(axes_dupcheck[i] == 1) { PyErr_Format(PyExc_ValueError, "The 'op_axes' provided to the iterator " "constructor for operand %d " "contained duplicate " - "value %d", (int)iiter, (int)i); + "value %d", (int)iop, (int)i); return 0; } else { @@ -3225,7 +3225,7 @@ npyiter_prepare_one_operand(PyArrayObject **op, * can replace the arrays if copying is necessary. */ static int -npyiter_prepare_operands(int niter, PyArrayObject **op_in, +npyiter_prepare_operands(int nop, PyArrayObject **op_in, PyArrayObject **op, char **op_dataptr, PyArray_Descr **op_request_dtypes, @@ -3233,16 +3233,16 @@ npyiter_prepare_operands(int niter, PyArrayObject **op_in, npy_uint32 flags, npy_uint32 *op_flags, char *op_itflags) { - int iiter, i; + int iop, i; - for (iiter = 0; iiter < niter; ++iiter) { - op[iiter] = op_in[iiter]; - Py_XINCREF(op[iiter]); - op_dtype[iiter] = NULL; + for (iop = 0; iop < nop; ++iop) { + op[iop] = op_in[iop]; + Py_XINCREF(op[iop]); + op_dtype[iop] = NULL; /* Check the readonly/writeonly flags, and fill in op_itflags */ - if (!npyiter_check_per_op_flags(op_flags[iiter], &op_itflags[iiter])) { - for (i = 0; i <= iiter; ++i) { + if (!npyiter_check_per_op_flags(op_flags[iop], &op_itflags[iop])) { + for (i = 0; i <= iop; ++i) { Py_XDECREF(op[i]); Py_XDECREF(op_dtype[i]); } @@ -3250,16 +3250,16 @@ npyiter_prepare_operands(int niter, PyArrayObject **op_in, } /* - * Prepare the operand. This produces an op_dtype[iiter] reference + * Prepare the operand. This produces an op_dtype[iop] reference * on success. */ - if (!npyiter_prepare_one_operand(&op[iiter], - &op_dataptr[iiter], - op_request_dtypes ? op_request_dtypes[iiter] : NULL, - &op_dtype[iiter], + if (!npyiter_prepare_one_operand(&op[iop], + &op_dataptr[iop], + op_request_dtypes ? op_request_dtypes[iop] : NULL, + &op_dtype[iop], flags, - op_flags[iiter], &op_itflags[iiter])) { - for (i = 0; i <= iiter; ++i) { + op_flags[iop], &op_itflags[iop])) { + for (i = 0; i <= iop; ++i) { Py_XDECREF(op[i]); Py_XDECREF(op_dtype[i]); } @@ -3271,14 +3271,14 @@ npyiter_prepare_operands(int niter, PyArrayObject **op_in, /* If all the operands were NULL, it's an error */ if (op[0] == NULL) { int all_null = 1; - for (iiter = 1; iiter < niter; ++iiter) { - if (op[iiter] != NULL) { + for (iop = 1; iop < nop; ++iop) { + if (op[iop] != NULL) { all_null = 0; break; } } if (all_null) { - for (i = 0; i < niter; ++i) { + for (i = 0; i < nop; ++i) { Py_XDECREF(op[i]); Py_XDECREF(op_dtype[i]); } @@ -3311,52 +3311,52 @@ npyiter_casting_to_string(NPY_CASTING casting) } static int -npyiter_check_casting(int niter, PyArrayObject **op, +npyiter_check_casting(int nop, PyArrayObject **op, PyArray_Descr **op_dtype, NPY_CASTING casting, char *op_itflags) { - int iiter; + int iop; - for(iiter = 0; iiter < niter; ++iiter) { + for(iop = 0; iop < nop; ++iop) { NPY_IT_DBG_PRINT1("Iterator: Checking casting for operand %d\n", - (int)iiter); + (int)iop); #if NPY_IT_DBG_TRACING printf("op: "); - if (op[iiter] != NULL) { - PyObject_Print((PyObject *)PyArray_DESCR(op[iiter]), stdout, 0); + if (op[iop] != NULL) { + PyObject_Print((PyObject *)PyArray_DESCR(op[iop]), stdout, 0); } else { printf("<null>"); } printf(", iter: "); - PyObject_Print((PyObject *)op_dtype[iiter], stdout, 0); + PyObject_Print((PyObject *)op_dtype[iop], stdout, 0); printf("\n"); #endif /* If the types aren't equivalent, a cast is necessary */ - if (op[iiter] != NULL && !PyArray_EquivTypes(PyArray_DESCR(op[iiter]), - op_dtype[iiter])) { + if (op[iop] != NULL && !PyArray_EquivTypes(PyArray_DESCR(op[iop]), + op_dtype[iop])) { /* Check read (op -> temp) casting */ - if ((op_itflags[iiter]&NPY_OP_ITFLAG_READ) && - !PyArray_CanCastArrayTo(op[iiter], - op_dtype[iiter], + if ((op_itflags[iop]&NPY_OP_ITFLAG_READ) && + !PyArray_CanCastArrayTo(op[iop], + op_dtype[iop], casting)) { PyErr_Format(PyExc_TypeError, "Iterator operand %d dtype could not be cast " "to the requested dtype, according to " - "the casting rule given, %s", (int)iiter, + "the casting rule given, %s", (int)iop, npyiter_casting_to_string(casting)); return 0; } /* Check write (temp -> op) casting */ - if ((op_itflags[iiter]&NPY_OP_ITFLAG_WRITE) && - !PyArray_CanCastTypeTo(op_dtype[iiter], - PyArray_DESCR(op[iiter]), + if ((op_itflags[iop]&NPY_OP_ITFLAG_WRITE) && + !PyArray_CanCastTypeTo(op_dtype[iop], + PyArray_DESCR(op[iop]), casting)) { PyErr_Format(PyExc_TypeError, "Iterator requested dtype could not be cast " "to the operand %d dtype, according to " - "the casting rule given, %s", (int)iiter, + "the casting rule given, %s", (int)iop, npyiter_casting_to_string(casting)); return 0; } @@ -3364,7 +3364,7 @@ npyiter_check_casting(int niter, PyArrayObject **op, NPY_IT_DBG_PRINT("Iterator: Setting NPY_OP_ITFLAG_CAST " "because the types aren't equivalent\n"); /* Indicate that this operand needs casting */ - op_itflags[iiter] |= NPY_OP_ITFLAG_CAST; + op_itflags[iop] |= NPY_OP_ITFLAG_CAST; } } @@ -3421,7 +3421,7 @@ npyiter_shape_string(npy_intp n, npy_intp *vals, char *ending) } /* - * Fills in the AXISDATA for the 'niter' operands, broadcasting + * Fills in the AXISDATA for the 'nop' operands, broadcasting * the dimensionas as necessary. Also fills * in the ITERSIZE data member. * @@ -3439,7 +3439,7 @@ npyiter_fill_axisdata(NpyIter *iter, npy_uint32 flags, char *op_itflags, { npy_uint32 itflags = NIT_ITFLAGS(iter); int idim, ndim = NIT_NDIM(iter); - int iiter, niter = NIT_NITER(iter); + int iop, nop = NIT_NOP(iter); int ondim; NpyIter_AxisData *axisdata; @@ -3462,16 +3462,16 @@ npyiter_fill_axisdata(NpyIter *iter, npy_uint32 flags, char *op_itflags, } } } - for (iiter = 0; iiter < niter; ++iiter) { - op_cur = op[iiter]; + for (iop = 0; iop < nop; ++iop) { + op_cur = op[iop]; if (op_cur != NULL) { npy_intp *shape = PyArray_DIMS(op_cur); ondim = PyArray_NDIM(op_cur); - if (op_axes == NULL || op_axes[iiter] == NULL) { + if (op_axes == NULL || op_axes[iop] == NULL) { /* * Possible if op_axes are being used, but - * op_axes[iiter] is NULL + * op_axes[iop] is NULL */ if (ondim > ndim) { PyErr_SetString(PyExc_ValueError, @@ -3491,7 +3491,7 @@ npyiter_fill_axisdata(NpyIter *iter, npy_uint32 flags, char *op_itflags, } } else { - int *axes = op_axes[iiter]; + int *axes = op_axes[iop]; for (idim = 0; idim < ndim; ++idim) { int i = axes[idim]; if (i >= 0) { @@ -3510,8 +3510,8 @@ npyiter_fill_axisdata(NpyIter *iter, npy_uint32 flags, char *op_itflags, "Iterator input op_axes[%d][%d] (==%d) " "is not a valid axis of op[%d], which " "has %d dimensions ", - (int)iiter, (int)(ndim-idim-1), (int)i, - (int)iiter, (int)ondim); + (int)iop, (int)(ndim-idim-1), (int)i, + (int)iop, (int)ondim); return 0; } } @@ -3532,7 +3532,7 @@ npyiter_fill_axisdata(NpyIter *iter, npy_uint32 flags, char *op_itflags, } axisdata = NIT_AXISDATA(iter); - sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, niter); + sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, nop); /* Now process the operands, filling in the axisdata */ for (idim = 0; idim < ndim; ++idim) { @@ -3541,39 +3541,39 @@ npyiter_fill_axisdata(NpyIter *iter, npy_uint32 flags, char *op_itflags, NAD_SHAPE(axisdata) = bshape; NAD_INDEX(axisdata) = 0; - memcpy(NAD_PTRS(axisdata), op_dataptr, NPY_SIZEOF_INTP*niter); + memcpy(NAD_PTRS(axisdata), op_dataptr, NPY_SIZEOF_INTP*nop); - for (iiter = 0; iiter < niter; ++iiter) { - op_cur = op[iiter]; + for (iop = 0; iop < nop; ++iop) { + op_cur = op[iop]; - if (op_axes == NULL || op_axes[iiter] == NULL) { + if (op_axes == NULL || op_axes[iop] == NULL) { if (op_cur == NULL) { - strides[iiter] = 0; + strides[iop] = 0; } else { ondim = PyArray_NDIM(op_cur); if (bshape == 1) { - strides[iiter] = 0; + strides[iop] = 0; if (idim >= ondim && !output_scalars && - (op_flags[iiter]&NPY_ITER_NO_BROADCAST)) { + (op_flags[iop]&NPY_ITER_NO_BROADCAST)) { goto operand_different_than_broadcast; } } else if (idim >= ondim || PyArray_DIM(op_cur, ondim-idim-1) == 1) { - strides[iiter] = 0; - if (op_flags[iiter]&NPY_ITER_NO_BROADCAST) { + strides[iop] = 0; + if (op_flags[iop]&NPY_ITER_NO_BROADCAST) { goto operand_different_than_broadcast; } /* If it's writeable, this means a reduction */ - if (op_itflags[iiter]&NPY_OP_ITFLAG_WRITE) { + if (op_itflags[iop]&NPY_OP_ITFLAG_WRITE) { if (!(flags&NPY_ITER_REDUCE_OK)) { PyErr_SetString(PyExc_ValueError, "output operand requires a reduction, but " "reduction is not enabled"); return 0; } - if (!(op_itflags[iiter]&NPY_OP_ITFLAG_READ)) { + if (!(op_itflags[iop]&NPY_OP_ITFLAG_READ)) { PyErr_SetString(PyExc_ValueError, "output operand requires a reduction, but " "is flagged as write-only, not " @@ -3581,35 +3581,35 @@ npyiter_fill_axisdata(NpyIter *iter, npy_uint32 flags, char *op_itflags, return 0; } NIT_ITFLAGS(iter) |= NPY_ITFLAG_REDUCE; - op_itflags[iiter] |= NPY_OP_ITFLAG_REDUCE; + op_itflags[iop] |= NPY_OP_ITFLAG_REDUCE; } } else { - strides[iiter] = PyArray_STRIDE(op_cur, ondim-idim-1); + strides[iop] = PyArray_STRIDE(op_cur, ondim-idim-1); } } } else { - int *axes = op_axes[iiter]; + int *axes = op_axes[iop]; int i = axes[ndim-idim-1]; if (i >= 0) { if (bshape == 1 || op_cur == NULL) { - strides[iiter] = 0; + strides[iop] = 0; } else if (PyArray_DIM(op_cur, i) == 1) { - strides[iiter] = 0; - if (op_flags[iiter]&NPY_ITER_NO_BROADCAST) { + strides[iop] = 0; + if (op_flags[iop]&NPY_ITER_NO_BROADCAST) { goto operand_different_than_broadcast; } /* If it's writeable, this means a reduction */ - if (op_itflags[iiter]&NPY_OP_ITFLAG_WRITE) { + if (op_itflags[iop]&NPY_OP_ITFLAG_WRITE) { if (!(flags&NPY_ITER_REDUCE_OK)) { PyErr_SetString(PyExc_ValueError, "output operand requires a reduction, but " "reduction is not enabled"); return 0; } - if (!(op_itflags[iiter]&NPY_OP_ITFLAG_READ)) { + if (!(op_itflags[iop]&NPY_OP_ITFLAG_READ)) { PyErr_SetString(PyExc_ValueError, "output operand requires a reduction, but " "is flagged as write-only, not " @@ -3617,27 +3617,27 @@ npyiter_fill_axisdata(NpyIter *iter, npy_uint32 flags, char *op_itflags, return 0; } NIT_ITFLAGS(iter) |= NPY_ITFLAG_REDUCE; - op_itflags[iiter] |= NPY_OP_ITFLAG_REDUCE; + op_itflags[iop] |= NPY_OP_ITFLAG_REDUCE; } } else { - strides[iiter] = PyArray_STRIDE(op_cur, i); + strides[iop] = PyArray_STRIDE(op_cur, i); } } else if (bshape == 1) { - strides[iiter] = 0; + strides[iop] = 0; } else { - strides[iiter] = 0; + strides[iop] = 0; /* If it's writeable, this means a reduction */ - if (op_itflags[iiter]&NPY_OP_ITFLAG_WRITE) { + if (op_itflags[iop]&NPY_OP_ITFLAG_WRITE) { if (!(flags&NPY_ITER_REDUCE_OK)) { PyErr_SetString(PyExc_ValueError, "output operand requires a reduction, but " "reduction is not enabled"); return 0; } - if (!(op_itflags[iiter]&NPY_OP_ITFLAG_READ)) { + if (!(op_itflags[iop]&NPY_OP_ITFLAG_READ)) { PyErr_SetString(PyExc_ValueError, "output operand requires a reduction, but " "is flagged as write-only, not " @@ -3645,7 +3645,7 @@ npyiter_fill_axisdata(NpyIter *iter, npy_uint32 flags, char *op_itflags, return 0; } NIT_ITFLAGS(iter) |= NPY_ITFLAG_REDUCE; - op_itflags[iiter] |= NPY_OP_ITFLAG_REDUCE; + op_itflags[iop] |= NPY_OP_ITFLAG_REDUCE; } } } @@ -3676,10 +3676,10 @@ broadcast_error: { if (errmsg == NULL) { return 0; } - for (iiter = 0; iiter < niter; ++iiter) { - if (op[iiter] != NULL) { - tmp = npyiter_shape_string(PyArray_NDIM(op[iiter]), - PyArray_DIMS(op[iiter]), + for (iop = 0; iop < nop; ++iop) { + if (op[iop] != NULL) { + tmp = npyiter_shape_string(PyArray_NDIM(op[iop]), + PyArray_DIMS(op[iop]), " "); if (tmp == NULL) { Py_DECREF(errmsg); @@ -3719,13 +3719,13 @@ broadcast_error: { errmsg = PyUString_FromString("operands could not be broadcast " "together with remapped shapes " "[original->remapped]: "); - for (iiter = 0; iiter < niter; ++iiter) { - if (op[iiter] != NULL) { - int *axes = op_axes[iiter]; + for (iop = 0; iop < nop; ++iop) { + if (op[iop] != NULL) { + int *axes = op_axes[iop]; tmpstr = (axes == NULL) ? " " : "->"; - tmp = npyiter_shape_string(PyArray_NDIM(op[iiter]), - PyArray_DIMS(op[iiter]), + tmp = npyiter_shape_string(PyArray_NDIM(op[iop]), + PyArray_DIMS(op[iop]), tmpstr); if (tmp == NULL) { return 0; @@ -3739,8 +3739,8 @@ broadcast_error: { for (idim = 0; idim < ndim; ++idim) { npy_intp i = axes[idim]; - if (i >= 0 && i < PyArray_NDIM(op[iiter])) { - remdims[idim] = PyArray_DIM(op[iiter], i); + if (i >= 0 && i < PyArray_NDIM(op[iop])) { + remdims[idim] = PyArray_DIM(op[iop], i); } else { remdims[idim] = -1; @@ -3790,7 +3790,7 @@ operand_different_than_broadcast: { PyObject *errmsg, *tmp; /* Start of error message */ - if (op_flags[iiter]&NPY_ITER_READONLY) { + if (op_flags[iop]&NPY_ITER_READONLY) { errmsg = PyUString_FromString("non-broadcastable operand " "with shape "); } @@ -3803,8 +3803,8 @@ operand_different_than_broadcast: { } /* Operand shape */ - tmp = npyiter_shape_string(PyArray_NDIM(op[iiter]), - PyArray_DIMS(op[iiter]), ""); + tmp = npyiter_shape_string(PyArray_NDIM(op[iop]), + PyArray_DIMS(op[iop]), ""); if (tmp == NULL) { return 0; } @@ -3813,14 +3813,14 @@ operand_different_than_broadcast: { return 0; } /* Remapped operand shape */ - if (op_axes != NULL && op_axes[iiter] != NULL) { - int *axes = op_axes[iiter]; + if (op_axes != NULL && op_axes[iop] != NULL) { + int *axes = op_axes[iop]; for (idim = 0; idim < ndim; ++idim) { npy_intp i = axes[ndim-idim-1]; - if (i >= 0 && i < PyArray_NDIM(op[iiter])) { - remdims[idim] = PyArray_DIM(op[iiter], i); + if (i >= 0 && i < PyArray_NDIM(op[iop])) { + remdims[idim] = PyArray_DIM(op[iop], i); } else { remdims[idim] = -1; @@ -3880,7 +3880,7 @@ operand_different_than_broadcast: { } /* - * Replaces the AXISDATA for the iiter'th operand, broadcasting + * Replaces the AXISDATA for the iop'th operand, broadcasting * the dimensions as necessary. Assumes the replacement array is * exactly the same shape as the original array used when * npy_fill_axisdata was called. @@ -3889,14 +3889,14 @@ operand_different_than_broadcast: { * array. */ static void -npyiter_replace_axisdata(NpyIter *iter, int iiter, +npyiter_replace_axisdata(NpyIter *iter, int iop, PyArrayObject *op, int op_ndim, char *op_dataptr, int *op_axes) { npy_uint32 itflags = NIT_ITFLAGS(iter); int idim, ndim = NIT_NDIM(iter); - int niter = NIT_NITER(iter); + int nop = NIT_NOP(iter); NpyIter_AxisData *axisdata0, *axisdata; npy_intp sizeof_axisdata; @@ -3905,7 +3905,7 @@ npyiter_replace_axisdata(NpyIter *iter, int iiter, perm = NIT_PERM(iter); axisdata0 = NIT_AXISDATA(iter); - sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, niter); + sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, nop); /* * Replace just the strides which were non-zero, and compute @@ -3934,11 +3934,11 @@ npyiter_replace_axisdata(NpyIter *iter, int iiter, npy_intp stride = PyArray_STRIDE(op, i); if (p < 0) { /* If the perm entry is negative, flip the axis */ - NAD_STRIDES(axisdata)[iiter] = -stride; + NAD_STRIDES(axisdata)[iop] = -stride; baseoffset += stride*(shape-1); } else { - NAD_STRIDES(axisdata)[iiter] = stride; + NAD_STRIDES(axisdata)[iop] = stride; } } } @@ -3965,11 +3965,11 @@ npyiter_replace_axisdata(NpyIter *iter, int iiter, npy_intp stride = PyArray_STRIDE(op, i); if (p < 0) { /* If the perm entry is negative, flip the axis */ - NAD_STRIDES(axisdata)[iiter] = -stride; + NAD_STRIDES(axisdata)[iop] = -stride; baseoffset += stride*(shape-1); } else { - NAD_STRIDES(axisdata)[iiter] = stride; + NAD_STRIDES(axisdata)[iop] = stride; } } } @@ -3979,11 +3979,11 @@ npyiter_replace_axisdata(NpyIter *iter, int iiter, op_dataptr += baseoffset; /* Now the base data pointer is calculated, set it everywhere it's needed */ - NIT_RESETDATAPTR(iter)[iiter] = op_dataptr; - NIT_BASEOFFSETS(iter)[iiter] = baseoffset; + NIT_RESETDATAPTR(iter)[iop] = op_dataptr; + NIT_BASEOFFSETS(iter)[iop] = baseoffset; axisdata = axisdata0; for (idim = 0; idim < ndim; ++idim, NIT_ADVANCE_AXISDATA(axisdata, 1)) { - NAD_PTRS(axisdata)[iiter] = op_dataptr; + NAD_PTRS(axisdata)[iop] = op_dataptr; } } @@ -3999,7 +3999,7 @@ npyiter_compute_index_strides(NpyIter *iter, npy_uint32 flags) { npy_uint32 itflags = NIT_ITFLAGS(iter); int idim, ndim = NIT_NDIM(iter); - int niter = NIT_NITER(iter); + int nop = NIT_NOP(iter); npy_intp indexstride; NpyIter_AxisData *axisdata; @@ -4013,42 +4013,42 @@ npyiter_compute_index_strides(NpyIter *iter, npy_uint32 flags) if (NIT_ITERSIZE(iter) == 1) { if (itflags&NPY_ITFLAG_HASINDEX) { axisdata = NIT_AXISDATA(iter); - NAD_PTRS(axisdata)[niter] = 0; + NAD_PTRS(axisdata)[nop] = 0; } return; } if (flags&NPY_ITER_C_INDEX) { - sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, niter); + sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, nop); axisdata = NIT_AXISDATA(iter); indexstride = 1; for(idim = 0; idim < ndim; ++idim, NIT_ADVANCE_AXISDATA(axisdata, 1)) { npy_intp shape = NAD_SHAPE(axisdata); if (shape == 1) { - NAD_STRIDES(axisdata)[niter] = 0; + NAD_STRIDES(axisdata)[nop] = 0; } else { - NAD_STRIDES(axisdata)[niter] = indexstride; + NAD_STRIDES(axisdata)[nop] = indexstride; } - NAD_PTRS(axisdata)[niter] = 0; + NAD_PTRS(axisdata)[nop] = 0; indexstride *= shape; } } else if (flags&NPY_ITER_F_INDEX) { - sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, niter); + sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, nop); axisdata = NIT_INDEX_AXISDATA(NIT_AXISDATA(iter), ndim-1); indexstride = 1; for(idim = 0; idim < ndim; ++idim, NIT_ADVANCE_AXISDATA(axisdata, -1)) { npy_intp shape = NAD_SHAPE(axisdata); if (shape == 1) { - NAD_STRIDES(axisdata)[niter] = 0; + NAD_STRIDES(axisdata)[nop] = 0; } else { - NAD_STRIDES(axisdata)[niter] = indexstride; + NAD_STRIDES(axisdata)[nop] = indexstride; } - NAD_PTRS(axisdata)[niter] = 0; + NAD_PTRS(axisdata)[nop] = 0; indexstride *= shape; } } @@ -4064,7 +4064,7 @@ npyiter_apply_forced_iteration_order(NpyIter *iter, NPY_ORDER order) { /*npy_uint32 itflags = NIT_ITFLAGS(iter);*/ int ndim = NIT_NDIM(iter); - int iiter, niter = NIT_NITER(iter); + int iop, nop = NIT_NOP(iter); switch (order) { case NPY_CORDER: @@ -4085,7 +4085,7 @@ npyiter_apply_forced_iteration_order(NpyIter *iter, NPY_ORDER order) int forder = 1; /* Check that all the array inputs are fortran order */ - for (iiter = 0; iiter < niter; ++iiter, ++op) { + for (iop = 0; iop < nop; ++iop, ++op) { if (*op && !PyArray_CHKFLAGS(*op, NPY_F_CONTIGUOUS)) { forder = 0; break; @@ -4115,12 +4115,12 @@ npyiter_flip_negative_strides(NpyIter *iter) { npy_uint32 itflags = NIT_ITFLAGS(iter); int idim, ndim = NIT_NDIM(iter); - int iiter, niter = NIT_NITER(iter); + int iop, nop = NIT_NOP(iter); npy_intp istrides, nstrides = NAD_NSTRIDES(); NpyIter_AxisData *axisdata, *axisdata0; npy_intp *baseoffsets; - npy_intp sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, niter); + npy_intp sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, nop); int any_flipped = 0; axisdata0 = axisdata = NIT_AXISDATA(iter); @@ -4133,11 +4133,11 @@ npyiter_flip_negative_strides(NpyIter *iter) * Check the signs of all the strides, excluding * the index stride at the end. */ - for (iiter = 0; iiter < niter; ++iiter) { - if (strides[iiter] < 0) { + for (iop = 0; iop < nop; ++iop) { + if (strides[iop] < 0) { any_negative = 1; } - else if (strides[iiter] != 0) { + else if (strides[iop] != 0) { break; } } @@ -4145,7 +4145,7 @@ npyiter_flip_negative_strides(NpyIter *iter) * If at least on stride is negative and none are positive, * flip all the strides for this dimension. */ - if (any_negative && iiter == niter) { + if (any_negative && iop == nop) { npy_intp shapem1 = NAD_SHAPE(axisdata) - 1; for (istrides = 0; istrides < nstrides; ++istrides) { @@ -4197,13 +4197,13 @@ npyiter_reverse_axis_ordering(NpyIter *iter) { npy_uint32 itflags = NIT_ITFLAGS(iter); int ndim = NIT_NDIM(iter); - int niter = NIT_NITER(iter); + int nop = NIT_NOP(iter); npy_intp i, temp, size; npy_intp *first, *last; char *perm; - size = NIT_AXISDATA_SIZEOF(itflags, ndim, niter)/NPY_SIZEOF_INTP; + size = NIT_AXISDATA_SIZEOF(itflags, ndim, nop)/NPY_SIZEOF_INTP; first = (npy_intp*)NIT_AXISDATA(iter); last = first + (ndim-1)*size; @@ -4237,13 +4237,13 @@ npyiter_find_best_axis_ordering(NpyIter *iter) { npy_uint32 itflags = NIT_ITFLAGS(iter); int idim, ndim = NIT_NDIM(iter); - int iiter, niter = NIT_NITER(iter); + int iop, nop = NIT_NOP(iter); npy_intp ax_i0, ax_i1, ax_ipos; char ax_j0, ax_j1; char *perm; NpyIter_AxisData *axisdata = NIT_AXISDATA(iter); - npy_intp sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, niter); + npy_intp sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, nop); int permuted = 0; perm = NIT_PERM(iter); @@ -4269,10 +4269,10 @@ npyiter_find_best_axis_ordering(NpyIter *iter) strides1 = NAD_STRIDES(NIT_INDEX_AXISDATA(axisdata, ax_j1)); - for (iiter = 0; iiter < niter; ++iiter) { - if (strides0[iiter] != 0 && strides1[iiter] != 0) { - if (intp_abs(strides1[iiter]) <= - intp_abs(strides0[iiter])) { + for (iop = 0; iop < nop; ++iop) { + if (strides0[iop] != 0 && strides1[iop] != 0) { + if (intp_abs(strides1[iop]) <= + intp_abs(strides0[iop])) { /* * Set swap even if it's not ambiguous already, * because in the case of conflicts between @@ -4377,11 +4377,11 @@ npyiter_coalesce_axes(NpyIter *iter) { npy_uint32 itflags = NIT_ITFLAGS(iter); int idim, ndim = NIT_NDIM(iter); - int niter = NIT_NITER(iter); + int nop = NIT_NOP(iter); npy_intp istrides, nstrides = NAD_NSTRIDES(); NpyIter_AxisData *axisdata = NIT_AXISDATA(iter); - npy_intp sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, niter); + npy_intp sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, nop); NpyIter_AxisData *ad_compress; npy_intp new_ndim = 1; @@ -4462,7 +4462,7 @@ npyiter_new_temp_array(NpyIter *iter, PyTypeObject *subtype, { npy_uint32 itflags = NIT_ITFLAGS(iter); int idim, ndim = NIT_NDIM(iter); - int niter = NIT_NITER(iter); + int nop = NIT_NOP(iter); char *perm = NIT_PERM(iter); npy_intp new_shape[NPY_MAXDIMS], strides[NPY_MAXDIMS], @@ -4493,7 +4493,7 @@ npyiter_new_temp_array(NpyIter *iter, PyTypeObject *subtype, } axisdata = NIT_AXISDATA(iter); - sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, niter); + sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, nop); memset(reversestride, 0, NPY_MAXDIMS); /* Initialize the strides to invalid values */ @@ -4560,8 +4560,8 @@ npyiter_new_temp_array(NpyIter *iter, PyTypeObject *subtype, return NULL; } - NPY_IT_DBG_PRINT("Iterator: Indicating that a reduction " - "is occurring\n"); + NPY_IT_DBG_PRINT("Iterator: Indicating that a " + "reduction is occurring\n"); /* Indicate that a reduction is occurring */ NIT_ITFLAGS(iter) |= NPY_ITFLAG_REDUCE; (*op_itflags) |= NPY_OP_ITFLAG_REDUCE; @@ -4734,7 +4734,7 @@ npyiter_allocate_arrays(NpyIter *iter, { npy_uint32 itflags = NIT_ITFLAGS(iter); int idim, ndim = NIT_NDIM(iter); - int iiter, niter = NIT_NITER(iter); + int iop, nop = NIT_NOP(iter); NpyIter_BufferData *bufferdata = NULL; PyArrayObject **op = NIT_OPERANDS(iter); @@ -4744,136 +4744,136 @@ npyiter_allocate_arrays(NpyIter *iter, } - for (iiter = 0; iiter < niter; ++iiter) { + for (iop = 0; iop < nop; ++iop) { /* NULL means an output the iterator should allocate */ - if (op[iiter] == NULL) { + if (op[iop] == NULL) { PyArrayObject *out; PyTypeObject *op_subtype; int ondim = output_scalars ? 0 : ndim; /* Check whether the subtype was disabled */ - op_subtype = (op_flags[iiter]&NPY_ITER_NO_SUBTYPE) ? + op_subtype = (op_flags[iop]&NPY_ITER_NO_SUBTYPE) ? &PyArray_Type : subtype; /* Allocate the output array */ out = npyiter_new_temp_array(iter, op_subtype, - flags, &op_itflags[iiter], + flags, &op_itflags[iop], ondim, NULL, - op_dtype[iiter], - op_axes ? op_axes[iiter] : NULL); + op_dtype[iop], + op_axes ? op_axes[iop] : NULL); if (out == NULL) { return 0; } - op[iiter] = out; + op[iop] = out; /* * Now we need to replace the pointers and strides with values * from the new array. */ - npyiter_replace_axisdata(iter, iiter, op[iiter], ondim, - PyArray_DATA(op[iiter]), op_axes ? op_axes[iiter] : NULL); + npyiter_replace_axisdata(iter, iop, op[iop], ondim, + PyArray_DATA(op[iop]), op_axes ? op_axes[iop] : NULL); /* New arrays are aligned and need no cast */ - op_itflags[iiter] |= NPY_OP_ITFLAG_ALIGNED; - op_itflags[iiter] &= ~NPY_OP_ITFLAG_CAST; + op_itflags[iop] |= NPY_OP_ITFLAG_ALIGNED; + op_itflags[iop] &= ~NPY_OP_ITFLAG_CAST; } /* * If casting is required, the operand is read-only, and * it's an array scalar, make a copy whether or not the * copy flag is enabled. */ - else if ((op_itflags[iiter]&(NPY_OP_ITFLAG_CAST| + else if ((op_itflags[iop]&(NPY_OP_ITFLAG_CAST| NPY_OP_ITFLAG_READ| NPY_OP_ITFLAG_WRITE)) == (NPY_OP_ITFLAG_CAST| NPY_OP_ITFLAG_READ) && - PyArray_NDIM(op[iiter]) == 0) { + PyArray_NDIM(op[iop]) == 0) { PyArrayObject *temp; - Py_INCREF(op_dtype[iiter]); + Py_INCREF(op_dtype[iop]); temp = (PyArrayObject *)PyArray_NewFromDescr( - &PyArray_Type, op_dtype[iiter], + &PyArray_Type, op_dtype[iop], 0, NULL, NULL, NULL, 0, NULL); if (temp == NULL) { return 0; } - if (PyArray_CopyInto(temp, op[iiter]) != 0) { + if (PyArray_CopyInto(temp, op[iop]) != 0) { Py_DECREF(temp); return 0; } - Py_DECREF(op[iiter]); - op[iiter] = temp; + Py_DECREF(op[iop]); + op[iop] = temp; /* * Now we need to replace the pointers and strides with values * from the temporary array. */ - npyiter_replace_axisdata(iter, iiter, op[iiter], 0, - PyArray_DATA(op[iiter]), NULL); + npyiter_replace_axisdata(iter, iop, op[iop], 0, + PyArray_DATA(op[iop]), NULL); /* * New arrays are aligned need no cast, and in the case * of scalars, always have stride 0 so never need buffering */ - op_itflags[iiter] |= (NPY_OP_ITFLAG_ALIGNED| + op_itflags[iop] |= (NPY_OP_ITFLAG_ALIGNED| NPY_OP_ITFLAG_BUFNEVER); - op_itflags[iiter] &= ~NPY_OP_ITFLAG_CAST; + op_itflags[iop] &= ~NPY_OP_ITFLAG_CAST; if (itflags&NPY_ITFLAG_BUFFER) { - NBF_STRIDES(bufferdata)[iiter] = 0; + NBF_STRIDES(bufferdata)[iop] = 0; } } /* If casting is required and permitted */ - else if ((op_itflags[iiter]&NPY_OP_ITFLAG_CAST) && - (op_flags[iiter]&(NPY_ITER_COPY|NPY_ITER_UPDATEIFCOPY))) { + else if ((op_itflags[iop]&NPY_OP_ITFLAG_CAST) && + (op_flags[iop]&(NPY_ITER_COPY|NPY_ITER_UPDATEIFCOPY))) { PyArrayObject *temp; - int ondim = PyArray_NDIM(op[iiter]); + int ondim = PyArray_NDIM(op[iop]); /* Allocate the temporary array, if possible */ temp = npyiter_new_temp_array(iter, &PyArray_Type, - flags, &op_itflags[iiter], + flags, &op_itflags[iop], ondim, - PyArray_DIMS(op[iiter]), - op_dtype[iiter], - op_axes ? op_axes[iiter] : NULL); + PyArray_DIMS(op[iop]), + op_dtype[iop], + op_axes ? op_axes[iop] : NULL); if (temp == NULL) { return 0; } /* If the data will be read, copy it into temp */ - if (op_itflags[iiter]&NPY_OP_ITFLAG_READ) { - if (PyArray_CopyInto(temp, op[iiter]) != 0) { + if (op_itflags[iop]&NPY_OP_ITFLAG_READ) { + if (PyArray_CopyInto(temp, op[iop]) != 0) { Py_DECREF(temp); return 0; } } /* If the data will be written to, set UPDATEIFCOPY */ - if (op_itflags[iiter]&NPY_OP_ITFLAG_WRITE) { + if (op_itflags[iop]&NPY_OP_ITFLAG_WRITE) { PyArray_FLAGS(temp) |= NPY_UPDATEIFCOPY; - PyArray_FLAGS(op[iiter]) &= ~NPY_WRITEABLE; - Py_INCREF(op[iiter]); - temp->base = (PyObject *)op[iiter]; + PyArray_FLAGS(op[iop]) &= ~NPY_WRITEABLE; + Py_INCREF(op[iop]); + temp->base = (PyObject *)op[iop]; } - Py_DECREF(op[iiter]); - op[iiter] = temp; + Py_DECREF(op[iop]); + op[iop] = temp; /* * Now we need to replace the pointers and strides with values * from the temporary array. */ - npyiter_replace_axisdata(iter, iiter, op[iiter], ondim, - PyArray_DATA(op[iiter]), op_axes ? op_axes[iiter] : NULL); + npyiter_replace_axisdata(iter, iop, op[iop], ondim, + PyArray_DATA(op[iop]), op_axes ? op_axes[iop] : NULL); /* The temporary copy is aligned and needs no cast */ - op_itflags[iiter] |= NPY_OP_ITFLAG_ALIGNED; - op_itflags[iiter] &= ~NPY_OP_ITFLAG_CAST; + op_itflags[iop] |= NPY_OP_ITFLAG_ALIGNED; + op_itflags[iop] &= ~NPY_OP_ITFLAG_CAST; } else { /* * Buffering must be enabled for casting/conversion if copy * wasn't specified. */ - if ((op_itflags[iiter]&NPY_OP_ITFLAG_CAST) && + if ((op_itflags[iop]&NPY_OP_ITFLAG_CAST) && !(itflags&NPY_ITFLAG_BUFFER)) { PyErr_SetString(PyExc_TypeError, "Iterator operand required copying or buffering, " @@ -4885,20 +4885,20 @@ npyiter_allocate_arrays(NpyIter *iter, * If the operand is aligned, any buffering can use aligned * optimizations. */ - if (PyArray_ISALIGNED(op[iiter])) { - op_itflags[iiter] |= NPY_OP_ITFLAG_ALIGNED; + if (PyArray_ISALIGNED(op[iop])) { + op_itflags[iop] |= NPY_OP_ITFLAG_ALIGNED; } } /* Here we can finally check for contiguous iteration */ - if (op_flags[iiter]&NPY_ITER_CONTIG) { + if (op_flags[iop]&NPY_ITER_CONTIG) { NpyIter_AxisData *axisdata = NIT_AXISDATA(iter); - npy_intp stride = NAD_STRIDES(axisdata)[iiter]; + npy_intp stride = NAD_STRIDES(axisdata)[iop]; - if (stride != op_dtype[iiter]->elsize) { + if (stride != op_dtype[iop]->elsize) { NPY_IT_DBG_PRINT("Iterator: Setting NPY_OP_ITFLAG_CAST " "because of NPY_ITER_CONTIG\n"); - op_itflags[iiter] |= NPY_OP_ITFLAG_CAST; + op_itflags[iop] |= NPY_OP_ITFLAG_CAST; if (!(itflags&NPY_ITFLAG_BUFFER)) { PyErr_SetString(PyExc_TypeError, "Iterator operand required buffering, " @@ -4914,21 +4914,21 @@ npyiter_allocate_arrays(NpyIter *iter, * the inner stride of this operand works for the whole * array, we can set NPY_OP_ITFLAG_BUFNEVER. */ - if ((itflags&NPY_ITFLAG_BUFFER) && !(op_itflags[iiter]&NPY_OP_ITFLAG_CAST)) { + if ((itflags&NPY_ITFLAG_BUFFER) && !(op_itflags[iop]&NPY_OP_ITFLAG_CAST)) { NpyIter_AxisData *axisdata = NIT_AXISDATA(iter); if (ndim == 1) { - op_itflags[iiter] |= NPY_OP_ITFLAG_BUFNEVER; - NBF_STRIDES(bufferdata)[iiter] = NAD_STRIDES(axisdata)[iiter]; + op_itflags[iop] |= NPY_OP_ITFLAG_BUFNEVER; + NBF_STRIDES(bufferdata)[iop] = NAD_STRIDES(axisdata)[iop]; } - else if (PyArray_NDIM(op[iiter]) > 0) { + else if (PyArray_NDIM(op[iop]) > 0) { npy_intp stride, shape, innerstride = 0, innershape; npy_intp sizeof_axisdata = - NIT_AXISDATA_SIZEOF(itflags, ndim, niter); + NIT_AXISDATA_SIZEOF(itflags, ndim, nop); /* Find stride of the first non-empty shape */ for (idim = 0; idim < ndim; ++idim) { innershape = NAD_SHAPE(axisdata); if (innershape != 1) { - innerstride = NAD_STRIDES(axisdata)[iiter]; + innerstride = NAD_STRIDES(axisdata)[iop]; break; } NIT_ADVANCE_AXISDATA(axisdata, 1); @@ -4937,7 +4937,7 @@ npyiter_allocate_arrays(NpyIter *iter, NIT_ADVANCE_AXISDATA(axisdata, 1); /* Check that everything could have coalesced together */ for (; idim < ndim; ++idim) { - stride = NAD_STRIDES(axisdata)[iiter]; + stride = NAD_STRIDES(axisdata)[iop]; shape = NAD_SHAPE(axisdata); if (shape != 1) { /* @@ -4959,8 +4959,8 @@ npyiter_allocate_arrays(NpyIter *iter, * dimension. */ if (idim == ndim) { - op_itflags[iiter] |= NPY_OP_ITFLAG_BUFNEVER; - NBF_STRIDES(bufferdata)[iiter] = innerstride; + op_itflags[iop] |= NPY_OP_ITFLAG_BUFNEVER; + NBF_STRIDES(bufferdata)[iop] = innerstride; } } } @@ -4975,19 +4975,19 @@ npyiter_allocate_arrays(NpyIter *iter, * subtype of the input array with highest priority. */ static void -npyiter_get_priority_subtype(int niter, PyArrayObject **op, +npyiter_get_priority_subtype(int nop, PyArrayObject **op, char *op_itflags, double *subtype_priority, PyTypeObject **subtype) { - int iiter; + int iop; - for (iiter = 0; iiter < niter; ++iiter) { - if (op[iiter] != NULL && op_itflags[iiter]&NPY_OP_ITFLAG_READ) { - double priority = PyArray_GetPriority((PyObject *)op[iiter], 0.0); + for (iop = 0; iop < nop; ++iop) { + if (op[iop] != NULL && op_itflags[iop]&NPY_OP_ITFLAG_READ) { + double priority = PyArray_GetPriority((PyObject *)op[iop], 0.0); if (priority > *subtype_priority) { *subtype_priority = priority; - *subtype = Py_TYPE(op[iiter]); + *subtype = Py_TYPE(op[iop]); } } } @@ -4999,12 +4999,12 @@ npyiter_get_priority_subtype(int niter, PyArrayObject **op, * are not read from out of the calculation. */ static PyArray_Descr * -npyiter_get_common_dtype(int niter, PyArrayObject **op, +npyiter_get_common_dtype(int nop, PyArrayObject **op, char *op_itflags, PyArray_Descr **op_dtype, PyArray_Descr **op_request_dtypes, int only_inputs, int output_scalars) { - int iiter; + int iop; npy_intp narrs = 0, ndtypes = 0; PyArrayObject *arrs[NPY_MAXARGS]; PyArray_Descr *dtypes[NPY_MAXARGS]; @@ -5012,18 +5012,18 @@ npyiter_get_common_dtype(int niter, PyArrayObject **op, NPY_IT_DBG_PRINT("Iterator: Getting a common data type from operands\n"); - for (iiter = 0; iiter < niter; ++iiter) { - if (op_dtype[iiter] != NULL && - (!only_inputs || (op_itflags[iiter]&NPY_OP_ITFLAG_READ))) { + for (iop = 0; iop < nop; ++iop) { + if (op_dtype[iop] != NULL && + (!only_inputs || (op_itflags[iop]&NPY_OP_ITFLAG_READ))) { /* If no dtype was requested and the op is a scalar, pass the op */ if ((op_request_dtypes == NULL || - op_request_dtypes[iiter] == NULL) && - PyArray_NDIM(op[iiter]) == 0) { - arrs[narrs++] = op[iiter]; + op_request_dtypes[iop] == NULL) && + PyArray_NDIM(op[iop]) == 0) { + arrs[narrs++] = op[iop]; } /* Otherwise just pass in the dtype */ else { - dtypes[ndtypes++] = op_dtype[iiter]; + dtypes[ndtypes++] = op_dtype[iop]; } } } @@ -5059,7 +5059,7 @@ npyiter_allocate_transfer_functions(NpyIter *iter) { npy_uint32 itflags = NIT_ITFLAGS(iter); /*int ndim = NIT_NDIM(iter);*/ - int iiter = 0, niter = NIT_NITER(iter); + int iop = 0, nop = NIT_NOP(iter); npy_intp i; char *op_itflags = NIT_OPITFLAGS(iter); @@ -5077,14 +5077,14 @@ npyiter_allocate_transfer_functions(NpyIter *iter) void *transferdata = NULL; int needs_api = 0; - for (iiter = 0; iiter < niter; ++iiter) { - char flags = op_itflags[iiter]; + for (iop = 0; iop < nop; ++iop) { + char flags = op_itflags[iop]; /* * Reduction operands may be buffered with a different stride, * so we must pass NPY_MAX_INTP to the transfer function factory. */ op_stride = (flags&NPY_OP_ITFLAG_REDUCE) ? NPY_MAX_INTP : - strides[iiter]; + strides[iop]; /* * If we have determined that a buffer may be needed, @@ -5096,40 +5096,40 @@ npyiter_allocate_transfer_functions(NpyIter *iter) if (PyArray_GetDTypeTransferFunction( (flags&NPY_OP_ITFLAG_ALIGNED) != 0, op_stride, - op_dtype[iiter]->elsize, - PyArray_DESCR(op[iiter]), - op_dtype[iiter], + op_dtype[iop]->elsize, + PyArray_DESCR(op[iop]), + op_dtype[iop], move_references, &stransfer, &transferdata, &needs_api) != NPY_SUCCEED) { goto fail; } - readtransferfn[iiter] = stransfer; - readtransferdata[iiter] = transferdata; + readtransferfn[iop] = stransfer; + readtransferdata[iop] = transferdata; } else { - readtransferfn[iiter] = NULL; + readtransferfn[iop] = NULL; } if (flags&NPY_OP_ITFLAG_WRITE) { int move_references = 1; if (PyArray_GetDTypeTransferFunction( (flags&NPY_OP_ITFLAG_ALIGNED) != 0, - op_dtype[iiter]->elsize, + op_dtype[iop]->elsize, op_stride, - op_dtype[iiter], - PyArray_DESCR(op[iiter]), + op_dtype[iop], + PyArray_DESCR(op[iop]), move_references, &stransfer, &transferdata, &needs_api) != NPY_SUCCEED) { goto fail; } - writetransferfn[iiter] = stransfer; - writetransferdata[iiter] = transferdata; + writetransferfn[iop] = stransfer; + writetransferdata[iop] = transferdata; } /* If no write back but there are references make a decref fn */ - else if (PyDataType_REFCHK(op_dtype[iiter])) { + else if (PyDataType_REFCHK(op_dtype[iop])) { /* * By passing NULL to dst_type and setting move_references * to 1, we get back a function that just decrements the @@ -5137,24 +5137,24 @@ npyiter_allocate_transfer_functions(NpyIter *iter) */ if (PyArray_GetDTypeTransferFunction( (flags&NPY_OP_ITFLAG_ALIGNED) != 0, - op_dtype[iiter]->elsize, 0, - op_dtype[iiter], NULL, + op_dtype[iop]->elsize, 0, + op_dtype[iop], NULL, 1, &stransfer, &transferdata, &needs_api) != NPY_SUCCEED) { goto fail; } - writetransferfn[iiter] = stransfer; - writetransferdata[iiter] = transferdata; + writetransferfn[iop] = stransfer; + writetransferdata[iop] = transferdata; } else { - writetransferfn[iiter] = NULL; + writetransferfn[iop] = NULL; } } else { - readtransferfn[iiter] = NULL; - writetransferfn[iiter] = NULL; + readtransferfn[iop] = NULL; + writetransferfn[iop] = NULL; } } @@ -5166,14 +5166,14 @@ npyiter_allocate_transfer_functions(NpyIter *iter) return 1; fail: - for (i = 0; i < iiter; ++i) { - if (readtransferdata[iiter] != NULL) { - PyArray_FreeStridedTransferData(readtransferdata[iiter]); - readtransferdata[iiter] = NULL; + for (i = 0; i < iop; ++i) { + if (readtransferdata[iop] != NULL) { + PyArray_FreeStridedTransferData(readtransferdata[iop]); + readtransferdata[iop] = NULL; } - if (writetransferdata[iiter] != NULL) { - PyArray_FreeStridedTransferData(writetransferdata[iiter]); - writetransferdata[iiter] = NULL; + if (writetransferdata[iop] != NULL) { + PyArray_FreeStridedTransferData(writetransferdata[iop]); + writetransferdata[iop] = NULL; } } return 0; @@ -5191,7 +5191,7 @@ npyiter_allocate_buffers(NpyIter *iter, char **errmsg) { /*npy_uint32 itflags = NIT_ITFLAGS(iter);*/ /*int ndim = NIT_NDIM(iter);*/ - int iiter = 0, niter = NIT_NITER(iter); + int iop = 0, nop = NIT_NOP(iter); npy_intp i; char *op_itflags = NIT_OPITFLAGS(iter); @@ -5200,15 +5200,15 @@ npyiter_allocate_buffers(NpyIter *iter, char **errmsg) npy_intp buffersize = NBF_BUFFERSIZE(bufferdata); char *buffer, **buffers = NBF_BUFFERS(bufferdata); - for (iiter = 0; iiter < niter; ++iiter) { - char flags = op_itflags[iiter]; + for (iop = 0; iop < nop; ++iop) { + char flags = op_itflags[iop]; /* * If we have determined that a buffer may be needed, * allocate one. */ if (!(flags&NPY_OP_ITFLAG_BUFNEVER)) { - npy_intp itemsize = op_dtype[iiter]->elsize; + npy_intp itemsize = op_dtype[iop]->elsize; buffer = PyArray_malloc(itemsize*buffersize); if (buffer == NULL) { if (errmsg == NULL) { @@ -5219,14 +5219,14 @@ npyiter_allocate_buffers(NpyIter *iter, char **errmsg) } goto fail; } - buffers[iiter] = buffer; + buffers[iop] = buffer; } } return 1; fail: - for (i = 0; i < iiter; ++i) { + for (i = 0; i < iop; ++i) { if (buffers[i] != NULL) { PyArray_free(buffers[i]); buffers[i] = NULL; @@ -5245,7 +5245,7 @@ npyiter_goto_iterindex(NpyIter *iter, npy_intp iterindex) { npy_uint32 itflags = NIT_ITFLAGS(iter); int idim, ndim = NIT_NDIM(iter); - int niter = NIT_NITER(iter); + int nop = NIT_NOP(iter); char **dataptr; NpyIter_AxisData *axisdata; @@ -5253,7 +5253,7 @@ npyiter_goto_iterindex(NpyIter *iter, npy_intp iterindex) npy_intp istrides, nstrides, i, shape; axisdata = NIT_AXISDATA(iter); - sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, niter); + sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, nop); nstrides = NAD_NSTRIDES(); NIT_ITERINDEX(iter) = iterindex; @@ -5328,7 +5328,7 @@ npyiter_copy_from_buffers(NpyIter *iter) { npy_uint32 itflags = NIT_ITFLAGS(iter); int ndim = NIT_NDIM(iter); - int iiter, niter = NIT_NITER(iter); + int iop, nop = NIT_NOP(iter); char *op_itflags = NIT_OPITFLAGS(iter); NpyIter_BufferData *bufferdata = NIT_BUFFERDATA(iter); @@ -5340,7 +5340,7 @@ npyiter_copy_from_buffers(NpyIter *iter) buffersize = NBF_BUFFERSIZE(bufferdata); npy_intp *strides = NBF_STRIDES(bufferdata), *ad_strides = NAD_STRIDES(axisdata); - npy_intp sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, niter); + npy_intp sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, nop); char **ptrs = NBF_PTRS(bufferdata), **ad_ptrs = NAD_PTRS(axisdata); char **buffers = NBF_BUFFERS(bufferdata); char *buffer; @@ -5352,7 +5352,7 @@ npyiter_copy_from_buffers(NpyIter *iter) PyArray_StridedTransferFn *stransfer = NULL; void *transferdata = NULL; - npy_intp axisdata_incr = NIT_AXISDATA_SIZEOF(itflags, ndim, niter) / + npy_intp axisdata_incr = NIT_AXISDATA_SIZEOF(itflags, ndim, nop) / NPY_SIZEOF_INTP; /* If we're past the end, nothing to copy */ @@ -5370,34 +5370,34 @@ npyiter_copy_from_buffers(NpyIter *iter) transfersize *= NBF_REDUCE_OUTERSIZE(bufferdata); } - for (iiter = 0; iiter < niter; ++iiter) { - stransfer = NBF_WRITETRANSFERFN(bufferdata)[iiter]; - transferdata = NBF_WRITETRANSFERDATA(bufferdata)[iiter]; - buffer = buffers[iiter]; + for (iop = 0; iop < nop; ++iop) { + stransfer = NBF_WRITETRANSFERFN(bufferdata)[iop]; + transferdata = NBF_WRITETRANSFERDATA(bufferdata)[iop]; + buffer = buffers[iop]; /* * Copy the data back to the arrays. If the type has refs, * this function moves them so the buffer's refs are released. */ - if ((stransfer != NULL) && (op_itflags[iiter]&NPY_OP_ITFLAG_WRITE)) { + if ((stransfer != NULL) && (op_itflags[iop]&NPY_OP_ITFLAG_WRITE)) { /* Copy back only if the pointer was pointing to the buffer */ - npy_intp delta = (ptrs[iiter] - buffer); - if (0 <= delta && delta <= buffersize*dtypes[iiter]->elsize) { + npy_intp delta = (ptrs[iop] - buffer); + if (0 <= delta && delta <= buffersize*dtypes[iop]->elsize) { npy_intp op_transfersize; npy_intp src_stride, *dst_strides, *dst_coords, *dst_shape; int ndim_transfer; NPY_IT_DBG_PRINT1("Iterator: Operand %d was buffered\n", - (int)iiter); + (int)iop); /* * If this operand is being reduced in the inner loop, * its buffering stride was set to zero, and just * one element was copied. */ - if (op_itflags[iiter]&NPY_OP_ITFLAG_REDUCE) { - if (strides[iiter] == 0) { - if (reduce_outerstrides[iiter] == 0) { + if (op_itflags[iop]&NPY_OP_ITFLAG_REDUCE) { + if (strides[iop] == 0) { + if (reduce_outerstrides[iop] == 0) { op_transfersize = 1; src_stride = 0; dst_strides = &src_stride; @@ -5407,19 +5407,19 @@ npyiter_copy_from_buffers(NpyIter *iter) } else { op_transfersize = NBF_REDUCE_OUTERSIZE(bufferdata); - src_stride = reduce_outerstrides[iiter]; + src_stride = reduce_outerstrides[iop]; dst_strides = - &NAD_STRIDES(reduce_outeraxisdata)[iiter]; + &NAD_STRIDES(reduce_outeraxisdata)[iop]; dst_coords = &NAD_INDEX(reduce_outeraxisdata); dst_shape = &NAD_SHAPE(reduce_outeraxisdata); ndim_transfer = ndim - reduce_outerdim; } } else { - if (reduce_outerstrides[iiter] == 0) { + if (reduce_outerstrides[iop] == 0) { op_transfersize = NBF_SIZE(bufferdata); - src_stride = strides[iiter]; - dst_strides = &ad_strides[iiter]; + src_stride = strides[iop]; + dst_strides = &ad_strides[iop]; dst_coords = &NAD_INDEX(axisdata); dst_shape = &NAD_SHAPE(axisdata); ndim_transfer = reduce_outerdim ? @@ -5427,8 +5427,8 @@ npyiter_copy_from_buffers(NpyIter *iter) } else { op_transfersize = transfersize; - src_stride = strides[iiter]; - dst_strides = &ad_strides[iiter]; + src_stride = strides[iop]; + dst_strides = &ad_strides[iop]; dst_coords = &NAD_INDEX(axisdata); dst_shape = &NAD_SHAPE(axisdata); ndim_transfer = ndim; @@ -5437,8 +5437,8 @@ npyiter_copy_from_buffers(NpyIter *iter) } else { op_transfersize = transfersize; - src_stride = strides[iiter]; - dst_strides = &ad_strides[iiter]; + src_stride = strides[iop]; + dst_strides = &ad_strides[iop]; dst_coords = &NAD_INDEX(axisdata); dst_shape = &NAD_SHAPE(axisdata); ndim_transfer = ndim; @@ -5446,14 +5446,14 @@ npyiter_copy_from_buffers(NpyIter *iter) NPY_IT_DBG_PRINT2("Iterator: Copying buffer to " "operand %d (%d items)\n", - (int)iiter, (int)op_transfersize); + (int)iop, (int)op_transfersize); PyArray_TransferStridedToNDim(ndim_transfer, - ad_ptrs[iiter], dst_strides, axisdata_incr, + ad_ptrs[iop], dst_strides, axisdata_incr, buffer, src_stride, dst_coords, axisdata_incr, dst_shape, axisdata_incr, - op_transfersize, dtypes[iiter]->elsize, + op_transfersize, dtypes[iop]->elsize, stransfer, transferdata); } @@ -5464,13 +5464,13 @@ npyiter_copy_from_buffers(NpyIter *iter) */ else if (stransfer != NULL) { /* Decrement refs only if the pointer was pointing to the buffer */ - npy_intp delta = (ptrs[iiter] - buffer); - if (0 <= delta && delta <= transfersize*dtypes[iiter]->elsize) { + npy_intp delta = (ptrs[iop] - buffer); + if (0 <= delta && delta <= transfersize*dtypes[iop]->elsize) { NPY_IT_DBG_PRINT1("Iterator: Freeing refs and zeroing buffer " - "of operand %d\n", (int)iiter); + "of operand %d\n", (int)iop); /* Decrement refs */ - stransfer(NULL, 0, buffer, dtypes[iiter]->elsize, - transfersize, dtypes[iiter]->elsize, + stransfer(NULL, 0, buffer, dtypes[iop]->elsize, + transfersize, dtypes[iop]->elsize, transferdata); /* * Zero out the memory for safety. For instance, @@ -5478,7 +5478,7 @@ npyiter_copy_from_buffers(NpyIter *iter) * array pointing into the buffer, it will get None * values for its references after this. */ - memset(buffer, 0, dtypes[iiter]->elsize*transfersize); + memset(buffer, 0, dtypes[iop]->elsize*transfersize); } } } @@ -5496,7 +5496,7 @@ npyiter_copy_to_buffers(NpyIter *iter, char **prev_dataptrs) { npy_uint32 itflags = NIT_ITFLAGS(iter); int ndim = NIT_NDIM(iter); - int iiter, niter = NIT_NITER(iter); + int iop, nop = NIT_NOP(iter); char *op_itflags = NIT_OPITFLAGS(iter); NpyIter_BufferData *bufferdata = NIT_BUFFERDATA(iter); @@ -5507,7 +5507,7 @@ npyiter_copy_to_buffers(NpyIter *iter, char **prev_dataptrs) PyArrayObject **operands = NIT_OPERANDS(iter); npy_intp *strides = NBF_STRIDES(bufferdata), *ad_strides = NAD_STRIDES(axisdata); - npy_intp sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, niter); + npy_intp sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, nop); char **ptrs = NBF_PTRS(bufferdata), **ad_ptrs = NAD_PTRS(axisdata); char **buffers = NBF_BUFFERS(bufferdata); npy_intp iterindex, iterend, transfersize, @@ -5527,7 +5527,7 @@ npyiter_copy_to_buffers(NpyIter *iter, char **prev_dataptrs) npy_bool reuse_reduce_loops = (prev_dataptrs != NULL) && ((itflags&NPY_ITFLAG_REUSE_REDUCE_LOOPS) != 0); - npy_intp axisdata_incr = NIT_AXISDATA_SIZEOF(itflags, ndim, niter) / + npy_intp axisdata_incr = NIT_AXISDATA_SIZEOF(itflags, ndim, nop) / NPY_SIZEOF_INTP; NPY_IT_DBG_PRINT("Iterator: Copying inputs to buffers\n"); @@ -5603,40 +5603,40 @@ npyiter_copy_to_buffers(NpyIter *iter, char **prev_dataptrs) is_onestride = 1; } - for (iiter = 0; iiter < niter; ++iiter) { + for (iop = 0; iop < nop; ++iop) { /* * If the buffer is write-only, these two are NULL, and the buffer * pointers will be set up but the read copy won't be done */ - stransfer = NBF_READTRANSFERFN(bufferdata)[iiter]; - transferdata = NBF_READTRANSFERDATA(bufferdata)[iiter]; - switch (op_itflags[iiter]& + stransfer = NBF_READTRANSFERFN(bufferdata)[iop]; + transferdata = NBF_READTRANSFERDATA(bufferdata)[iop]; + switch (op_itflags[iop]& (NPY_OP_ITFLAG_BUFNEVER| NPY_OP_ITFLAG_CAST| NPY_OP_ITFLAG_REDUCE)) { /* Never need to buffer this operand */ case NPY_OP_ITFLAG_BUFNEVER: - ptrs[iiter] = ad_ptrs[iiter]; + ptrs[iop] = ad_ptrs[iop]; if (itflags&NPY_ITFLAG_REDUCE) { - reduce_outerstrides[iiter] = reduce_innersize * - strides[iiter]; - reduce_outerptrs[iiter] = ptrs[iiter]; + reduce_outerstrides[iop] = reduce_innersize * + strides[iop]; + reduce_outerptrs[iop] = ptrs[iop]; } /* - * Should not adjust the stride - ad_strides[iiter] - * could be zero, but strides[iiter] was initialized + * Should not adjust the stride - ad_strides[iop] + * could be zero, but strides[iop] was initialized * to the first non-trivial stride. */ stransfer = NULL; break; /* Never need to buffer this operand */ case NPY_OP_ITFLAG_BUFNEVER|NPY_OP_ITFLAG_REDUCE: - ptrs[iiter] = ad_ptrs[iiter]; - reduce_outerptrs[iiter] = ptrs[iiter]; - reduce_outerstrides[iiter] = 0; + ptrs[iop] = ad_ptrs[iop]; + reduce_outerptrs[iop] = ptrs[iop]; + reduce_outerstrides[iop] = 0; /* - * Should not adjust the stride - ad_strides[iiter] - * could be zero, but strides[iiter] was initialized + * Should not adjust the stride - ad_strides[iop] + * could be zero, but strides[iop] was initialized * to the first non-trivial stride. */ stransfer = NULL; @@ -5650,8 +5650,8 @@ npyiter_copy_to_buffers(NpyIter *iter, char **prev_dataptrs) * already does that, no need to copy it. */ if (is_onestride) { - ptrs[iiter] = ad_ptrs[iiter]; - strides[iiter] = ad_strides[iiter]; + ptrs[iop] = ad_ptrs[iop]; + strides[iop] = ad_strides[iop]; stransfer = NULL; } /* If some other op is reduced, we have a double reduce loop */ @@ -5660,33 +5660,33 @@ npyiter_copy_to_buffers(NpyIter *iter, char **prev_dataptrs) (transfersize/reduce_innersize <= NAD_SHAPE(reduce_outeraxisdata) - NAD_INDEX(reduce_outeraxisdata))) { - ptrs[iiter] = ad_ptrs[iiter]; - reduce_outerptrs[iiter] = ptrs[iiter]; - strides[iiter] = ad_strides[iiter]; - reduce_outerstrides[iiter] = - NAD_STRIDES(reduce_outeraxisdata)[iiter]; + ptrs[iop] = ad_ptrs[iop]; + reduce_outerptrs[iop] = ptrs[iop]; + strides[iop] = ad_strides[iop]; + reduce_outerstrides[iop] = + NAD_STRIDES(reduce_outeraxisdata)[iop]; stransfer = NULL; } else { /* In this case, the buffer is being used */ - ptrs[iiter] = buffers[iiter]; - strides[iiter] = dtypes[iiter]->elsize; + ptrs[iop] = buffers[iop]; + strides[iop] = dtypes[iop]->elsize; if (itflags&NPY_ITFLAG_REDUCE) { - reduce_outerstrides[iiter] = reduce_innersize * - strides[iiter]; - reduce_outerptrs[iiter] = ptrs[iiter]; + reduce_outerstrides[iop] = reduce_innersize * + strides[iop]; + reduce_outerptrs[iop] = ptrs[iop]; } } break; /* Just a copy, but with a reduction */ case NPY_OP_ITFLAG_REDUCE: - if (ad_strides[iiter] == 0) { - strides[iiter] = 0; + if (ad_strides[iop] == 0) { + strides[iop] = 0; /* It's all in one stride in the inner loop dimension */ if (is_onestride) { - NPY_IT_DBG_PRINT1("reduce op %d all one stride\n", (int)iiter); - ptrs[iiter] = ad_ptrs[iiter]; - reduce_outerstrides[iiter] = 0; + NPY_IT_DBG_PRINT1("reduce op %d all one stride\n", (int)iop); + ptrs[iop] = ad_ptrs[iop]; + reduce_outerstrides[iop] = 0; stransfer = NULL; } /* It's all in one stride in the reduce outer loop */ @@ -5695,33 +5695,33 @@ npyiter_copy_to_buffers(NpyIter *iter, char **prev_dataptrs) NAD_SHAPE(reduce_outeraxisdata) - NAD_INDEX(reduce_outeraxisdata))) { NPY_IT_DBG_PRINT1("reduce op %d all one outer stride\n", - (int)iiter); - ptrs[iiter] = ad_ptrs[iiter]; + (int)iop); + ptrs[iop] = ad_ptrs[iop]; /* Outer reduce loop advances by one item */ - reduce_outerstrides[iiter] = - NAD_STRIDES(reduce_outeraxisdata)[iiter]; + reduce_outerstrides[iop] = + NAD_STRIDES(reduce_outeraxisdata)[iop]; stransfer = NULL; } /* In this case, the buffer is being used */ else { - NPY_IT_DBG_PRINT1("reduce op %d must buffer\n", (int)iiter); - ptrs[iiter] = buffers[iiter]; + NPY_IT_DBG_PRINT1("reduce op %d must buffer\n", (int)iop); + ptrs[iop] = buffers[iop]; /* Both outer and inner reduce loops have stride 0 */ - if (NAD_STRIDES(reduce_outeraxisdata)[iiter] == 0) { - reduce_outerstrides[iiter] = 0; + if (NAD_STRIDES(reduce_outeraxisdata)[iop] == 0) { + reduce_outerstrides[iop] = 0; } /* Outer reduce loop advances by one item */ else { - reduce_outerstrides[iiter] = dtypes[iiter]->elsize; + reduce_outerstrides[iop] = dtypes[iop]->elsize; } } } else if (is_onestride) { - NPY_IT_DBG_PRINT1("reduce op %d all one stride in dim 0\n", (int)iiter); - ptrs[iiter] = ad_ptrs[iiter]; - strides[iiter] = ad_strides[iiter]; - reduce_outerstrides[iiter] = 0; + NPY_IT_DBG_PRINT1("reduce op %d all one stride in dim 0\n", (int)iop); + ptrs[iop] = ad_ptrs[iop]; + strides[iop] = ad_strides[iop]; + reduce_outerstrides[iop] = 0; stransfer = NULL; } else { @@ -5730,82 +5730,82 @@ npyiter_copy_to_buffers(NpyIter *iter, char **prev_dataptrs) (transfersize/reduce_innersize <= NAD_SHAPE(reduce_outeraxisdata) - NAD_INDEX(reduce_outeraxisdata))) { - ptrs[iiter] = ad_ptrs[iiter]; - strides[iiter] = ad_strides[iiter]; + ptrs[iop] = ad_ptrs[iop]; + strides[iop] = ad_strides[iop]; /* Outer reduce loop advances by one item */ - reduce_outerstrides[iiter] = - NAD_STRIDES(reduce_outeraxisdata)[iiter]; + reduce_outerstrides[iop] = + NAD_STRIDES(reduce_outeraxisdata)[iop]; stransfer = NULL; } /* In this case, the buffer is being used */ else { - ptrs[iiter] = buffers[iiter]; - strides[iiter] = dtypes[iiter]->elsize; + ptrs[iop] = buffers[iop]; + strides[iop] = dtypes[iop]->elsize; - if (NAD_STRIDES(reduce_outeraxisdata)[iiter] == 0) { + if (NAD_STRIDES(reduce_outeraxisdata)[iop] == 0) { /* Reduction in outer reduce loop */ - reduce_outerstrides[iiter] = 0; + reduce_outerstrides[iop] = 0; } else { /* Advance to next items in outer reduce loop */ - reduce_outerstrides[iiter] = reduce_innersize * - dtypes[iiter]->elsize; + reduce_outerstrides[iop] = reduce_innersize * + dtypes[iop]->elsize; } } } - reduce_outerptrs[iiter] = ptrs[iiter]; + reduce_outerptrs[iop] = ptrs[iop]; break; default: /* In this case, the buffer is being used */ - if (!(op_itflags[iiter]&NPY_OP_ITFLAG_REDUCE)) { - ptrs[iiter] = buffers[iiter]; - strides[iiter] = dtypes[iiter]->elsize; + if (!(op_itflags[iop]&NPY_OP_ITFLAG_REDUCE)) { + ptrs[iop] = buffers[iop]; + strides[iop] = dtypes[iop]->elsize; if (itflags&NPY_ITFLAG_REDUCE) { - reduce_outerstrides[iiter] = reduce_innersize * - strides[iiter]; - reduce_outerptrs[iiter] = ptrs[iiter]; + reduce_outerstrides[iop] = reduce_innersize * + strides[iop]; + reduce_outerptrs[iop] = ptrs[iop]; } } /* The buffer is being used with reduction */ else { - ptrs[iiter] = buffers[iiter]; - if (ad_strides[iiter] == 0) { - NPY_IT_DBG_PRINT1("cast op %d has innermost stride 0\n", (int)iiter); - strides[iiter] = 0; + ptrs[iop] = buffers[iop]; + if (ad_strides[iop] == 0) { + NPY_IT_DBG_PRINT1("cast op %d has innermost stride 0\n", (int)iop); + strides[iop] = 0; /* Both outer and inner reduce loops have stride 0 */ - if (NAD_STRIDES(reduce_outeraxisdata)[iiter] == 0) { - NPY_IT_DBG_PRINT1("cast op %d has outermost stride 0\n", (int)iiter); - reduce_outerstrides[iiter] = 0; + if (NAD_STRIDES(reduce_outeraxisdata)[iop] == 0) { + NPY_IT_DBG_PRINT1("cast op %d has outermost stride 0\n", (int)iop); + reduce_outerstrides[iop] = 0; } /* Outer reduce loop advances by one item */ else { - NPY_IT_DBG_PRINT1("cast op %d has outermost stride !=0\n", (int)iiter); - reduce_outerstrides[iiter] = dtypes[iiter]->elsize; + NPY_IT_DBG_PRINT1("cast op %d has outermost stride !=0\n", (int)iop); + reduce_outerstrides[iop] = dtypes[iop]->elsize; } } else { - NPY_IT_DBG_PRINT1("cast op %d has innermost stride !=0\n", (int)iiter); - strides[iiter] = dtypes[iiter]->elsize; + NPY_IT_DBG_PRINT1("cast op %d has innermost stride !=0\n", (int)iop); + strides[iop] = dtypes[iop]->elsize; - if (NAD_STRIDES(reduce_outeraxisdata)[iiter] == 0) { - NPY_IT_DBG_PRINT1("cast op %d has outermost stride 0\n", (int)iiter); + if (NAD_STRIDES(reduce_outeraxisdata)[iop] == 0) { + NPY_IT_DBG_PRINT1("cast op %d has outermost stride 0\n", (int)iop); /* Reduction in outer reduce loop */ - reduce_outerstrides[iiter] = 0; + reduce_outerstrides[iop] = 0; } else { - NPY_IT_DBG_PRINT1("cast op %d has outermost stride !=0\n", (int)iiter); + NPY_IT_DBG_PRINT1("cast op %d has outermost stride !=0\n", (int)iop); /* Advance to next items in outer reduce loop */ - reduce_outerstrides[iiter] = reduce_innersize * - dtypes[iiter]->elsize; + reduce_outerstrides[iop] = reduce_innersize * + dtypes[iop]->elsize; } } - reduce_outerptrs[iiter] = ptrs[iiter]; + reduce_outerptrs[iop] = ptrs[iop]; } break; } if (stransfer != NULL) { - npy_intp src_itemsize = PyArray_DESCR(operands[iiter])->elsize; + npy_intp src_itemsize = PyArray_DESCR(operands[iop])->elsize; npy_intp op_transfersize; npy_intp dst_stride, *src_strides, *src_coords, *src_shape; @@ -5820,10 +5820,10 @@ npyiter_copy_to_buffers(NpyIter *iter, char **prev_dataptrs) * set its buffering stride to zero, and just copy * one element. */ - if (op_itflags[iiter]&NPY_OP_ITFLAG_REDUCE) { - if (ad_strides[iiter] == 0) { - strides[iiter] = 0; - if (reduce_outerstrides[iiter] == 0) { + if (op_itflags[iop]&NPY_OP_ITFLAG_REDUCE) { + if (ad_strides[iop] == 0) { + strides[iop] = 0; + if (reduce_outerstrides[iop] == 0) { op_transfersize = 1; dst_stride = 0; src_strides = &dst_stride; @@ -5839,36 +5839,36 @@ npyiter_copy_to_buffers(NpyIter *iter, char **prev_dataptrs) * intermediate calculation. */ if (prev_dataptrs && - prev_dataptrs[iiter] == ad_ptrs[iiter]) { + prev_dataptrs[iop] == ad_ptrs[iop]) { NPY_IT_DBG_PRINT1("Iterator: skipping operand %d" " copy because it's a 1-element reduce\n", - (int)iiter); + (int)iop); skip_transfer = 1; } } else { op_transfersize = NBF_REDUCE_OUTERSIZE(bufferdata); - dst_stride = reduce_outerstrides[iiter]; - src_strides = &NAD_STRIDES(reduce_outeraxisdata)[iiter]; + dst_stride = reduce_outerstrides[iop]; + src_strides = &NAD_STRIDES(reduce_outeraxisdata)[iop]; src_coords = &NAD_INDEX(reduce_outeraxisdata); src_shape = &NAD_SHAPE(reduce_outeraxisdata); ndim_transfer = ndim - reduce_outerdim; } } else { - if (reduce_outerstrides[iiter] == 0) { + if (reduce_outerstrides[iop] == 0) { op_transfersize = NBF_SIZE(bufferdata); - dst_stride = strides[iiter]; - src_strides = &ad_strides[iiter]; + dst_stride = strides[iop]; + src_strides = &ad_strides[iop]; src_coords = &NAD_INDEX(axisdata); src_shape = &NAD_SHAPE(axisdata); ndim_transfer = reduce_outerdim ? reduce_outerdim : 1; } else { op_transfersize = transfersize; - dst_stride = strides[iiter]; - src_strides = &ad_strides[iiter]; + dst_stride = strides[iop]; + src_strides = &ad_strides[iop]; src_coords = &NAD_INDEX(axisdata); src_shape = &NAD_SHAPE(axisdata); ndim_transfer = ndim; @@ -5877,8 +5877,8 @@ npyiter_copy_to_buffers(NpyIter *iter, char **prev_dataptrs) } else { op_transfersize = transfersize; - dst_stride = strides[iiter]; - src_strides = &ad_strides[iiter]; + dst_stride = strides[iop]; + src_strides = &ad_strides[iop]; src_coords = &NAD_INDEX(axisdata); src_shape = &NAD_SHAPE(axisdata); ndim_transfer = ndim; @@ -5889,19 +5889,19 @@ npyiter_copy_to_buffers(NpyIter *iter, char **prev_dataptrs) * and the source pointer for this data didn't change, * we don't have to copy the data again. */ - if (reuse_reduce_loops && prev_dataptrs[iiter] == ad_ptrs[iiter]) { + if (reuse_reduce_loops && prev_dataptrs[iop] == ad_ptrs[iop]) { NPY_IT_DBG_PRINT2("Iterator: skipping operands %d " "copy (%d items) because loops are reused and the data " "pointer didn't change\n", - (int)iiter, (int)op_transfersize); + (int)iop, (int)op_transfersize); skip_transfer = 1; } /* If the data type requires zero-inititialization */ - if (PyDataType_FLAGCHK(dtypes[iiter], NPY_NEEDS_INIT)) { + if (PyDataType_FLAGCHK(dtypes[iop], NPY_NEEDS_INIT)) { NPY_IT_DBG_PRINT("Iterator: Buffer requires init, " "memsetting to 0\n"); - memset(ptrs[iiter], 0, dtypes[iiter]->elsize*op_transfersize); + memset(ptrs[iop], 0, dtypes[iop]->elsize*op_transfersize); /* Can't skip the transfer in this case */ skip_transfer = 0; } @@ -5909,11 +5909,11 @@ npyiter_copy_to_buffers(NpyIter *iter, char **prev_dataptrs) if (!skip_transfer) { NPY_IT_DBG_PRINT2("Iterator: Copying operand %d to " "buffer (%d items)\n", - (int)iiter, (int)op_transfersize); + (int)iop, (int)op_transfersize); PyArray_TransferNDimToStrided(ndim_transfer, - ptrs[iiter], dst_stride, - ad_ptrs[iiter], src_strides, axisdata_incr, + ptrs[iop], dst_stride, + ad_ptrs[iop], src_strides, axisdata_incr, src_coords, axisdata_incr, src_shape, axisdata_incr, op_transfersize, src_itemsize, @@ -5921,13 +5921,13 @@ npyiter_copy_to_buffers(NpyIter *iter, char **prev_dataptrs) transferdata); } } - else if (ptrs[iiter] == buffers[iiter]) { + else if (ptrs[iop] == buffers[iop]) { /* If the data type requires zero-inititialization */ - if (PyDataType_FLAGCHK(dtypes[iiter], NPY_NEEDS_INIT)) { + if (PyDataType_FLAGCHK(dtypes[iop], NPY_NEEDS_INIT)) { NPY_IT_DBG_PRINT1("Iterator: Write-only buffer for " "operand %d requires init, " - "memsetting to 0\n", (int)iiter); - memset(ptrs[iiter], 0, dtypes[iiter]->elsize*transfersize); + "memsetting to 0\n", (int)iop); + memset(ptrs[iop], 0, dtypes[iop]->elsize*transfersize); } } @@ -5980,7 +5980,7 @@ npyiter_checkreducesize(NpyIter *iter, npy_intp count, { npy_uint32 itflags = NIT_ITFLAGS(iter); int idim, ndim = NIT_NDIM(iter); - int iiter, niter = NIT_NITER(iter); + int iop, nop = NIT_NOP(iter); NpyIter_AxisData *axisdata; npy_intp sizeof_axisdata; @@ -6000,14 +6000,14 @@ npyiter_checkreducesize(NpyIter *iter, npy_intp count, return count; } - sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, niter); + sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, nop); axisdata = NIT_AXISDATA(iter); /* Indicate which REDUCE operands have stride 0 in the inner loop */ strides = NAD_STRIDES(axisdata); - for (iiter = 0; iiter < niter; ++iiter) { - stride0op[iiter] = (op_itflags[iiter]&NPY_OP_ITFLAG_REDUCE) && - (strides[iiter] == 0); + for (iop = 0; iop < nop; ++iop) { + stride0op[iop] = (op_itflags[iop]&NPY_OP_ITFLAG_REDUCE) && + (strides[iop] == 0); } shape = NAD_SHAPE(axisdata); coord = NAD_INDEX(axisdata); @@ -6019,7 +6019,7 @@ npyiter_checkreducesize(NpyIter *iter, npy_intp count, for (idim = 1; idim < ndim && reducespace < count; ++idim, NIT_ADVANCE_AXISDATA(axisdata, 1)) { strides = NAD_STRIDES(axisdata); - for (iiter = 0; iiter < niter; ++iiter) { + for (iop = 0; iop < nop; ++iop) { /* * If a reduce stride switched from zero to non-zero, or * vice versa, that's the point where the data will stop @@ -6027,10 +6027,10 @@ npyiter_checkreducesize(NpyIter *iter, npy_intp count, * buffer starts with an all zero multi-index up to this * point, gives us the reduce_innersize. */ - if((stride0op[iiter] && (strides[iiter] != 0)) || - (!stride0op[iiter] && - (strides[iiter] == 0) && - (op_itflags[iiter]&NPY_OP_ITFLAG_REDUCE))) { + if((stride0op[iop] && (strides[iop] != 0)) || + (!stride0op[iop] && + (strides[iop] == 0) && + (op_itflags[iop]&NPY_OP_ITFLAG_REDUCE))) { NPY_IT_DBG_PRINT1("Iterator: Reduce operation limits " "buffer to %d\n", (int)reducespace); /* @@ -6056,7 +6056,7 @@ npyiter_checkreducesize(NpyIter *iter, npy_intp count, } } /* If we broke out of the loop early, we found reduce_innersize */ - if (iiter != niter) { + if (iop != nop) { break; } @@ -6096,9 +6096,9 @@ npyiter_checkreducesize(NpyIter *iter, npy_intp count, factor = 1; /* Indicate which REDUCE operands have stride 0 at the current level */ strides = NAD_STRIDES(axisdata); - for (iiter = 0; iiter < niter; ++iiter) { - stride0op[iiter] = (op_itflags[iiter]&NPY_OP_ITFLAG_REDUCE) && - (strides[iiter] == 0); + for (iop = 0; iop < nop; ++iop) { + stride0op[iop] = (op_itflags[iop]&NPY_OP_ITFLAG_REDUCE) && + (strides[iop] == 0); } shape = NAD_SHAPE(axisdata); coord = NAD_INDEX(axisdata); @@ -6110,7 +6110,7 @@ npyiter_checkreducesize(NpyIter *iter, npy_intp count, for (; idim < ndim && reducespace < count; ++idim, NIT_ADVANCE_AXISDATA(axisdata, 1)) { strides = NAD_STRIDES(axisdata); - for (iiter = 0; iiter < niter; ++iiter) { + for (iop = 0; iop < nop; ++iop) { /* * If a reduce stride switched from zero to non-zero, or * vice versa, that's the point where the data will stop @@ -6118,10 +6118,10 @@ npyiter_checkreducesize(NpyIter *iter, npy_intp count, * buffer starts with an all zero multi-index up to this * point, gives us the reduce_innersize. */ - if((stride0op[iiter] && (strides[iiter] != 0)) || - (!stride0op[iiter] && - (strides[iiter] == 0) && - (op_itflags[iiter]&NPY_OP_ITFLAG_REDUCE))) { + if((stride0op[iop] && (strides[iop] != 0)) || + (!stride0op[iop] && + (strides[iop] == 0) && + (op_itflags[iop]&NPY_OP_ITFLAG_REDUCE))) { NPY_IT_DBG_PRINT1("Iterator: Reduce operation limits " "buffer to %d\n", (int)reducespace); /* @@ -6161,7 +6161,7 @@ NpyIter_DebugPrint(NpyIter *iter) { npy_uint32 itflags = NIT_ITFLAGS(iter); int idim, ndim = NIT_NDIM(iter); - int iiter, niter = NIT_NITER(iter); + int iop, nop = NIT_NOP(iter); NpyIter_AxisData *axisdata; npy_intp sizeof_axisdata; @@ -6201,17 +6201,17 @@ NpyIter_DebugPrint(NpyIter *iter) printf("REUSE_REDUCE_LOOPS "); printf("\n"); printf("| NDim: %d\n", (int)ndim); - printf("| NIter: %d\n", (int)niter); + printf("| NOp: %d\n", (int)nop); printf("| IterSize: %d\n", (int)NIT_ITERSIZE(iter)); printf("| IterStart: %d\n", (int)NIT_ITERSTART(iter)); printf("| IterEnd: %d\n", (int)NIT_ITEREND(iter)); printf("| IterIndex: %d\n", (int)NIT_ITERINDEX(iter)); printf("| Iterator SizeOf: %d\n", - (int)NIT_SIZEOF_ITERATOR(itflags, ndim, niter)); + (int)NIT_SIZEOF_ITERATOR(itflags, ndim, nop)); printf("| BufferData SizeOf: %d\n", - (int)NIT_BUFFERDATA_SIZEOF(itflags, ndim, niter)); + (int)NIT_BUFFERDATA_SIZEOF(itflags, ndim, nop)); printf("| AxisData SizeOf: %d\n", - (int)NIT_AXISDATA_SIZEOF(itflags, ndim, niter)); + (int)NIT_AXISDATA_SIZEOF(itflags, ndim, nop)); printf("|\n"); printf("| Perm: "); @@ -6220,43 +6220,43 @@ NpyIter_DebugPrint(NpyIter *iter) } printf("\n"); printf("| DTypes: "); - for (iiter = 0; iiter < niter; ++iiter) { - printf("%p ", (void *)NIT_DTYPES(iter)[iiter]); + for (iop = 0; iop < nop; ++iop) { + printf("%p ", (void *)NIT_DTYPES(iter)[iop]); } printf("\n"); printf("| DTypes: "); - for (iiter = 0; iiter < niter; ++iiter) { - if (NIT_DTYPES(iter)[iiter] != NULL) - PyObject_Print((PyObject*)NIT_DTYPES(iter)[iiter], stdout, 0); + for (iop = 0; iop < nop; ++iop) { + if (NIT_DTYPES(iter)[iop] != NULL) + PyObject_Print((PyObject*)NIT_DTYPES(iter)[iop], stdout, 0); else printf("(nil) "); printf(" "); } printf("\n"); printf("| InitDataPtrs: "); - for (iiter = 0; iiter < niter; ++iiter) { - printf("%p ", (void *)NIT_RESETDATAPTR(iter)[iiter]); + for (iop = 0; iop < nop; ++iop) { + printf("%p ", (void *)NIT_RESETDATAPTR(iter)[iop]); } printf("\n"); printf("| BaseOffsets: "); - for (iiter = 0; iiter < niter; ++iiter) { - printf("%i ", (int)NIT_BASEOFFSETS(iter)[iiter]); + for (iop = 0; iop < nop; ++iop) { + printf("%i ", (int)NIT_BASEOFFSETS(iter)[iop]); } printf("\n"); if (itflags&NPY_ITFLAG_HASINDEX) { printf("| InitIndex: %d\n", - (int)(npy_intp)NIT_RESETDATAPTR(iter)[niter]); + (int)(npy_intp)NIT_RESETDATAPTR(iter)[nop]); } printf("| Operands: "); - for (iiter = 0; iiter < niter; ++iiter) { - printf("%p ", (void *)NIT_OPERANDS(iter)[iiter]); + for (iop = 0; iop < nop; ++iop) { + printf("%p ", (void *)NIT_OPERANDS(iter)[iop]); } printf("\n"); printf("| Operand DTypes: "); - for (iiter = 0; iiter < niter; ++iiter) { + for (iop = 0; iop < nop; ++iop) { PyArray_Descr *dtype; - if (NIT_OPERANDS(iter)[iiter] != NULL) { - dtype = PyArray_DESCR(NIT_OPERANDS(iter)[iiter]); + if (NIT_OPERANDS(iter)[iop] != NULL) { + dtype = PyArray_DESCR(NIT_OPERANDS(iter)[iop]); if (dtype != NULL) PyObject_Print((PyObject *)dtype, stdout, 0); else @@ -6269,19 +6269,19 @@ NpyIter_DebugPrint(NpyIter *iter) } printf("\n"); printf("| OpItFlags:\n"); - for (iiter = 0; iiter < niter; ++iiter) { - printf("| Flags[%d]: ", (int)iiter); - if ((NIT_OPITFLAGS(iter)[iiter])&NPY_OP_ITFLAG_READ) + for (iop = 0; iop < nop; ++iop) { + printf("| Flags[%d]: ", (int)iop); + if ((NIT_OPITFLAGS(iter)[iop])&NPY_OP_ITFLAG_READ) printf("READ "); - if ((NIT_OPITFLAGS(iter)[iiter])&NPY_OP_ITFLAG_WRITE) + if ((NIT_OPITFLAGS(iter)[iop])&NPY_OP_ITFLAG_WRITE) printf("WRITE "); - if ((NIT_OPITFLAGS(iter)[iiter])&NPY_OP_ITFLAG_CAST) + if ((NIT_OPITFLAGS(iter)[iop])&NPY_OP_ITFLAG_CAST) printf("CAST "); - if ((NIT_OPITFLAGS(iter)[iiter])&NPY_OP_ITFLAG_BUFNEVER) + if ((NIT_OPITFLAGS(iter)[iop])&NPY_OP_ITFLAG_BUFNEVER) printf("BUFNEVER "); - if ((NIT_OPITFLAGS(iter)[iiter])&NPY_OP_ITFLAG_ALIGNED) + if ((NIT_OPITFLAGS(iter)[iop])&NPY_OP_ITFLAG_ALIGNED) printf("ALIGNED "); - if ((NIT_OPITFLAGS(iter)[iiter])&NPY_OP_ITFLAG_REDUCE) + if ((NIT_OPITFLAGS(iter)[iop])&NPY_OP_ITFLAG_REDUCE) printf("REDUCE "); printf("\n"); } @@ -6302,77 +6302,77 @@ NpyIter_DebugPrint(NpyIter *iter) (int)NBF_REDUCE_OUTERDIM(bufferdata)); } printf("| Strides: "); - for (iiter = 0; iiter < niter; ++iiter) - printf("%d ", (int)NBF_STRIDES(bufferdata)[iiter]); + for (iop = 0; iop < nop; ++iop) + printf("%d ", (int)NBF_STRIDES(bufferdata)[iop]); printf("\n"); /* Print the fixed strides when there's no inner loop */ if (itflags&NPY_ITFLAG_EXLOOP) { npy_intp fixedstrides[NPY_MAXDIMS]; printf("| Fixed Strides: "); NpyIter_GetInnerFixedStrideArray(iter, fixedstrides); - for (iiter = 0; iiter < niter; ++iiter) - printf("%d ", (int)fixedstrides[iiter]); + for (iop = 0; iop < nop; ++iop) + printf("%d ", (int)fixedstrides[iop]); printf("\n"); } printf("| Ptrs: "); - for (iiter = 0; iiter < niter; ++iiter) - printf("%p ", (void *)NBF_PTRS(bufferdata)[iiter]); + for (iop = 0; iop < nop; ++iop) + printf("%p ", (void *)NBF_PTRS(bufferdata)[iop]); printf("\n"); if (itflags&NPY_ITFLAG_REDUCE) { printf("| REDUCE Outer Strides: "); - for (iiter = 0; iiter < niter; ++iiter) - printf("%d ", (int)NBF_REDUCE_OUTERSTRIDES(bufferdata)[iiter]); + for (iop = 0; iop < nop; ++iop) + printf("%d ", (int)NBF_REDUCE_OUTERSTRIDES(bufferdata)[iop]); printf("\n"); printf("| REDUCE Outer Ptrs: "); - for (iiter = 0; iiter < niter; ++iiter) - printf("%p ", (void *)NBF_REDUCE_OUTERPTRS(bufferdata)[iiter]); + for (iop = 0; iop < nop; ++iop) + printf("%p ", (void *)NBF_REDUCE_OUTERPTRS(bufferdata)[iop]); printf("\n"); } printf("| ReadTransferFn: "); - for (iiter = 0; iiter < niter; ++iiter) - printf("%p ", (void *)NBF_READTRANSFERFN(bufferdata)[iiter]); + for (iop = 0; iop < nop; ++iop) + printf("%p ", (void *)NBF_READTRANSFERFN(bufferdata)[iop]); printf("\n"); printf("| ReadTransferData: "); - for (iiter = 0; iiter < niter; ++iiter) - printf("%p ", (void *)NBF_READTRANSFERDATA(bufferdata)[iiter]); + for (iop = 0; iop < nop; ++iop) + printf("%p ", (void *)NBF_READTRANSFERDATA(bufferdata)[iop]); printf("\n"); printf("| WriteTransferFn: "); - for (iiter = 0; iiter < niter; ++iiter) - printf("%p ", (void *)NBF_WRITETRANSFERFN(bufferdata)[iiter]); + for (iop = 0; iop < nop; ++iop) + printf("%p ", (void *)NBF_WRITETRANSFERFN(bufferdata)[iop]); printf("\n"); printf("| WriteTransferData: "); - for (iiter = 0; iiter < niter; ++iiter) - printf("%p ", (void *)NBF_WRITETRANSFERDATA(bufferdata)[iiter]); + for (iop = 0; iop < nop; ++iop) + printf("%p ", (void *)NBF_WRITETRANSFERDATA(bufferdata)[iop]); printf("\n"); printf("| Buffers: "); - for (iiter = 0; iiter < niter; ++iiter) - printf("%p ", (void *)NBF_BUFFERS(bufferdata)[iiter]); + for (iop = 0; iop < nop; ++iop) + printf("%p ", (void *)NBF_BUFFERS(bufferdata)[iop]); printf("\n"); printf("|\n"); } axisdata = NIT_AXISDATA(iter); - sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, niter); + sizeof_axisdata = NIT_AXISDATA_SIZEOF(itflags, ndim, nop); for (idim = 0; idim < ndim; ++idim, NIT_ADVANCE_AXISDATA(axisdata, 1)) { printf("| AxisData[%d]:\n", (int)idim); printf("| Shape: %d\n", (int)NAD_SHAPE(axisdata)); printf("| Index: %d\n", (int)NAD_INDEX(axisdata)); printf("| Strides: "); - for (iiter = 0; iiter < niter; ++iiter) { - printf("%d ", (int)NAD_STRIDES(axisdata)[iiter]); + for (iop = 0; iop < nop; ++iop) { + printf("%d ", (int)NAD_STRIDES(axisdata)[iop]); } printf("\n"); if (itflags&NPY_ITFLAG_HASINDEX) { - printf("| Index Stride: %d\n", (int)NAD_STRIDES(axisdata)[niter]); + printf("| Index Stride: %d\n", (int)NAD_STRIDES(axisdata)[nop]); } printf("| Ptrs: "); - for (iiter = 0; iiter < niter; ++iiter) { - printf("%p ", (void *)NAD_PTRS(axisdata)[iiter]); + for (iop = 0; iop < nop; ++iop) { + printf("%p ", (void *)NAD_PTRS(axisdata)[iop]); } printf("\n"); if (itflags&NPY_ITFLAG_HASINDEX) { printf("| Index Value: %d\n", - (int)((npy_intp*)NAD_PTRS(axisdata))[niter]); + (int)((npy_intp*)NAD_PTRS(axisdata))[nop]); } } diff --git a/numpy/core/src/multiarray/nditer_pywrap.c b/numpy/core/src/multiarray/nditer_pywrap.c index 3d13d9ec4..a0ddc2f5a 100644 --- a/numpy/core/src/multiarray/nditer_pywrap.c +++ b/numpy/core/src/multiarray/nditer_pywrap.c @@ -443,9 +443,9 @@ NpyIter_OpFlagsConverter(PyObject *op_flags_in, static int npyiter_convert_op_flags_array(PyObject *op_flags_in, - npy_uint32 *op_flags_array, npy_intp niter) + npy_uint32 *op_flags_array, npy_intp nop) { - npy_intp iiter; + npy_intp iop; if (!PyTuple_Check(op_flags_in) && !PyList_Check(op_flags_in)) { PyErr_SetString(PyExc_ValueError, @@ -453,22 +453,22 @@ npyiter_convert_op_flags_array(PyObject *op_flags_in, return 0; } - if (PySequence_Size(op_flags_in) != niter) { + if (PySequence_Size(op_flags_in) != nop) { goto try_single_flags; } - for (iiter = 0; iiter < niter; ++iiter) { - PyObject *f = PySequence_GetItem(op_flags_in, iiter); + for (iop = 0; iop < nop; ++iop) { + PyObject *f = PySequence_GetItem(op_flags_in, iop); if (f == NULL) { return 0; } /* If the first item is a string, try as one set of flags */ - if (iiter == 0 && (PyBytes_Check(f) || PyUnicode_Check(f))) { + if (iop == 0 && (PyBytes_Check(f) || PyUnicode_Check(f))) { Py_DECREF(f); goto try_single_flags; } if (NpyIter_OpFlagsConverter(f, - &op_flags_array[iiter]) != 1) { + &op_flags_array[iop]) != 1) { Py_DECREF(f); return 0; } @@ -484,8 +484,8 @@ try_single_flags: return 0; } - for (iiter = 1; iiter < niter; ++iiter) { - op_flags_array[iiter] = op_flags_array[0]; + for (iop = 1; iop < nop; ++iop) { + op_flags_array[iop] = op_flags_array[0]; } return 1; @@ -494,33 +494,33 @@ try_single_flags: static int npyiter_convert_dtypes(PyObject *op_dtypes_in, PyArray_Descr **op_dtypes, - npy_intp niter) + npy_intp nop) { - npy_intp iiter; + npy_intp iop; /* * If the input isn't a tuple of dtypes, try converting it as-is * to a dtype, and replicating to all operands. */ if ((!PyTuple_Check(op_dtypes_in) && !PyList_Check(op_dtypes_in)) || - PySequence_Size(op_dtypes_in) != niter) { + PySequence_Size(op_dtypes_in) != nop) { goto try_single_dtype; } - for (iiter = 0; iiter < niter; ++iiter) { - PyObject *dtype = PySequence_GetItem(op_dtypes_in, iiter); + for (iop = 0; iop < nop; ++iop) { + PyObject *dtype = PySequence_GetItem(op_dtypes_in, iop); if (dtype == NULL) { npy_intp i; - for (i = 0; i < iiter; ++i ) { + for (i = 0; i < iop; ++i ) { Py_XDECREF(op_dtypes[i]); } return 0; } /* Try converting the object to a descr */ - if (PyArray_DescrConverter2(dtype, &op_dtypes[iiter]) != 1) { + if (PyArray_DescrConverter2(dtype, &op_dtypes[iop]) != 1) { npy_intp i; - for (i = 0; i < iiter; ++i ) { + for (i = 0; i < iop; ++i ) { Py_XDECREF(op_dtypes[i]); } Py_DECREF(dtype); @@ -535,9 +535,9 @@ npyiter_convert_dtypes(PyObject *op_dtypes_in, try_single_dtype: if (PyArray_DescrConverter2(op_dtypes_in, &op_dtypes[0]) == 1) { - for (iiter = 1; iiter < niter; ++iiter) { - op_dtypes[iiter] = op_dtypes[0]; - Py_XINCREF(op_dtypes[iiter]); + for (iop = 1; iop < nop; ++iop) { + op_dtypes[iop] = op_dtypes[0]; + Py_XINCREF(op_dtypes[iop]); } return 1; } @@ -546,14 +546,14 @@ try_single_dtype: } static int -npyiter_convert_op_axes(PyObject *op_axes_in, npy_intp niter, +npyiter_convert_op_axes(PyObject *op_axes_in, npy_intp nop, int **op_axes, int *oa_ndim) { PyObject *a; - int iiter; + int iop; if ((!PyTuple_Check(op_axes_in) && !PyList_Check(op_axes_in)) || - PySequence_Size(op_axes_in) != niter) { + PySequence_Size(op_axes_in) != nop) { PyErr_SetString(PyExc_ValueError, "op_axes must be a tuple/list matching the number of ops"); return 0; @@ -562,14 +562,14 @@ npyiter_convert_op_axes(PyObject *op_axes_in, npy_intp niter, *oa_ndim = 0; /* Copy the tuples into op_axes */ - for (iiter = 0; iiter < niter; ++iiter) { + for (iop = 0; iop < nop; ++iop) { int idim; - a = PySequence_GetItem(op_axes_in, iiter); + a = PySequence_GetItem(op_axes_in, iop); if (a == NULL) { return 0; } if (a == Py_None) { - op_axes[iiter] = NULL; + op_axes[iop] = NULL; } else { if (!PyTuple_Check(a) && !PyList_Check(a)) { PyErr_SetString(PyExc_ValueError, @@ -605,11 +605,11 @@ npyiter_convert_op_axes(PyObject *op_axes_in, npy_intp niter, } /* numpy.newaxis is None */ if (v == Py_None) { - op_axes[iiter][idim] = -1; + op_axes[iop][idim] = -1; } else { - op_axes[iiter][idim] = PyInt_AsLong(v); - if (op_axes[iiter][idim]==-1 && + op_axes[iop][idim] = PyInt_AsLong(v); + if (op_axes[iop][idim]==-1 && PyErr_Occurred()) { Py_DECREF(a); Py_DECREF(v); @@ -634,34 +634,34 @@ npyiter_convert_op_axes(PyObject *op_axes_in, npy_intp niter, /* * Converts the operand array and op_flags array into the form NpyIter_AdvancedNew - * needs. Sets niter, and on success, each op[i] owns a reference + * needs. Sets nop, and on success, each op[i] owns a reference * to an array object. */ static int npyiter_convert_ops(PyObject *op_in, PyObject *op_flags_in, PyArrayObject **op, npy_uint32 *op_flags, - int *niter_out) + int *nop_out) { - int iiter, niter; + int iop, nop; - /* niter and op */ + /* nop and op */ if (PyTuple_Check(op_in) || PyList_Check(op_in)) { - niter = PySequence_Size(op_in); - if (niter == 0) { + nop = PySequence_Size(op_in); + if (nop == 0) { PyErr_SetString(PyExc_ValueError, "Must provide at least one operand"); return 0; } - if (niter > NPY_MAXARGS) { + if (nop > NPY_MAXARGS) { PyErr_SetString(PyExc_ValueError, "Too many operands"); return 0; } - for (iiter = 0; iiter < niter; ++iiter) { - PyObject *item = PySequence_GetItem(op_in, iiter); + for (iop = 0; iop < nop; ++iop) { + PyObject *item = PySequence_GetItem(op_in, iop); if (item == NULL) { npy_intp i; - for (i = 0; i < iiter; ++i) { + for (i = 0; i < iop; ++i) { Py_XDECREF(op[i]); } return 0; @@ -671,53 +671,53 @@ npyiter_convert_ops(PyObject *op_in, PyObject *op_flags_in, item = NULL; } /* This is converted to an array after op flags are retrieved */ - op[iiter] = (PyArrayObject *)item; + op[iop] = (PyArrayObject *)item; } } else { - niter = 1; + nop = 1; /* Is converted to an array after op flags are retrieved */ Py_INCREF(op_in); op[0] = (PyArrayObject *)op_in; } - *niter_out = niter; + *nop_out = nop; /* op_flags */ if (op_flags_in == NULL || op_flags_in == Py_None) { - for (iiter = 0; iiter < niter; ++iiter) { + for (iop = 0; iop < nop; ++iop) { /* * By default, make NULL operands writeonly and flagged for * allocation, and everything else readonly. To write * to a provided operand, you must specify the write flag manually. */ - if (op[iiter] == NULL) { - op_flags[iiter] = NPY_ITER_WRITEONLY | NPY_ITER_ALLOCATE; + if (op[iop] == NULL) { + op_flags[iop] = NPY_ITER_WRITEONLY | NPY_ITER_ALLOCATE; } else { - op_flags[iiter] = NPY_ITER_READONLY; + op_flags[iop] = NPY_ITER_READONLY; } } } else if (npyiter_convert_op_flags_array(op_flags_in, - op_flags, niter) != 1) { - for (iiter = 0; iiter < niter; ++iiter) { - Py_XDECREF(op[iiter]); + op_flags, nop) != 1) { + for (iop = 0; iop < nop; ++iop) { + Py_XDECREF(op[iop]); } - *niter_out = 0; + *nop_out = 0; return 0; } /* Now that we have the flags - convert all the ops to arrays */ - for (iiter = 0; iiter < niter; ++iiter) { - if (op[iiter] != NULL) { + for (iop = 0; iop < nop; ++iop) { + if (op[iop] != NULL) { PyArrayObject *ao; int fromanyflags = 0; - if (op_flags[iiter]&(NPY_ITER_READWRITE|NPY_ITER_WRITEONLY)) { + if (op_flags[iop]&(NPY_ITER_READWRITE|NPY_ITER_WRITEONLY)) { fromanyflags = NPY_UPDATEIFCOPY; } - ao = (PyArrayObject *)PyArray_FromAny((PyObject *)op[iiter], + ao = (PyArrayObject *)PyArray_FromAny((PyObject *)op[iop], NULL, 0, 0, fromanyflags, NULL); if (ao == NULL) { if (PyErr_Occurred() && @@ -727,14 +727,14 @@ npyiter_convert_ops(PyObject *op_in, PyObject *op_flags_in, "but is an object which cannot be written " "back to via UPDATEIFCOPY"); } - for (iiter = 0; iiter < niter; ++iiter) { - Py_DECREF(op[iiter]); + for (iop = 0; iop < nop; ++iop) { + Py_DECREF(op[iop]); } - *niter_out = 0; + *nop_out = 0; return 0; } - Py_DECREF(op[iiter]); - op[iiter] = ao; + Py_DECREF(op[iop]); + op[iop] = ao; } } @@ -752,7 +752,7 @@ npyiter_init(NewNpyArrayIterObject *self, PyObject *args, PyObject *kwds) PyObject *op_in = NULL, *op_flags_in = NULL, *op_dtypes_in = NULL, *op_axes_in = NULL; - int iiter, niter = 0; + int iop, nop = 0; PyArrayObject *op[NPY_MAXARGS]; npy_uint32 flags = 0; NPY_ORDER order = NPY_KEEPORDER; @@ -791,7 +791,7 @@ npyiter_init(NewNpyArrayIterObject *self, PyObject *args, PyObject *kwds) memset(op_request_dtypes, 0, sizeof(op_request_dtypes)); /* op and op_flags */ - if (npyiter_convert_ops(op_in, op_flags_in, op, op_flags, &niter) + if (npyiter_convert_ops(op_in, op_flags_in, op, op_flags, &nop) != 1) { goto fail; } @@ -799,18 +799,18 @@ npyiter_init(NewNpyArrayIterObject *self, PyObject *args, PyObject *kwds) /* op_request_dtypes */ if (op_dtypes_in != NULL && op_dtypes_in != Py_None && npyiter_convert_dtypes(op_dtypes_in, - op_request_dtypes, niter) != 1) { + op_request_dtypes, nop) != 1) { goto fail; } /* op_axes */ if (op_axes_in != NULL && op_axes_in != Py_None) { /* Initialize to point to the op_axes arrays */ - for (iiter = 0; iiter < niter; ++iiter) { - op_axes[iiter] = op_axes_arrays[iiter]; + for (iop = 0; iop < nop; ++iop) { + op_axes[iop] = op_axes_arrays[iop]; } - if (npyiter_convert_op_axes(op_axes_in, niter, + if (npyiter_convert_op_axes(op_axes_in, nop, op_axes, &oa_ndim) != 1) { goto fail; } @@ -833,7 +833,7 @@ npyiter_init(NewNpyArrayIterObject *self, PyObject *args, PyObject *kwds) itershape.ptr = NULL; } - self->iter = NpyIter_AdvancedNew(niter, op, flags, order, casting, op_flags, + self->iter = NpyIter_AdvancedNew(nop, op, flags, order, casting, op_flags, op_request_dtypes, oa_ndim, oa_ndim > 0 ? op_axes : NULL, itershape.ptr, @@ -860,9 +860,9 @@ npyiter_init(NewNpyArrayIterObject *self, PyObject *args, PyObject *kwds) } /* Release the references we got to the ops and dtypes */ - for (iiter = 0; iiter < niter; ++iiter) { - Py_XDECREF(op[iiter]); - Py_XDECREF(op_request_dtypes[iiter]); + for (iop = 0; iop < nop; ++iop) { + Py_XDECREF(op[iop]); + Py_XDECREF(op_request_dtypes[iop]); } return 0; @@ -871,9 +871,9 @@ fail: if (itershape.ptr != NULL) { PyDimMem_FREE(itershape.ptr); } - for (iiter = 0; iiter < niter; ++iiter) { - Py_XDECREF(op[iiter]); - Py_XDECREF(op_request_dtypes[iiter]); + for (iop = 0; iop < nop; ++iop) { + Py_XDECREF(op[iop]); + Py_XDECREF(op_request_dtypes[iop]); } return -1; } @@ -890,7 +890,7 @@ NpyIter_NestedIters(PyObject *NPY_UNUSED(self), PyObject *op_in = NULL, *axes_in = NULL, *op_flags_in = NULL, *op_dtypes_in = NULL; - int iiter, niter = 0, inest, nnest = 0; + int iop, nop = 0, inest, nnest = 0; PyArrayObject *op[NPY_MAXARGS]; npy_uint32 flags = 0, flags_inner = 0; NPY_ORDER order = NPY_KEEPORDER; @@ -986,20 +986,20 @@ NpyIter_NestedIters(PyObject *NPY_UNUSED(self), } /* op and op_flags */ - if (npyiter_convert_ops(op_in, op_flags_in, op, op_flags, &niter) + if (npyiter_convert_ops(op_in, op_flags_in, op, op_flags, &nop) != 1) { return NULL; } /* Set the dtypes to all NULL to start as well */ - memset(op_request_dtypes, 0, sizeof(op_request_dtypes[0])*niter); + memset(op_request_dtypes, 0, sizeof(op_request_dtypes[0])*nop); memset(op_request_dtypes_inner, 0, - sizeof(op_request_dtypes_inner[0])*niter); + sizeof(op_request_dtypes_inner[0])*nop); /* op_request_dtypes */ if (op_dtypes_in != NULL && op_dtypes_in != Py_None && npyiter_convert_dtypes(op_dtypes_in, - op_request_dtypes, niter) != 1) { + op_request_dtypes, nop) != 1) { goto fail; } @@ -1018,16 +1018,16 @@ NpyIter_NestedIters(PyObject *NPY_UNUSED(self), * to indicate exactly the allocated outputs. Also, separate * the inner loop flags. */ - for (iiter = 0; iiter < niter; ++iiter) { - if ((op_flags[iiter]&NPY_ITER_ALLOCATE) && op[iiter] != NULL) { - op_flags[iiter] &= ~NPY_ITER_ALLOCATE; + for (iop = 0; iop < nop; ++iop) { + if ((op_flags[iop]&NPY_ITER_ALLOCATE) && op[iop] != NULL) { + op_flags[iop] &= ~NPY_ITER_ALLOCATE; } /* * Clear any flags allowing copies or output allocation for * the inner loop. */ - op_flags_inner[iiter] = op_flags[iiter] & ~(NPY_ITER_COPY| + op_flags_inner[iop] = op_flags[iop] & ~(NPY_ITER_COPY| NPY_ITER_UPDATEIFCOPY| NPY_ITER_ALLOCATE); /* @@ -1036,12 +1036,12 @@ NpyIter_NestedIters(PyObject *NPY_UNUSED(self), * for the outer loops. */ if ((flags&(NPY_ITER_BUFFERED)) && - !(op_flags[iiter]&(NPY_ITER_COPY| + !(op_flags[iop]&(NPY_ITER_COPY| NPY_ITER_UPDATEIFCOPY| NPY_ITER_ALLOCATE))) { - op_flags[iiter] &= ~(NPY_ITER_NBO|NPY_ITER_ALIGNED|NPY_ITER_CONTIG); - op_request_dtypes_inner[iiter] = op_request_dtypes[iiter]; - op_request_dtypes[iiter] = NULL; + op_flags[iop] &= ~(NPY_ITER_NBO|NPY_ITER_ALIGNED|NPY_ITER_CONTIG); + op_request_dtypes_inner[iop] = op_request_dtypes[iop]; + op_request_dtypes[iop] = NULL; } } @@ -1052,33 +1052,33 @@ NpyIter_NestedIters(PyObject *NPY_UNUSED(self), for (inest = 0; inest < nnest; ++inest) { NewNpyArrayIterObject *iter; - int *op_axes_niter[NPY_MAXARGS]; + int *op_axes_nop[NPY_MAXARGS]; /* * All the operands' op_axes are the same, except for * allocated outputs. */ - for (iiter = 0; iiter < niter; ++iiter) { - if (op_flags[iiter]&NPY_ITER_ALLOCATE) { + for (iop = 0; iop < nop; ++iop) { + if (op_flags[iop]&NPY_ITER_ALLOCATE) { if (inest == 0) { - op_axes_niter[iiter] = NULL; + op_axes_nop[iop] = NULL; } else { - op_axes_niter[iiter] = negones; + op_axes_nop[iop] = negones; } } else { - op_axes_niter[iiter] = nested_op_axes[inest]; + op_axes_nop[iop] = nested_op_axes[inest]; } } /* printf("\n"); - for (iiter = 0; iiter < niter; ++iiter) { + for (iop = 0; iop < nop; ++iop) { npy_intp i; for (i = 0; i < nested_naxes[inest]; ++i) { - printf("%d ", (int)op_axes_niter[iiter][i]); + printf("%d ", (int)op_axes_nop[iop][i]); } printf("\n"); } @@ -1092,17 +1092,17 @@ NpyIter_NestedIters(PyObject *NPY_UNUSED(self), } if (inest < nnest-1) { - iter->iter = NpyIter_AdvancedNew(niter, op, flags, order, + iter->iter = NpyIter_AdvancedNew(nop, op, flags, order, casting, op_flags, op_request_dtypes, - nested_naxes[inest], op_axes_niter, + nested_naxes[inest], op_axes_nop, NULL, 0); } else { - iter->iter = NpyIter_AdvancedNew(niter, op, flags_inner, order, + iter->iter = NpyIter_AdvancedNew(nop, op, flags_inner, order, casting, op_flags_inner, op_request_dtypes_inner, - nested_naxes[inest], op_axes_niter, + nested_naxes[inest], op_axes_nop, NULL, buffersize); } @@ -1130,18 +1130,18 @@ NpyIter_NestedIters(PyObject *NPY_UNUSED(self), */ if (inest == 0) { PyArrayObject **operands = NpyIter_GetOperandArray(iter->iter); - for (iiter = 0; iiter < niter; ++iiter) { - if (op[iiter] != operands[iiter]) { - Py_XDECREF(op[iiter]); - op[iiter] = operands[iiter]; - Py_INCREF(op[iiter]); + for (iop = 0; iop < nop; ++iop) { + if (op[iop] != operands[iop]) { + Py_XDECREF(op[iop]); + op[iop] = operands[iop]; + Py_INCREF(op[iop]); } /* * Clear any flags allowing copies for * the rest of the iterators */ - op_flags[iiter] &= ~(NPY_ITER_COPY| + op_flags[iop] &= ~(NPY_ITER_COPY| NPY_ITER_UPDATEIFCOPY); } /* Clear the common dtype flag for the rest of the iterators */ @@ -1152,10 +1152,10 @@ NpyIter_NestedIters(PyObject *NPY_UNUSED(self), } /* Release our references to the ops and dtypes */ - for (iiter = 0; iiter < niter; ++iiter) { - Py_XDECREF(op[iiter]); - Py_XDECREF(op_request_dtypes[iiter]); - Py_XDECREF(op_request_dtypes_inner[iiter]); + for (iop = 0; iop < nop; ++iop) { + Py_XDECREF(op[iop]); + Py_XDECREF(op_request_dtypes[iop]); + Py_XDECREF(op_request_dtypes_inner[iop]); } /* Set up the nested child references */ @@ -1183,10 +1183,10 @@ NpyIter_NestedIters(PyObject *NPY_UNUSED(self), return ret; fail: - for (iiter = 0; iiter < niter; ++iiter) { - Py_XDECREF(op[iiter]); - Py_XDECREF(op_request_dtypes[iiter]); - Py_XDECREF(op_request_dtypes_inner[iiter]); + for (iop = 0; iop < nop; ++iop) { + Py_XDECREF(op[iop]); + Py_XDECREF(op_request_dtypes[iop]); + Py_XDECREF(op_request_dtypes_inner[iop]); } return NULL; } @@ -1416,7 +1416,7 @@ static PyObject *npyiter_value_get(NewNpyArrayIterObject *self) { PyObject *ret; - npy_intp iiter, niter; + npy_intp iop, nop; PyArray_Descr **dtypes; char **dataptrs; @@ -1426,26 +1426,26 @@ static PyObject *npyiter_value_get(NewNpyArrayIterObject *self) return NULL; } - niter = NpyIter_GetNIter(self->iter); + nop = NpyIter_GetNOp(self->iter); dtypes = self->dtypes; dataptrs = self->dataptrs; /* Return an array or tuple of arrays with the values */ - if (niter == 1) { + if (nop == 1) { ret = npyiter_seq_item(self, 0); } else { - ret = PyTuple_New(niter); + ret = PyTuple_New(nop); if (ret == NULL) { return NULL; } - for (iiter = 0; iiter < niter; ++iiter) { - PyObject *a = npyiter_seq_item(self, iiter); + for (iop = 0; iop < nop; ++iop) { + PyObject *a = npyiter_seq_item(self, iop); if (a == NULL) { Py_DECREF(ret); return NULL; } - PyTuple_SET_ITEM(ret, iiter, a); + PyTuple_SET_ITEM(ret, iop, a); } } @@ -1456,7 +1456,7 @@ static PyObject *npyiter_operands_get(NewNpyArrayIterObject *self) { PyObject *ret; - npy_intp iiter, niter; + npy_intp iop, nop; PyArrayObject **operands; if (self->iter == NULL) { @@ -1465,18 +1465,18 @@ static PyObject *npyiter_operands_get(NewNpyArrayIterObject *self) return NULL; } - niter = NpyIter_GetNIter(self->iter); + nop = NpyIter_GetNOp(self->iter); operands = self->operands; - ret = PyTuple_New(niter); + ret = PyTuple_New(nop); if (ret == NULL) { return NULL; } - for (iiter = 0; iiter < niter; ++iiter) { - PyObject *operand = (PyObject *)operands[iiter]; + for (iop = 0; iop < nop; ++iop) { + PyObject *operand = (PyObject *)operands[iop]; Py_INCREF(operand); - PyTuple_SET_ITEM(ret, iiter, operand); + PyTuple_SET_ITEM(ret, iop, operand); } return ret; @@ -1486,7 +1486,7 @@ static PyObject *npyiter_itviews_get(NewNpyArrayIterObject *self) { PyObject *ret; - npy_intp iiter, niter; + npy_intp iop, nop; if (self->iter == NULL) { PyErr_SetString(PyExc_ValueError, @@ -1494,20 +1494,20 @@ static PyObject *npyiter_itviews_get(NewNpyArrayIterObject *self) return NULL; } - niter = NpyIter_GetNIter(self->iter); + nop = NpyIter_GetNOp(self->iter); - ret = PyTuple_New(niter); + ret = PyTuple_New(nop); if (ret == NULL) { return NULL; } - for (iiter = 0; iiter < niter; ++iiter) { - PyArrayObject *view = NpyIter_GetIterView(self->iter, iiter); + for (iop = 0; iop < nop; ++iop) { + PyArrayObject *view = NpyIter_GetIterView(self->iter, iop); if (view == NULL) { Py_DECREF(ret); return NULL; } - PyTuple_SET_ITEM(ret, iiter, (PyObject *)view); + PyTuple_SET_ITEM(ret, iop, (PyObject *)view); } return ret; @@ -1909,7 +1909,7 @@ static PyObject *npyiter_dtypes_get(NewNpyArrayIterObject *self) { PyObject *ret; - npy_intp iiter, niter; + npy_intp iop, nop; PyArray_Descr **dtypes; if (self->iter == NULL) { @@ -1918,18 +1918,18 @@ static PyObject *npyiter_dtypes_get(NewNpyArrayIterObject *self) return NULL; } - niter = NpyIter_GetNIter(self->iter); + nop = NpyIter_GetNOp(self->iter); - ret = PyTuple_New(niter); + ret = PyTuple_New(nop); if (ret == NULL) { return NULL; } dtypes = self->dtypes; - for (iiter = 0; iiter < niter; ++iiter) { - PyArray_Descr *dtype = dtypes[iiter]; + for (iop = 0; iop < nop; ++iop) { + PyArray_Descr *dtype = dtypes[iop]; Py_INCREF(dtype); - PyTuple_SET_ITEM(ret, iiter, (PyObject *)dtype); + PyTuple_SET_ITEM(ret, iop, (PyObject *)dtype); } return ret; @@ -1946,7 +1946,7 @@ static PyObject *npyiter_ndim_get(NewNpyArrayIterObject *self) return PyInt_FromLong(NpyIter_GetNDim(self->iter)); } -static PyObject *npyiter_niter_get(NewNpyArrayIterObject *self) +static PyObject *npyiter_nop_get(NewNpyArrayIterObject *self) { if (self->iter == NULL) { PyErr_SetString(PyExc_ValueError, @@ -1954,7 +1954,7 @@ static PyObject *npyiter_niter_get(NewNpyArrayIterObject *self) return NULL; } - return PyInt_FromLong(NpyIter_GetNIter(self->iter)); + return PyInt_FromLong(NpyIter_GetNOp(self->iter)); } static PyObject *npyiter_itersize_get(NewNpyArrayIterObject *self) @@ -1985,7 +1985,7 @@ npyiter_seq_length(NewNpyArrayIterObject *self) return 0; } else { - return NpyIter_GetNIter(self->iter); + return NpyIter_GetNOp(self->iter); } } @@ -1995,7 +1995,7 @@ npyiter_seq_item(NewNpyArrayIterObject *self, Py_ssize_t i) PyObject *ret; npy_intp ret_ndim; - npy_intp niter, innerloopsize, innerstride; + npy_intp nop, innerloopsize, innerstride; char *dataptr; PyArray_Descr *dtype; @@ -2012,8 +2012,8 @@ npyiter_seq_item(NewNpyArrayIterObject *self, Py_ssize_t i) return NULL; } - niter = NpyIter_GetNIter(self->iter); - if (i < 0 || i >= niter) { + nop = NpyIter_GetNOp(self->iter); + if (i < 0 || i >= nop) { PyErr_Format(PyExc_IndexError, "Iterator operand index %d is out of bounds", (int)i); return NULL; @@ -2067,7 +2067,7 @@ npyiter_seq_slice(NewNpyArrayIterObject *self, Py_ssize_t ilow, Py_ssize_t ihigh) { PyObject *ret; - npy_intp niter; + npy_intp nop; Py_ssize_t i; if (self->iter == NULL || self->finished) { @@ -2083,18 +2083,18 @@ npyiter_seq_slice(NewNpyArrayIterObject *self, return NULL; } - niter = NpyIter_GetNIter(self->iter); + nop = NpyIter_GetNOp(self->iter); if (ilow < 0) { ilow = 0; } - else if (ilow >= niter) { - ilow = niter-1; + else if (ilow >= nop) { + ilow = nop-1; } if (ihigh < ilow) { ihigh = ilow; } - else if (ihigh > niter) { - ihigh = niter; + else if (ihigh > nop) { + ihigh = nop; } ret = PyTuple_New(ihigh-ilow); @@ -2116,7 +2116,7 @@ NPY_NO_EXPORT int npyiter_seq_ass_item(NewNpyArrayIterObject *self, Py_ssize_t i, PyObject *v) { - npy_intp niter, innerloopsize, innerstride; + npy_intp nop, innerloopsize, innerstride; char *dataptr; PyArray_Descr *dtype; PyArrayObject *tmp; @@ -2141,8 +2141,8 @@ npyiter_seq_ass_item(NewNpyArrayIterObject *self, Py_ssize_t i, PyObject *v) return -1; } - niter = NpyIter_GetNIter(self->iter); - if (i < 0 || i >= niter) { + nop = NpyIter_GetNOp(self->iter); + if (i < 0 || i >= nop) { PyErr_Format(PyExc_IndexError, "Iterator operand index %d is out of bounds", (int)i); return -1; @@ -2184,7 +2184,7 @@ static int npyiter_seq_ass_slice(NewNpyArrayIterObject *self, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v) { - npy_intp niter; + npy_intp nop; Py_ssize_t i; if (v == NULL) { @@ -2206,18 +2206,18 @@ npyiter_seq_ass_slice(NewNpyArrayIterObject *self, Py_ssize_t ilow, return -1; } - niter = NpyIter_GetNIter(self->iter); + nop = NpyIter_GetNOp(self->iter); if (ilow < 0) { ilow = 0; } - else if (ilow >= niter) { - ilow = niter-1; + else if (ilow >= nop) { + ilow = nop-1; } if (ihigh < ilow) { ihigh = ilow; } - else if (ihigh > niter) { - ihigh = niter; + else if (ihigh > nop) { + ihigh = nop; } if (!PySequence_Check(v) || PySequence_Size(v) != ihigh-ilow) { @@ -2268,7 +2268,7 @@ npyiter_subscript(NewNpyArrayIterObject *self, PyObject *op) else if (PySlice_Check(op)) { Py_ssize_t istart = 0, iend = 0, istep = 0; if (PySlice_GetIndices((PySliceObject *)op, - NpyIter_GetNIter(self->iter), + NpyIter_GetNOp(self->iter), &istart, &iend, &istep) < 0) { return NULL; } @@ -2313,7 +2313,7 @@ npyiter_ass_subscript(NewNpyArrayIterObject *self, PyObject *op, else if (PySlice_Check(op)) { Py_ssize_t istart = 0, iend = 0, istep = 0; if (PySlice_GetIndices((PySliceObject *)op, - NpyIter_GetNIter(self->iter), + NpyIter_GetNOp(self->iter), &istart, &iend, &istep) < 0) { return -1; } @@ -2395,8 +2395,8 @@ static PyGetSetDef npyiter_getsets[] = { {"ndim", (getter)npyiter_ndim_get, NULL, NULL, NULL}, - {"niter", - (getter)npyiter_niter_get, + {"nop", + (getter)npyiter_nop_get, NULL, NULL, NULL}, {"itersize", (getter)npyiter_itersize_get, diff --git a/numpy/core/src/umath/ufunc_object.c b/numpy/core/src/umath/ufunc_object.c index 59722cef4..8f87e7bff 100644 --- a/numpy/core/src/umath/ufunc_object.c +++ b/numpy/core/src/umath/ufunc_object.c @@ -976,7 +976,7 @@ ufunc_loop_matches(PyUFuncObject *self, char *out_err_src_typecode, char *out_err_dst_typecode) { - npy_intp i, nin = self->nin, niter = nin + self->nout; + npy_intp i, nin = self->nin, nop = nin + self->nout; /* * First check if all the inputs can be safely cast @@ -1035,7 +1035,7 @@ ufunc_loop_matches(PyUFuncObject *self, * If all the inputs were ok, then check casting back to the * outputs. */ - for (i = nin; i < niter; ++i) { + for (i = nin; i < nop; ++i) { if (op[i] != NULL) { PyArray_Descr *tmp = PyArray_DescrFromType(types[i]); if (tmp == NULL) { @@ -1065,11 +1065,11 @@ set_ufunc_loop_data_types(PyUFuncObject *self, PyArrayObject **op, int *types, npy_intp buffersize, int *out_trivial_loop_ok) { - npy_intp i, nin = self->nin, niter = nin + self->nout; + npy_intp i, nin = self->nin, nop = nin + self->nout; *out_trivial_loop_ok = 1; /* Fill the dtypes array */ - for (i = 0; i < niter; ++i) { + for (i = 0; i < nop; ++i) { out_dtype[i] = PyArray_DescrFromType(types[i]); if (out_dtype[i] == NULL) { return -1; @@ -1203,7 +1203,7 @@ find_ufunc_specified_userloop(PyUFuncObject *self, void **out_innerloopdata, int *out_trivial_loop_ok) { - npy_intp i, j, nin = self->nin, niter = nin + self->nout; + npy_intp i, j, nin = self->nin, nop = nin + self->nout; PyUFunc_Loop1d *funcdata; /* Use this to try to avoid repeating the same userdef loop search */ @@ -1233,8 +1233,8 @@ find_ufunc_specified_userloop(PyUFuncObject *self, int *types = funcdata->arg_types; int matched = 1; - if (n_specified == niter) { - for (j = 0; j < niter; ++j) { + if (n_specified == nop) { + for (j = 0; j < nop; ++j) { if (types[j] != specified_types[j]) { matched = 0; break; @@ -1313,7 +1313,7 @@ find_best_ufunc_inner_loop(PyUFuncObject *self, void **out_innerloopdata, int *out_trivial_loop_ok) { - npy_intp i, j, nin = self->nin, niter = nin + self->nout; + npy_intp i, j, nin = self->nin, nop = nin + self->nout; int types[NPY_MAXARGS]; char *ufunc_name; int no_castable_output, all_inputs_scalar; @@ -1370,7 +1370,7 @@ find_best_ufunc_inner_loop(PyUFuncObject *self, char *orig_types = self->types + i*self->nargs; /* Copy the types into an int array for matching */ - for (j = 0; j < niter; ++j) { + for (j = 0; j < nop; ++j) { types[j] = orig_types[j]; } @@ -1448,7 +1448,7 @@ find_specified_ufunc_inner_loop(PyUFuncObject *self, void **out_innerloopdata, int *out_trivial_loop_ok) { - npy_intp i, j, n, nin = self->nin, niter = nin + self->nout; + npy_intp i, j, n, nin = self->nin, nop = nin + self->nout; int n_specified = 0; int specified_types[NPY_MAXARGS], types[NPY_MAXARGS]; char *ufunc_name; @@ -1470,10 +1470,10 @@ find_specified_ufunc_inner_loop(PyUFuncObject *self, /* Fill in specified_types from the tuple or string */ if (PyTuple_Check(type_tup)) { n = PyTuple_GET_SIZE(type_tup); - if (n != 1 && n != niter) { + if (n != 1 && n != nop) { PyErr_Format(PyExc_ValueError, "a type-tuple must be specified " \ - "of length 1 or %d for ufunc '%s'", (int)niter, + "of length 1 or %d for ufunc '%s'", (int)nop, self->name ? self->name : "(unknown)"); return -1; } @@ -1507,7 +1507,7 @@ find_specified_ufunc_inner_loop(PyUFuncObject *self, Py_XDECREF(str_obj); return -1; } - if (length != 1 && (length != niter + 2 || + if (length != 1 && (length != nop + 2 || str[nin] != '-' || str[nin+1] != '>')) { PyErr_Format(PyExc_ValueError, "a type-string for %s, " \ @@ -1534,9 +1534,9 @@ find_specified_ufunc_inner_loop(PyUFuncObject *self, } else { PyArray_Descr *dtype; - n_specified = (int)niter; + n_specified = (int)nop; - for (i = 0; i < niter; ++i) { + for (i = 0; i < nop; ++i) { npy_intp istr = i < nin ? i : i+2; dtype = PyArray_DescrFromType(str[istr]); @@ -1579,12 +1579,12 @@ find_specified_ufunc_inner_loop(PyUFuncObject *self, NPY_UF_DBG_PRINT1("Trying function loop %d\n", (int)i); /* Copy the types into an int array for matching */ - for (j = 0; j < niter; ++j) { + for (j = 0; j < nop; ++j) { types[j] = orig_types[j]; } - if (n_specified == niter) { - for (j = 0; j < niter; ++j) { + if (n_specified == nop) { + for (j = 0; j < nop; ++j) { if (types[j] != specified_types[j]) { matched = 0; break; @@ -1783,7 +1783,7 @@ iterator_loop(PyUFuncObject *self, void *innerloopdata) { npy_intp i, nin = self->nin, nout = self->nout; - npy_intp niter = nin + nout; + npy_intp nop = nin + nout; npy_uint32 op_flags[NPY_MAXARGS]; NpyIter *iter; char *baseptrs[NPY_MAXARGS]; @@ -1803,7 +1803,7 @@ iterator_loop(PyUFuncObject *self, op_flags[i] = NPY_ITER_READONLY| NPY_ITER_ALIGNED; } - for (i = nin; i < niter; ++i) { + for (i = nin; i < nop; ++i) { op_flags[i] = NPY_ITER_WRITEONLY| NPY_ITER_ALIGNED| NPY_ITER_ALLOCATE| @@ -1816,7 +1816,7 @@ iterator_loop(PyUFuncObject *self, * were already checked, we use the casting rule 'unsafe' which * is faster to calculate. */ - iter = NpyIter_AdvancedNew(niter, op, + iter = NpyIter_AdvancedNew(nop, op, NPY_ITER_EXTERNAL_LOOP| NPY_ITER_REFS_OK| NPY_ITER_ZEROSIZE_OK| @@ -1834,7 +1834,7 @@ iterator_loop(PyUFuncObject *self, /* Copy any allocated outputs */ op_it = NpyIter_GetOperandArray(iter); - for (i = nin; i < niter; ++i) { + for (i = nin; i < nop; ++i) { if (op[i] == NULL) { op[i] = op_it[i]; Py_INCREF(op[i]); @@ -1857,7 +1857,7 @@ iterator_loop(PyUFuncObject *self, for (i = 0; i < nin; ++i) { baseptrs[i] = PyArray_BYTES(op_it[i]); } - for (i = nin; i < niter; ++i) { + for (i = nin; i < nop; ++i) { baseptrs[i] = PyArray_BYTES(op[i]); } if (NpyIter_ResetBasePointers(iter, baseptrs, NULL) != NPY_SUCCEED) { @@ -2074,7 +2074,7 @@ PyUFunc_GeneralizedFunction(PyUFuncObject *self, PyArrayObject **op) { int nin, nout; - int i, idim, niter; + int i, idim, nop; char *ufunc_name; int retval = -1, any_object = 0, subok = 1; NPY_CASTING input_casting; @@ -2134,14 +2134,14 @@ PyUFunc_GeneralizedFunction(PyUFuncObject *self, nin = self->nin; nout = self->nout; - niter = nin + nout; + nop = nin + nout; ufunc_name = self->name ? self->name : "<unnamed ufunc>"; NPY_UF_DBG_PRINT1("\nEvaluating ufunc %s\n", ufunc_name); /* Initialize all the operands and dtypes to NULL */ - for (i = 0; i < niter; ++i) { + for (i = 0; i < nop; ++i) { op[i] = NULL; dtype[i] = NULL; arr_prep[i] = NULL; @@ -2176,7 +2176,7 @@ PyUFunc_GeneralizedFunction(PyUFuncObject *self, /* Fill in op_axes for all the operands */ core_dim_ixs_size = 0; core_dim_ixs = self->core_dim_ixs; - for (i = 0; i < niter; ++i) { + for (i = 0; i < nop; ++i) { int n; if (op[i]) { /* @@ -2281,7 +2281,7 @@ PyUFunc_GeneralizedFunction(PyUFuncObject *self, printf(" "); } printf("\noutput types:\n"); - for (i = nin; i < niter; ++i) { + for (i = nin; i < nop; ++i) { PyObject_Print((PyObject *)dtype[i], stdout, 0); printf(" "); } @@ -2318,7 +2318,7 @@ PyUFunc_GeneralizedFunction(PyUFuncObject *self, NPY_ITER_COPY| NPY_ITER_ALIGNED; } - for (i = nin; i < niter; ++i) { + for (i = nin; i < nop; ++i) { op_flags[i] = NPY_ITER_READWRITE| NPY_ITER_UPDATEIFCOPY| NPY_ITER_ALIGNED| @@ -2327,7 +2327,7 @@ PyUFunc_GeneralizedFunction(PyUFuncObject *self, } /* Create the iterator */ - iter = NpyIter_AdvancedNew(niter, op, NPY_ITER_MULTI_INDEX| + iter = NpyIter_AdvancedNew(nop, op, NPY_ITER_MULTI_INDEX| NPY_ITER_REFS_OK| NPY_ITER_REDUCE_OK, order, NPY_UNSAFE_CASTING, op_flags, @@ -2338,7 +2338,7 @@ PyUFunc_GeneralizedFunction(PyUFuncObject *self, } /* Fill in any allocated outputs */ - for (i = nin; i < niter; ++i) { + for (i = nin; i < nop; ++i) { if (op[i] == NULL) { op[i] = NpyIter_GetOperandArray(iter)[i]; Py_INCREF(op[i]); @@ -2350,10 +2350,10 @@ PyUFunc_GeneralizedFunction(PyUFuncObject *self, * buffering, the strides are fixed throughout the looping. */ inner_strides = (npy_intp *)_pya_malloc( - NPY_SIZEOF_INTP * (niter+core_dim_ixs_size)); - /* The strides after the first niter match core_dim_ixs */ + NPY_SIZEOF_INTP * (nop+core_dim_ixs_size)); + /* The strides after the first nop match core_dim_ixs */ core_dim_ixs = self->core_dim_ixs; - inner_strides_tmp = inner_strides + niter; + inner_strides_tmp = inner_strides + nop; for (idim = 0; idim < self->core_num_dim_ix; ++idim) { ax_strides_tmp[idim] = NpyIter_GetAxisStrideArray(iter, broadcast_ndim+idim); @@ -2362,7 +2362,7 @@ PyUFunc_GeneralizedFunction(PyUFuncObject *self, goto fail; } } - for (i = 0; i < niter; ++i) { + for (i = 0; i < nop; ++i) { for (idim = 0; idim < self->core_num_dims[i]; ++idim) { inner_strides_tmp[idim] = ax_strides_tmp[core_dim_ixs[idim]][i]; } @@ -2397,15 +2397,15 @@ PyUFunc_GeneralizedFunction(PyUFuncObject *self, } /* - * The first niter strides are for the inner loop (but only can + * The first nop strides are for the inner loop (but only can * copy them after removing the core axes */ memcpy(inner_strides, NpyIter_GetInnerStrideArray(iter), - NPY_SIZEOF_INTP * niter); + NPY_SIZEOF_INTP * nop); #if 0 printf("strides: "); - for (i = 0; i < niter+core_dim_ixs_size; ++i) { + for (i = 0; i < nop+core_dim_ixs_size; ++i) { printf("%d ", (int)inner_strides[i]); } printf("\n"); @@ -2448,7 +2448,7 @@ PyUFunc_GeneralizedFunction(PyUFuncObject *self, _pya_free(inner_strides); NpyIter_Deallocate(iter); /* The caller takes ownership of all the references in op */ - for (i = 0; i < niter; ++i) { + for (i = 0; i < nop; ++i) { Py_XDECREF(dtype[i]); Py_XDECREF(arr_prep[i]); } @@ -2468,7 +2468,7 @@ fail: if (iter != NULL) { NpyIter_Deallocate(iter); } - for (i = 0; i < niter; ++i) { + for (i = 0; i < nop; ++i) { Py_XDECREF(op[i]); op[i] = NULL; Py_XDECREF(dtype[i]); @@ -2492,7 +2492,7 @@ PyUFunc_GenericFunction(PyUFuncObject *self, PyArrayObject **op) { int nin, nout; - int i, niter; + int i, nop; char *ufunc_name; int retval = -1, any_object = 0, subok = 1; NPY_CASTING input_casting; @@ -2541,14 +2541,14 @@ PyUFunc_GenericFunction(PyUFuncObject *self, nin = self->nin; nout = self->nout; - niter = nin + nout; + nop = nin + nout; ufunc_name = self->name ? self->name : "<unnamed ufunc>"; NPY_UF_DBG_PRINT1("\nEvaluating ufunc %s\n", ufunc_name); /* Initialize all the operands and dtypes to NULL */ - for (i = 0; i < niter; ++i) { + for (i = 0; i < nop; ++i) { op[i] = NULL; dtype[i] = NULL; arr_prep[i] = NULL; @@ -2629,7 +2629,7 @@ PyUFunc_GenericFunction(PyUFuncObject *self, printf(" "); } printf("\noutput types:\n"); - for (i = nin; i < niter; ++i) { + for (i = nin; i < nop; ++i) { PyObject_Print((PyObject *)dtype[i], stdout, 0); printf(" "); } @@ -2678,7 +2678,7 @@ PyUFunc_GenericFunction(PyUFuncObject *self, } /* The caller takes ownership of all the references in op */ - for (i = 0; i < niter; ++i) { + for (i = 0; i < nop; ++i) { Py_XDECREF(dtype[i]); Py_XDECREF(arr_prep[i]); } @@ -2692,7 +2692,7 @@ PyUFunc_GenericFunction(PyUFuncObject *self, fail: NPY_UF_DBG_PRINT1("Returning failure code %d\n", retval); - for (i = 0; i < niter; ++i) { + for (i = 0; i < nop; ++i) { Py_XDECREF(op[i]); op[i] = NULL; Py_XDECREF(dtype[i]); |