MCPcopy Index your code
hub / github.com/numpy/numpy / test_fromstring_complex

Function test_fromstring_complex

numpy/_core/tests/test_longdouble.py:96–119  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

94
95
96def test_fromstring_complex():
97 for ctype in ["complex", "cdouble"]:
98 # Check spacing between separator
99 assert_equal(np.fromstring("1, 2 , 3 ,4", sep=",", dtype=ctype),
100 np.array([1., 2., 3., 4.]))
101 # Real component not specified
102 assert_equal(np.fromstring("1j, -2j, 3j, 4e1j", sep=",", dtype=ctype),
103 np.array([1.j, -2.j, 3.j, 40.j]))
104 # Both components specified
105 assert_equal(np.fromstring("1+1j,2-2j, -3+3j, -4e1+4j", sep=",", dtype=ctype),
106 np.array([1. + 1.j, 2. - 2.j, - 3. + 3.j, - 40. + 4j]))
107 # Spaces at wrong places
108 with assert_raises(ValueError):
109 np.fromstring("1+2 j,3", dtype=ctype, sep=",")
110 with assert_raises(ValueError):
111 np.fromstring("1+ 2j,3", dtype=ctype, sep=",")
112 with assert_raises(ValueError):
113 np.fromstring("1 +2j,3", dtype=ctype, sep=",")
114 with assert_raises(ValueError):
115 np.fromstring("1+j", dtype=ctype, sep=",")
116 with assert_raises(ValueError):
117 np.fromstring("1+", dtype=ctype, sep=",")
118 with assert_raises(ValueError):
119 np.fromstring("1j+1", dtype=ctype, sep=",")
120
121
122def test_fromstring_bogus():

Callers

nothing calls this directly

Calls 3

assert_equalFunction · 0.90
assert_raisesFunction · 0.90
fromstringMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…