()
| 90 | |
| 91 | |
| 92 | def 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 | |
| 124 | def test_fromstring_bogus(): |
nothing calls this directly
no test coverage detected