Pierre GM wrote: > Folks, > What is the easiest way to define a recarray of arrays ? > For example, I'd need something like that: > Given three arrays > >>>> x = N.arange(5) >>>> y = x+1 >>>> z = N.sqrt(x) >>>> > and a list of names: > >>>> n = ['x','y','z'] >>>> > Define a 3-record array with two fields: the first one being a ndarray (in x, > y or), the second a string (in n). > > I'm a bit at loss with the definition of the corresponding dtype... >
I'm a little unclear one what you want. Here is a data-type whose first field is a name and whose second field is a 5-element array: dt = N.dtype([('name', 'S10'), ('data', float, (5,))]) Then: a = array([('x',x),('y',y),('z',z)],dt) gives array([('x', [0.0, 1.0, 2.0, 3.0, 4.0]), ('y', [1.0, 2.0, 3.0, 4.0, 5.0]), ('z', [0.0, 1.0, 1.4142135623730951, 1.7320508075688772, 2.0])], dtype=[('name', '|S10'), ('data', '<f8', (5,))]) -Travis ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion