(self)
| 155 | assert_equal(res, np.array([1., 2., 3.])) |
| 156 | |
| 157 | def test_fromfile_complex(self): |
| 158 | for ctype in ["complex", "cdouble", "cfloat"]: |
| 159 | # Check spacing between separator and only real component specified |
| 160 | with temppath() as path: |
| 161 | with open(path, 'w') as f: |
| 162 | f.write("1, 2 , 3 ,4\n") |
| 163 | |
| 164 | res = np.fromfile(path, dtype=ctype, sep=",") |
| 165 | assert_equal(res, np.array([1., 2., 3., 4.])) |
| 166 | |
| 167 | # Real component not specified |
| 168 | with temppath() as path: |
| 169 | with open(path, 'w') as f: |
| 170 | f.write("1j, -2j, 3j, 4e1j\n") |
| 171 | |
| 172 | res = np.fromfile(path, dtype=ctype, sep=",") |
| 173 | assert_equal(res, np.array([1.j, -2.j, 3.j, 40.j])) |
| 174 | |
| 175 | # Both components specified |
| 176 | with temppath() as path: |
| 177 | with open(path, 'w') as f: |
| 178 | f.write("1+1j,2-2j, -3+3j, -4e1+4j\n") |
| 179 | |
| 180 | res = np.fromfile(path, dtype=ctype, sep=",") |
| 181 | assert_equal(res, np.array([1. + 1.j, 2. - 2.j, - 3. + 3.j, - 40. + 4j])) |
| 182 | |
| 183 | # Spaces at wrong places |
| 184 | with temppath() as path: |
| 185 | with open(path, 'w') as f: |
| 186 | f.write("1+2 j,3\n") |
| 187 | |
| 188 | with assert_warns(DeprecationWarning): |
| 189 | res = np.fromfile(path, dtype=ctype, sep=",") |
| 190 | assert_equal(res, np.array([1.])) |
| 191 | |
| 192 | # Spaces at wrong places |
| 193 | with temppath() as path: |
| 194 | with open(path, 'w') as f: |
| 195 | f.write("1+ 2j,3\n") |
| 196 | |
| 197 | with assert_warns(DeprecationWarning): |
| 198 | res = np.fromfile(path, dtype=ctype, sep=",") |
| 199 | assert_equal(res, np.array([1.])) |
| 200 | |
| 201 | # Spaces at wrong places |
| 202 | with temppath() as path: |
| 203 | with open(path, 'w') as f: |
| 204 | f.write("1 +2j,3\n") |
| 205 | |
| 206 | with assert_warns(DeprecationWarning): |
| 207 | res = np.fromfile(path, dtype=ctype, sep=",") |
| 208 | assert_equal(res, np.array([1.])) |
| 209 | |
| 210 | # Spaces at wrong places |
| 211 | with temppath() as path: |
| 212 | with open(path, 'w') as f: |
| 213 | f.write("1+j\n") |
| 214 |
nothing calls this directly
no test coverage detected