Test whether epochs of hilbert-transformed data can be saved.
(tmp_path, preload, is_complex, fmt, rtol)
| 4436 | @pytest.mark.parametrize("is_complex", (True, False)) |
| 4437 | @pytest.mark.parametrize("fmt, rtol", [("single", 2e-6), ("double", 1e-10)]) |
| 4438 | def test_save_complex_data(tmp_path, preload, is_complex, fmt, rtol): |
| 4439 | """Test whether epochs of hilbert-transformed data can be saved.""" |
| 4440 | raw, events = _get_data()[:2] |
| 4441 | raw.load_data() |
| 4442 | if is_complex: |
| 4443 | raw.apply_hilbert(envelope=False, n_fft=None) |
| 4444 | epochs = Epochs(raw, events[:1], preload=True)[0] |
| 4445 | temp_fname = tmp_path / "test-epo.fif" |
| 4446 | epochs.save(temp_fname, fmt=fmt) |
| 4447 | data = epochs.get_data().copy() |
| 4448 | epochs_read = read_epochs(temp_fname, proj=False, preload=preload) |
| 4449 | data_read = epochs_read.get_data() |
| 4450 | want_dtype = np.complex128 if is_complex else np.float64 |
| 4451 | assert data.dtype == want_dtype |
| 4452 | assert data_read.dtype == want_dtype |
| 4453 | # XXX for some reason some random samples in here are off by a larger |
| 4454 | # factor... |
| 4455 | if fmt == "single" and not preload and not is_complex: |
| 4456 | rtol = 2e-4 |
| 4457 | assert_allclose(data_read, data, rtol=rtol) |
| 4458 | |
| 4459 | |
| 4460 | def test_no_epochs(tmp_path): |
nothing calls this directly
no test coverage detected