-
-
Notifications
You must be signed in to change notification settings - Fork 12.2k
loadtxt reads floats in as float32 instead of float64 under certain cicumstances (Trac #1589) #2185
Copy link
Copy link
Closed
Labels
00 - BugPriority: highHigh priority, also add milestones for urgent issuesHigh priority, also add milestones for urgent issuescomponent: Other
Milestone
Description
Original ticket http://projects.scipy.org/numpy/ticket/1589 on 2010-08-21 by @astrofrog, assigned to unknown.
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)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
00 - BugPriority: highHigh priority, also add milestones for urgent issuesHigh priority, also add milestones for urgent issuescomponent: Other