array from list of lists

A. M. Archibald peridot.faceted at gmail.com
Sun Nov 12 21:18:19 CST 2006


On 12/11/06, Erin Sheldon <erin.sheldon at gmail.com> wrote:

> Actually, there is a problem with that approach.  It first converts
> the entire array to a single type, by default a floating type.  For
> very large integers this precision is insufficient.  For example, I
> have the following integer in my arrays:
>  94137100072000193L
> which ends up as
>   94137100072000192
> after going to a float and then back to an integer.

That's an unfortunate limitation of numpy; it views double-precision
floats as higher precision than 64-bit integers, but of course they
aren't. If you want to put all your data in a record array, you could
try transposing the lists using a list comprehension - numpy is not
always as much faster than pure python as it looks. You could then
convert that to a list of four arrays and do the assignment as
appropriate. Alternatively, you could convert your array into a
higher-precision floating-point format (if one is available on your
machine) before transposing and storing in a record array.

A. M. Archibald

-------------------------------------------------------------------------
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




More information about the Numpy-discussion mailing list