Test edf files.
(tmp_path)
| 279 | |
| 280 | |
| 281 | def test_edf_data_broken(tmp_path): |
| 282 | """Test edf files.""" |
| 283 | raw = _test_raw_reader( |
| 284 | read_raw_edf, |
| 285 | input_fname=edf_path, |
| 286 | exclude=["Ergo-Left", "H10"], |
| 287 | verbose="error", |
| 288 | ) |
| 289 | raw_py = read_raw_edf(edf_path) |
| 290 | data = raw_py.get_data() |
| 291 | assert_equal(len(raw.ch_names) + 2, len(raw_py.ch_names)) |
| 292 | |
| 293 | # Test with number of records not in header (-1). |
| 294 | broken_fname = tmp_path / "broken.edf" |
| 295 | with open(edf_path, "rb") as fid_in: |
| 296 | fid_in.seek(0, 2) |
| 297 | n_bytes = fid_in.tell() |
| 298 | fid_in.seek(0, 0) |
| 299 | rbytes = fid_in.read() |
| 300 | with open(broken_fname, "wb") as fid_out: |
| 301 | fid_out.write(rbytes[:236]) |
| 302 | fid_out.write(b"-1 ") |
| 303 | fid_out.write(rbytes[244 : 244 + int(n_bytes * 0.4)]) |
| 304 | with pytest.warns(RuntimeWarning, match="records .* not match the file size"): |
| 305 | raw = read_raw_edf(broken_fname, preload=True) |
| 306 | read_raw_edf(broken_fname, exclude=raw.ch_names[:132], preload=True) |
| 307 | |
| 308 | # Test with \x00's in the data |
| 309 | with open(broken_fname, "wb") as fid_out: |
| 310 | fid_out.write(rbytes[:184]) |
| 311 | assert rbytes[184:192] == b"36096 " |
| 312 | fid_out.write(rbytes[184:192].replace(b" ", b"\x00")) |
| 313 | fid_out.write(rbytes[192:]) |
| 314 | raw_py = read_raw_edf(broken_fname) |
| 315 | data_new = raw_py.get_data() |
| 316 | assert_allclose(data, data_new) |
| 317 | |
| 318 | |
| 319 | def test_duplicate_channel_labels_edf(): |
nothing calls this directly
no test coverage detected