Re: [Numpy-discussion] Initializing an array to a constant value

2012-02-13 Thread Pierre Haessig
Le 13/02/2012 19:17, eat a écrit : > wouldn't it be nice if you could just write: > a= np.empty(shape).fill(A) > this would be possible if .fill(.) just returned self. Thanks for the tip. I noticed several times this was not working (because of course, in the mean time, I forgot it...) but I had to

Re: [Numpy-discussion] Initializing an array to a constant value

2012-02-13 Thread eat
Hi, A slightly OT (and not directly answering to your question), but On Mon, Feb 13, 2012 at 3:30 PM, Pierre Haessig wrote: > I have a pretty silly question about initializing an array a to a given > scalar value, say A. > > Most of the time I use a=np.ones(shape)*A which seems the most > widesp

[Numpy-discussion] Initializing an array to a constant value

2012-02-13 Thread Pierre Haessig
I have a pretty silly question about initializing an array a to a given scalar value, say A. Most of the time I use a=np.ones(shape)*A which seems the most widespread idiom, but I got recently interested in getting some performance improvement. I tried a=np.zeros(shape)+A, based on broadcastin