summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
authorzjpoh <poh.zijie@gmail.com>2019-10-06 21:44:59 -0700
committerzjpoh <poh.zijie@gmail.com>2019-10-06 21:44:59 -0700
commit23fdb82e28ca5cf5b66dadbc4ca4afc9d5f0cab6 (patch)
tree78cb5496f9bd1d536ed82c01045d68649182a608 /numpy/core
parent3c9926bc326f37f3785ddb6e2fc646b3bc2bf9f3 (diff)
downloadnumpy-23fdb82e28ca5cf5b66dadbc4ca4afc9d5f0cab6.tar.gz
Update per Sebastian's comments
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/_add_newdocs.py6
-rw-r--r--numpy/core/src/multiarray/arraytypes.c.src9
-rw-r--r--numpy/core/tests/test_longdouble.py6
3 files changed, 14 insertions, 7 deletions
diff --git a/numpy/core/_add_newdocs.py b/numpy/core/_add_newdocs.py
index 30379dfbe..8580904e2 100644
--- a/numpy/core/_add_newdocs.py
+++ b/numpy/core/_add_newdocs.py
@@ -1036,10 +1036,8 @@ add_newdoc('numpy.core.multiarray', 'fromstring',
A string containing the data.
dtype : data-type, optional
The data type of the array; default: float. For binary input data,
- the data must be in exactly this format. Supported dtypes are
- byte, ubyte, short, ushort, int, uint, long, ulong, longlong, ulonglong,
- datetime, timedelta, float, double, longdouble, half, bool,
- cfloat, and cdouble.
+ the data must be in exactly this format. Most builtin numeric types are
+ supported and extension types may be supported.
Complex dtypes are only supported since numpy 1.18.0
count : int, optional
diff --git a/numpy/core/src/multiarray/arraytypes.c.src b/numpy/core/src/multiarray/arraytypes.c.src
index c06a1edaa..9ffa30d81 100644
--- a/numpy/core/src/multiarray/arraytypes.c.src
+++ b/numpy/core/src/multiarray/arraytypes.c.src
@@ -1873,15 +1873,18 @@ static int
result = NumPyOS_ascii_strtod(str, endptr);
if (endptr && *endptr[0] == 'j') {
+ // Read is successful if the immediate following char is j
output.imag = result;
+
+ // Skip j
+ ++*endptr;
}
else {
+ // Set endptr to previous char to trigger the not everything is
+ // read error
endptr = prev;
output.imag = 0;
}
-
- // Skip j
- ++*endptr;
}
else if (endptr && *endptr[0] == 'j') {
// Real component not specified
diff --git a/numpy/core/tests/test_longdouble.py b/numpy/core/tests/test_longdouble.py
index b9652cc98..74dcb4d5e 100644
--- a/numpy/core/tests/test_longdouble.py
+++ b/numpy/core/tests/test_longdouble.py
@@ -95,6 +95,12 @@ def test_fromstring_complex():
with assert_warns(DeprecationWarning):
assert_equal(np.fromstring("1+j", dtype=ctype, sep=","),
np.array([1.]))
+ with assert_warns(DeprecationWarning):
+ assert_equal(np.fromstring("1+", dtype=ctype, sep=","),
+ np.array([1.]))
+ with assert_warns(DeprecationWarning):
+ assert_equal(np.fromstring("1j+1", dtype=ctype, sep=","),
+ np.array([1j]))