diff options
-rw-r--r-- | numpy/add_newdocs.py | 13 | ||||
-rw-r--r-- | numpy/core/src/umath/ufunc_object.c | 2 |
2 files changed, 9 insertions, 6 deletions
diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index adfbc5b5a..e630ae921 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -5820,11 +5820,14 @@ add_newdoc('numpy.core', 'ufunc', ('at', at(a, indices, b=None) Performs operation in place on array for items specified by indices. - Items can be listed more than once and operation will be performed - on result of operation on previous item. - - Equivalent to a[indices] += b for addition ufunc, except that results - are accumulated for indices listed more than once. + For addition ufunc, this method is equivalent to a[indices] += b, + except that results are accumulated for indices listed more than once. + This solves the problem with a[indices] += b where each time a duplicate + index is encounted, the increment is performed on the original element. + As a result, an element that appears three times in the fancy indexing + list will only be incremented once in the final result, whereas with the + new 'at' method the original element will be incremented by three in the + final result. Parameters ---------- diff --git a/numpy/core/src/umath/ufunc_object.c b/numpy/core/src/umath/ufunc_object.c index e7de6d379..dadf86e28 100644 --- a/numpy/core/src/umath/ufunc_object.c +++ b/numpy/core/src/umath/ufunc_object.c @@ -4953,7 +4953,7 @@ ufunc_at(PyUFuncObject *ufunc, PyObject *args, PyObject *kwds) /* * Be sure values array is "broadcastable" - * to shape of mit->dimensions, mit->nd + * to shape of iter->dimensions, iter->nd */ if ((iter2 = (PyArrayIterObject *)\ PyArray_BroadcastToShape((PyObject *)op2_array, |