()
| 94 | |
| 95 | |
| 96 | def 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 | |
| 122 | def test_fromstring_bogus(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…