[Numpy-discussion] Would a patch with a function for incrementing an array with advanced indexing be accepted?

John Salvatier jsalvati at u.washington.edu
Tue Jun 26 12:46:46 EDT 2012


If you increment an array using advanced indexing and have repeated
indexes, the array doesn't get repeatedly incremented,
http://comments.gmane.org/gmane.comp.python.numeric.general/50291. I wrote
a C function that does incrementing with repeated indexes correctly. The
branch is here (https://github.com/jsalvatier/numpy see the last two
commits). Would a patch with a cleaned up version of a function like this
be accepted into numpy? I'm not experienced writing numpy C code so I'm
sure it still needs improvement.

If you compile and install that branch, you can test the code using:

from numpy import *
from numpy.core.multiarray import index_increment

a = arange(12).reshape((3,4))
index = ([1,1,2,0], [0,0,2,3])
vals = [50,50., 30.,16]

b = index_increment(a, index, vals)

print b

should print out:
 [[   0.    1.    2.   19.]
 [ 104.    5.    6.    7.]
 [   8.    9.   40.   11.]]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20120626/dfc7ccaa/attachment.html>

More information about the NumPy-Discussion mailing list