MCPcopy
hub / github.com/mne-tools/mne-python / test_save_complex_data

Function test_save_complex_data

mne/tests/test_epochs.py:4438–4457  ·  view source on GitHub ↗

Test whether epochs of hilbert-transformed data can be saved.

(tmp_path, preload, is_complex, fmt, rtol)

Source from the content-addressed store, hash-verified

4436@pytest.mark.parametrize("is_complex", (True, False))
4437@pytest.mark.parametrize("fmt, rtol", [("single", 2e-6), ("double", 1e-10)])
4438def 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
4460def test_no_epochs(tmp_path):

Callers

nothing calls this directly

Calls 8

EpochsClass · 0.90
read_epochsFunction · 0.90
apply_hilbertMethod · 0.80
_get_dataFunction · 0.70
load_dataMethod · 0.45
saveMethod · 0.45
copyMethod · 0.45
get_dataMethod · 0.45

Tested by

no test coverage detected