[NumPy-Tickets] [NumPy] #1589: loadtxt reads floats in as float32 instead of float64 under certain cicumstances

NumPy Trac numpy-tickets@scipy....
Sat Aug 21 12:42:09 CDT 2010


#1589: loadtxt reads floats in as float32 instead of float64 under certain
cicumstances
------------------------+---------------------------------------------------
 Reporter:  robitaille  |       Owner:  somebody
     Type:  defect      |      Status:  new     
 Priority:  high        |   Milestone:  2.0.0   
Component:  Other       |     Version:  devel   
 Keywords:              |  
------------------------+---------------------------------------------------
 I have a file called data.txt with the following contents:

 {{{
 $ cat data.txt
 -9.9999999961922814E-01
 -9.9999999996192290E-01
 -9.9999999999619227E-01
 -9.9999999999961919E-01
 -9.9999999999996192E-01
 -9.9999999999999611E-01
 -1.0000000000000000E+00
 }}}

 If I try and read this in using loadtxt, which should read numbers in
 using (64-bit) float by default, I get:

 {{{
 Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29)
 [GCC 4.2.1 (Apple Inc. build 5646)] on darwin
 Type "help", "copyright", "credits" or "license" for more information.
 >>> import numpy as np
 >>> np.__version__
 '2.0.0.dev8657'
 >>> np.loadtxt('data.txt')
 array([-1., -1., -1., -1., -1., -1., -1.])
 }}}

 If I now create a file called data2.txt with only the first line:

 {{{
 $ cat data2.txt
 -9.9999999961922814E-01
 }}}

 loadtxt works correctly:

 {{{
 Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29)
 [GCC 4.2.1 (Apple Inc. build 5646)] on darwin
 Type "help", "copyright", "credits" or "license" for more information.
 >>> import numpy as np
 >>> np.__version__
 '2.0.0.dev8657'
 >>> np.loadtxt('data2.txt')
 array(-0.99999999961922814)
 }}}

-- 
Ticket URL: <http://projects.scipy.org/numpy/ticket/1589>
NumPy <http://projects.scipy.org/numpy>
My example project


More information about the NumPy-Tickets mailing list