summaryrefslogtreecommitdiff
path: root/numpy/core/tests
diff options
context:
space:
mode:
authorzjpoh <poh.zijie@gmail.com>2019-09-26 22:26:49 -0700
committerzjpoh <poh.zijie@gmail.com>2019-09-26 22:26:49 -0700
commit3c9926bc326f37f3785ddb6e2fc646b3bc2bf9f3 (patch)
tree7be0acce40158cbd091b9c90cd07046f064145c8 /numpy/core/tests
parent27332a8b2b098a519e8ade0706e1ae4086f15b92 (diff)
downloadnumpy-3c9926bc326f37f3785ddb6e2fc646b3bc2bf9f3.tar.gz
Add deprecation warning for invalid complex string
Diffstat (limited to 'numpy/core/tests')
-rw-r--r--numpy/core/tests/test_longdouble.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/numpy/core/tests/test_longdouble.py b/numpy/core/tests/test_longdouble.py
index 8e1c9d153..b9652cc98 100644
--- a/numpy/core/tests/test_longdouble.py
+++ b/numpy/core/tests/test_longdouble.py
@@ -72,16 +72,30 @@ def test_fromstring():
def test_fromstring_complex():
- for ctypes in ["complex", "cdouble", "cfloat"]:
+ for ctype in ["complex", "cdouble", "cfloat"]:
# Check spacing between separator
- assert_equal(np.fromstring("1, 2 , 3 ,4",sep=",",dtype=ctypes),
+ assert_equal(np.fromstring("1, 2 , 3 ,4",sep=",",dtype=ctype),
np.array([1., 2., 3., 4.]))
# Real component not specified
- assert_equal(np.fromstring("1j, -2j, 3j, 4e1j",sep=",",dtype=ctypes),
+ assert_equal(np.fromstring("1j, -2j, 3j, 4e1j",sep=",",dtype=ctype),
np.array([1.j, -2.j, 3.j, 40.j]))
# Both components specified
- assert_equal(np.fromstring("1+1j,2-2j, -3+3j, -4e1", sep=",", dtype=ctypes),
+ assert_equal(np.fromstring("1+1j,2-2j, -3+3j, -4e1", sep=",", dtype=ctype),
np.array([1. + 1.j, 2. - 2.j, - 3. + 3.j, - 40.]))
+ # Spaces at wrong places
+ with assert_warns(DeprecationWarning):
+ assert_equal(np.fromstring("1+2 j,3", dtype=ctype, sep=","),
+ np.array([1.]))
+ with assert_warns(DeprecationWarning):
+ assert_equal(np.fromstring("1+ 2j,3", dtype=ctype, sep=","),
+ np.array([1.]))
+ with assert_warns(DeprecationWarning):
+ assert_equal(np.fromstring("1 +2j,3", dtype=ctype, sep=","),
+ np.array([1.]))
+ with assert_warns(DeprecationWarning):
+ assert_equal(np.fromstring("1+j", dtype=ctype, sep=","),
+ np.array([1.]))
+
def test_fromstring_bogus():