summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorJay Bourque <jay.bourque@continuum.io>2012-10-04 17:27:36 -0500
committerJay Bourque <jay.bourque@continuum.io>2013-08-16 16:38:48 -0500
commit025a056fc905d3f34088fbdac366dc9667b20f9a (patch)
treefef52f73c04015843ffc64c2d053f50d3c4f7d89 /numpy
parent7191df063cb598e917407b6b805c620f3dee15e2 (diff)
downloadnumpy-025a056fc905d3f34088fbdac366dc9667b20f9a.tar.gz
Add comments
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/umath/ufunc_object.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/numpy/core/src/umath/ufunc_object.c b/numpy/core/src/umath/ufunc_object.c
index fe26cf672..ff71702b8 100644
--- a/numpy/core/src/umath/ufunc_object.c
+++ b/numpy/core/src/umath/ufunc_object.c
@@ -4849,6 +4849,7 @@ ufunc_reduceat(PyUFuncObject *ufunc, PyObject *args, PyObject *kwds)
return PyUFunc_GenericReduction(ufunc, args, kwds, UFUNC_REDUCEAT);
}
+/* Call ufunc only on selected array items and store result in first operand */
static PyObject *
ufunc_select(PyUFuncObject *ufunc, PyObject *args, PyObject *kwds)
{
@@ -4897,6 +4898,7 @@ ufunc_select(PyUFuncObject *ufunc, PyObject *args, PyObject *kwds)
PyArray_MapIterBind(iter, op1_array);
PyArray_MapIterReset(iter);
+ /* If second operand is an array, create MapIter object for it */
if (op2 != NULL && PyArray_Check(op2)) {
op2_array = (PyArrayObject *)PyArray_FromAny(op2, NULL, 0, 0, 0, NULL);
if (op2_array == NULL) {
@@ -4911,6 +4913,7 @@ ufunc_select(PyUFuncObject *ufunc, PyObject *args, PyObject *kwds)
PyArray_MapIterBind(iter2, op2_array);
PyArray_MapIterReset(iter2);
}
+ /* If second operand is a scalar, create 0 dim array from it */
else if (op2 != NULL && PyArray_IsAnyScalar(op2)) {
op2_array = (PyArrayObject *)PyArray_FromAny(op2, NULL, 0, 0, 0, NULL);
if (op2_array == NULL) {
@@ -4927,6 +4930,8 @@ ufunc_select(PyUFuncObject *ufunc, PyObject *args, PyObject *kwds)
return NULL;
}
+ /* Create dtypes array for either one or two input operands.
+ * The output operand is set to the first input operand */
dtypes[0] = PyArray_DESCR(op1_array);
if (op2_array != NULL) {
dtypes[1] = PyArray_DESCR(op2_array);
@@ -4945,11 +4950,13 @@ ufunc_select(PyUFuncObject *ufunc, PyObject *args, PyObject *kwds)
count[0] = 1;
stride[0] = 1;
+ /* Loop through all indices and call ufunc for each index */
i = iter->size;
while (i > 0)
{
+ /* Set up data pointers for either one or two input operands.
+ * The output data pointer points to the first operand data */
dataptr[0] = iter->dataptr;
-
if (iter2 != NULL) {
dataptr[1] = iter2->dataptr;
dataptr[2] = iter->dataptr;