diff options
author | Anne Archibald <archibald@astron.nl> | 2015-08-12 17:46:14 +0200 |
---|---|---|
committer | Anne Archibald <archibald@astron.nl> | 2015-08-28 15:52:42 +0200 |
commit | 6cbd724f75f25cdaa7cf68fd9743064b77fbf787 (patch) | |
tree | 816e86d5806f60c9e2bd618fe3874a6bec373e10 /numpy/lib/npyio.py | |
parent | b478ded953395fee6182439ff5e8eb38fd4271ce (diff) | |
download | numpy-6cbd724f75f25cdaa7cf68fd9743064b77fbf787.tar.gz |
BUG: fix #4381: precision loss on string -> longdouble conversion
Avoid going through python floats when converting string to
longdouble. This makes it dramatically easier to produce
full-precision long double numbers. Fixed are the constructor
(np.longdouble("1.01")), np.fromfile, np.fromstring, np.loadtxt,
and np.genfromtxt (and functions based on it). Also fixed is
precision loss when using np.tofile.
This also fixes #1481, poor handling of bad data in fromfile
and fromstring.
If the function strtod_l is not available, almost none of this
will work, and many tests will fail.
Diffstat (limited to 'numpy/lib/npyio.py')
-rw-r--r-- | numpy/lib/npyio.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index 86d757630..12052a08e 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -667,6 +667,8 @@ def _getconv(dtype): return np.int64 if issubclass(typ, np.integer): return lambda x: int(float(x)) + elif issubclass(typ, np.longdouble): + return np.longdouble elif issubclass(typ, np.floating): return floatconv elif issubclass(typ, np.complex): |