Re: [Numpy-discussion] adding field to rec array

2007-10-05 Thread John Hunter
On 9/26/07, Robert Kern [EMAIL PROTECTED] wrote: Here is the straightforward way: In [15]: import numpy as np In [16]: dt = np.dtype([('foo', int), ('bar', float)]) In [17]: r = np.zeros((3,3), dtype=dt) Here is a (hopefully) simple question. If I create an array like this, how can I

Re: [Numpy-discussion] adding field to rec array

2007-10-05 Thread Robert Kern
John Hunter wrote: On 9/26/07, Robert Kern [EMAIL PROTECTED] wrote: Here is the straightforward way: In [15]: import numpy as np In [16]: dt = np.dtype([('foo', int), ('bar', float)]) In [17]: r = np.zeros((3,3), dtype=dt) Here is a (hopefully) simple question. If I create an array

Re: [Numpy-discussion] adding field to rec array

2007-09-26 Thread Robert Kern
John Hunter wrote: I have a record array r and I want to add a new field to it. I have been looking at setfield but I am not sure how to use it for this purpose. Eg # r is some npy record array N = len(r) x = npy.zeros(N) # add array of floats x to r with dtype name 'jdh' and type 'f8'