Re: [Numpy-discussion] dtype reduction

2012-12-27 Thread Nicolas Rougier
Yep, I'm trying to construct dtype2 programmaticaly and was hoping for some function giving me a canonical expression of the dtype. I've started playing with fields but it's just a bit harder than I though (lot of different cases and recursion). Thanks for the answer. Nicolas On Dec 27,

[Numpy-discussion] Pre-allocate array

2012-12-27 Thread Nikolaus Rath
Hello, I have an array that I know will need to grow to X elements. However, I will need to work with it before it's completely filled. I see two ways of doing this: bigarray = np.empty(X) current_size = 0 for i in something: buf = produce_data(i)

Re: [Numpy-discussion] Pre-allocate array

2012-12-27 Thread Chris Barker - NOAA Federal
On Thu, Dec 27, 2012 at 8:44 AM, Nikolaus Rath nikol...@rath.org wrote: I have an array that I know will need to grow to X elements. However, I will need to work with it before it's completely filled. what sort of work with it do you mean? -- resize() is dangerous if there are any other views

[Numpy-discussion] Manipulate neighboring points in 2D array

2012-12-27 Thread deb
Hi, I have 2D array, let's say: `np.random.random((100,100))` and I want to do simple manipulation on each point neighbors, like divide their values by 3. So for each array value, x, and it neighbors n: n n nn/3 n/3 n/3 n x n - n/3 x n/3 n n nn/3 n/3 n/3 I searched a bit, and found

Re: [Numpy-discussion] numpy.testing.asserts and masked array

2012-12-27 Thread Ralf Gommers
On Thu, Dec 27, 2012 at 12:23 AM, Chao YUE chaoyue...@gmail.com wrote: Dear all, I found here http://mail.scipy.org/pipermail/numpy-discussion/2009-January/039681.html that to use* numpy.ma.testutils.assert_almost_equal* for masked array assertion, but I cannot find the np.ma.testutils

Re: [Numpy-discussion] numpy.testing.asserts and masked array

2012-12-27 Thread Chao YUE
Thanks. I tried again, it works. On Thu, Dec 27, 2012 at 10:35 PM, Ralf Gommers ralf.gomm...@gmail.comwrote: from numpy.ma import testutils -- *** Chao YUE Laboratoire des Sciences du Climat et de

Re: [Numpy-discussion] Manipulate neighboring points in 2D array

2012-12-27 Thread Zachary Pincus
I have 2D array, let's say: `np.random.random((100,100))` and I want to do simple manipulation on each point neighbors, like divide their values by 3. So for each array value, x, and it neighbors n: n n nn/3 n/3 n/3 n x n - n/3 x n/3 n n nn/3 n/3 n/3 I searched a bit, and