accumulating version of numpy.put?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

accumulating version of numpy.put?

FrankHorowitz
Hi All,

In the numpy library, are there any equivalences of numpy.put to additively store the values rather than simply overwriting?

Alternatively, would there be significant speed penalties to code of the form

a.flat[ind] += v

Thanks in advance for any help you might be able to provide!

Frank Horowitz

_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: accumulating version of numpy.put?

Eric Wieser

Frank,

I think you’re looking for np.add.at(a, ind, v), documented here

Eric


On Fri, 19 May 2017 at 17:13 Frank Horowitz <[hidden email]> wrote:
Hi All,

In the numpy library, are there any equivalences of numpy.put to additively store the values rather than simply overwriting?

Alternatively, would there be significant speed penalties to code of the form

a.flat[ind] += v

Thanks in advance for any help you might be able to provide!

Frank Horowitz

_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion

_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: accumulating version of numpy.put?

FrankHorowitz
This post has NOT been accepted by the mailing list yet.
Eric Wieser wrote
Frank,

I think you’re looking for np.add.at(a, ind, v), documented here
<https://docs.scipy.org/doc/numpy/reference/generated/numpy.ufunc.at.html>

Eric
Yes indeed! Thanks for the help!

Frank
Loading...