summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-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]))