MCPcopy Create free account
hub / github.com/numpy/numpy / test_fromstring_complex

Function test_fromstring_complex

numpy/core/tests/test_longdouble.py:92–121  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

assert_equalFunction · 0.90
assert_warnsFunction · 0.90
fromstringMethod · 0.80

Tested by

no test coverage detected