From: Robert K. <rob...@gm...> - 2006-11-13 04:28:26
|
Pierre GM wrote: > On Sunday 12 November 2006 20:10, Erin Sheldon wrote: >> Actually, there is a problem with that approach. It first converts >> the entire array to a single type, by default a floating type. > > As A.M. Archibald suggested, you can use list comprehension: > N.array([(a,b,c,d,) for (a,b,c,d) in yourlist], dtype=yourdesc) > > or > > N.fromiter(((a,b,c,d) for (a,b,c,d,) in yourlist), dtype=yourdesc) > > Would you mind trying that, and let us know which one works best ? That could > be put on the wiki somewhere... N.array(map(tuple, yourlist), dtype=yourdesc) is probably the best option. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco |