summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2015-08-31 13:04:54 -0400
committerCharles Harris <charlesr.harris@gmail.com>2015-08-31 13:04:54 -0400
commitd750cba93436f20d5457daec5ad5d5ffb65f22bd (patch)
tree79f6c2288244cb940021d4b0d3df308fb6d1917b
parent7001d613aaa445ff650a273ec3d4db6787daf2e3 (diff)
parentf53a7b09fef45fbba235fcb29c160328aad02680 (diff)
downloadnumpy-d750cba93436f20d5457daec5ad5d5ffb65f22bd.tar.gz
Merge pull request #6264 from aarchiba/longdouble_improvements
TST: check for best-effort parsing in foreign locales
-rw-r--r--numpy/core/src/multiarray/numpyos.c2
-rw-r--r--numpy/core/tests/test_longdouble.py13
2 files changed, 14 insertions, 1 deletions
diff --git a/numpy/core/src/multiarray/numpyos.c b/numpy/core/src/multiarray/numpyos.c
index 708151c00..450ec40b6 100644
--- a/numpy/core/src/multiarray/numpyos.c
+++ b/numpy/core/src/multiarray/numpyos.c
@@ -619,7 +619,7 @@ NumPyOS_ascii_strtold(const char *s, char** endptr)
}
return result;
#else
- return NumPyOS_ascii_strtod_plain(s, endptr);
+ return NumPyOS_ascii_strtod(s, endptr);
#endif
}
diff --git a/numpy/core/tests/test_longdouble.py b/numpy/core/tests/test_longdouble.py
index 9e90e8bd1..fcc79ecbc 100644
--- a/numpy/core/tests/test_longdouble.py
+++ b/numpy/core/tests/test_longdouble.py
@@ -19,6 +19,7 @@ _o = 1 + np.finfo(np.longdouble).eps
string_to_longdouble_inaccurate = (_o != np.longdouble(repr(_o)))
del _o
+
def test_scalar_extraction():
"""Confirm that extracting a value doesn't convert to python float"""
o = 1 + np.finfo(np.longdouble).eps
@@ -80,6 +81,18 @@ def test_fromstring():
err_msg="reading '%s'" % s)
+@in_foreign_locale
+def test_fromstring_best_effort_float():
+ assert_equal(np.fromstring("1,234", dtype=float, sep=" "),
+ np.array([1.]))
+
+
+@in_foreign_locale
+def test_fromstring_best_effort():
+ assert_equal(np.fromstring("1,234", dtype=np.longdouble, sep=" "),
+ np.array([1.]))
+
+
def test_fromstring_bogus():
assert_equal(np.fromstring("1. 2. 3. flop 4.", dtype=float, sep=" "),
np.array([1., 2., 3.]))