Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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.
  • Loading branch information...
commit 6385069225f95dd2070c5cbb86ede8e2d6c90811 1 parent 2acf028
Mark Wiebe mwiebe authored
48 doc/source/reference/c-api.iterator.rst
View
@@ -323,9 +323,9 @@ Construction and Destruction
dtype);
Py_DECREF(dtype);
-.. cfunction:: NpyIter* NpyIter_MultiNew(npy_intp niter, PyArrayObject** op, npy_uint32 flags, NPY_ORDER order, NPY_CASTING casting, npy_uint32* op_flags, PyArray_Descr** op_dtypes)
+.. cfunction:: NpyIter* NpyIter_MultiNew(npy_intp nop, PyArrayObject** op, npy_uint32 flags, NPY_ORDER order, NPY_CASTING casting, npy_uint32* op_flags, PyArray_Descr** op_dtypes)
- Creates an iterator for broadcasting the ``niter`` array objects provided
+ Creates an iterator for broadcasting the ``nop`` array objects provided
in ``op``, using regular NumPy broadcasting rules.
Any of the :ctype:`NPY_ORDER` enum values may be passed to ``order``. For
@@ -494,7 +494,7 @@ Construction and Destruction
Then, call :cfunc:`NpyIter_Reset` to allocate and fill the buffers
with their initial values.
- Flags that may be passed in ``op_flags[i]``, where ``0 <= i < niter``:
+ Flags that may be passed in ``op_flags[i]``, where ``0 <= i < nop``:
.. cvar:: NPY_ITER_READWRITE
.. cvar:: NPY_ITER_READONLY
@@ -579,7 +579,7 @@ Construction and Destruction
Ensures that the input or output matches the iteration
dimensions exactly.
-.. cfunction:: NpyIter* NpyIter_AdvancedNew(npy_intp niter, PyArrayObject** op, npy_uint32 flags, NPY_ORDER order, NPY_CASTING casting, npy_uint32* op_flags, PyArray_Descr** op_dtypes, int oa_ndim, int** op_axes, npy_intp* itershape, npy_intp buffersize)
+.. cfunction:: NpyIter* NpyIter_AdvancedNew(npy_intp nop, PyArrayObject** op, npy_uint32 flags, NPY_ORDER order, NPY_CASTING casting, npy_uint32* op_flags, PyArray_Descr** op_dtypes, int oa_ndim, int** op_axes, npy_intp* itershape, npy_intp buffersize)
Extends :cfunc:`NpyIter_MultiNew` with several advanced options providing
more control over broadcasting and buffering.
@@ -592,7 +592,7 @@ Construction and Destruction
If it is provided, ``op_axes`` and/or ``itershape`` must also be provided.
The ``op_axes`` parameter let you control in detail how the
axes of the operand arrays get matched together and iterated.
- In ``op_axes``, you must provide an array of ``niter`` pointers
+ In ``op_axes``, you must provide an array of ``nop`` pointers
to ``oa_ndim``-sized arrays of type ``npy_intp``. If an entry
in ``op_axes`` is NULL, normal broadcasting rules will apply.
In ``op_axes[j][i]`` is stored either a valid axis of ``op[j]``, or
@@ -906,7 +906,7 @@ Construction and Destruction
may be smaller than the number of dimensions in the original
objects.
-.. cfunction:: int NpyIter_GetNIter(NpyIter* iter)
+.. cfunction:: int NpyIter_GetNOp(NpyIter* iter)
Returns the number of operands in the iterator.
@@ -933,7 +933,7 @@ Construction and Destruction
.. cfunction:: PyArray_Descr** NpyIter_GetDescrArray(NpyIter* iter)
- This gives back a pointer to the ``niter`` data type Descrs for
+ This gives back a pointer to the ``nop`` data type Descrs for
the objects being iterated. The result points into ``iter``,
so the caller does not gain any references to the Descrs.
@@ -942,7 +942,7 @@ Construction and Destruction
.. cfunction:: PyObject** NpyIter_GetOperandArray(NpyIter* iter)
- This gives back a pointer to the ``niter`` operand PyObjects
+ This gives back a pointer to the ``nop`` operand PyObjects
that are being iterated. The result points into ``iter``,
so the caller does not gain any references to the PyObjects.
@@ -961,12 +961,12 @@ Construction and Destruction
.. cfunction:: void NpyIter_GetReadFlags(NpyIter* iter, char* outreadflags)
- Fills ``niter`` flags. Sets ``outreadflags[i]`` to 1 if
+ Fills ``nop`` flags. Sets ``outreadflags[i]`` to 1 if
``op[i]`` can be read from, and to 0 if not.
.. cfunction:: void NpyIter_GetWriteFlags(NpyIter* iter, char* outwriteflags)
- Fills ``niter`` flags. Sets ``outwriteflags[i]`` to 1 if
+ Fills ``nop`` flags. Sets ``outwriteflags[i]`` to 1 if
``op[i]`` can be written to, and to 0 if not.
.. cfunction:: int NpyIter_CreateCompatibleStrides(NpyIter* iter, npy_intp itemsize, npy_intp* outstrides)
@@ -1021,7 +1021,7 @@ Functions For Iteration
char** dataptr = NpyIter_GetDataPtrArray(iter);
do {
- /* use the addresses dataptr[0], ... dataptr[niter-1] */
+ /* use the addresses dataptr[0], ... dataptr[nop-1] */
} while(iternext(iter));
When :cdata:`NPY_ITER_EXTERNAL_LOOP` is specified, the typical
@@ -1033,14 +1033,14 @@ Functions For Iteration
char** dataptr = NpyIter_GetDataPtrArray(iter);
npy_intp* stride = NpyIter_GetInnerStrideArray(iter);
npy_intp* size_ptr = NpyIter_GetInnerLoopSizePtr(iter), size;
- npy_intp iiter, niter = NpyIter_GetNIter(iter);
+ npy_intp iop, nop = NpyIter_GetNOp(iter);
do {
size = *size_ptr;
while (size--) {
- /* use the addresses dataptr[0], ... dataptr[niter-1] */
- for (iiter = 0; iiter < niter; ++iiter) {
- dataptr[iiter] += stride[iiter];
+ /* use the addresses dataptr[0], ... dataptr[nop-1] */
+ for (iop = 0; iop < nop; ++iop) {
+ dataptr[iop] += stride[iop];
}
}
} while (iternext());
@@ -1067,7 +1067,7 @@ Functions For Iteration
char **dataptr = NpyIter_GetDataPtrArray(iter);
npy_intp *stride = NpyIter_GetInnerStrideArray(iter);
npy_intp *size_ptr = NpyIter_GetInnerLoopSizePtr(iter), size;
- npy_intp i, iiter, niter = NpyIter_GetNIter(iter);
+ npy_intp i, iop, nop = NpyIter_GetNOp(iter);
/* One loop with a fixed inner size */
size = *size_ptr;
@@ -1077,9 +1077,9 @@ Functions For Iteration
* which divides into FIXED_BUFFER_SIZE
*/
for (i = 0; i < FIXED_BUFFER_SIZE; ++i) {
- /* use the addresses dataptr[0], ... dataptr[niter-1] */
- for (iiter = 0; iiter < niter; ++iiter) {
- dataptr[iiter] += stride[iiter];
+ /* use the addresses dataptr[0], ... dataptr[nop-1] */
+ for (iop = 0; iop < nop; ++iop) {
+ dataptr[iop] += stride[iop];
}
}
iternext();
@@ -1090,9 +1090,9 @@ Functions For Iteration
if (size > 0) do {
size = *size_ptr;
while (size--) {
- /* use the addresses dataptr[0], ... dataptr[niter-1] */
- for (iiter = 0; iiter < niter; ++iiter) {
- dataptr[iiter] += stride[iiter];
+ /* use the addresses dataptr[0], ... dataptr[nop-1] */
+ for (iop = 0; iop < nop; ++iop) {
+ dataptr[iop] += stride[iop];
}
}
} while (iternext());
@@ -1113,7 +1113,7 @@ Functions For Iteration
.. cfunction:: char** NpyIter_GetDataPtrArray(NpyIter* iter)
- This gives back a pointer to the ``niter`` data pointers. If
+ This gives back a pointer to the ``nop`` data pointers. If
:cdata:`NPY_ITER_EXTERNAL_LOOP` was not specified, each data
pointer points to the current data item of the iterator. If
no inner iteration was specified, it points to the first data
@@ -1147,7 +1147,7 @@ functions provide that information.
.. cfunction:: npy_intp* NpyIter_GetInnerStrideArray(NpyIter* iter)
- Returns a pointer to an array of the ``niter`` strides,
+ Returns a pointer to an array of the ``nop`` strides,
one for each iterated object, to be used by the inner loop.
This pointer may be cached before the iteration loop, calling
2  numpy/add_newdocs.py
View
@@ -266,7 +266,7 @@
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.
2  numpy/core/code_generators/numpy_api.py
View
@@ -271,7 +271,7 @@
'NpyIter_ResetBasePointers': 235,
'NpyIter_ResetToIterIndexRange': 236,
'NpyIter_GetNDim': 237,
- 'NpyIter_GetNIter': 238,
+ 'NpyIter_GetNOp': 238,
'NpyIter_GetIterNext': 239,
'NpyIter_GetIterSize': 240,
'NpyIter_GetIterIndexRange': 241,
1,432 numpy/core/src/multiarray/nditer.c.src
View
716 additions, 716 deletions not shown
322 numpy/core/src/multiarray/nditer_pywrap.c
View
@@ -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 @@ npyiter_convert_op_flags_array(PyObject *op_flags_in,
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 @@ npyiter_convert_op_flags_array(PyObject *op_flags_in,
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 @@ npyiter_convert_dtypes(PyObject *op_dtypes_in,
}
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 @@ npyiter_init(NewNpyArrayIterObject *self, PyObject *args, PyObject *kwds)
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,
92 numpy/core/src/umath/ufunc_object.c
View
@@ -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 @@ PyUFunc_GeneralizedFunction(PyUFuncObject *self,
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]);
Please sign in to comment.
Something went wrong with that request. Please try again.