Skip to content

Commit fdba73f

Browse files
committed
FIX: Speed up, too
1 parent ba7d10a commit fdba73f

1 file changed

Lines changed: 17 additions & 11 deletions

File tree

mne/beamformer/tests/test_lcmv.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,20 @@ def test_make_lcmv_bem(tmp_path, reg, proj, kind):
564564
make_lcmv(epochs.info, forward_fixed, data_cov_grad, reg=0.01, noise_cov=noise_cov)
565565

566566

567+
@pytest.fixture(scope="module")
568+
def evoked_fwd_noise_data():
569+
"""Fixture to supply reusable data."""
570+
_, _, evoked, data_cov, noise_cov, _, _, _, _, _ = _get_data(proj=True)
571+
assert "eeg" not in evoked
572+
assert "meg" in evoked
573+
sphere = mne.make_sphere_model(r0=(0.0, 0.0, 0.0), head_radius=0.080)
574+
src = mne.setup_volume_source_space(
575+
pos=25.0, sphere=sphere, mindist=5.0, exclude=2.0
576+
)
577+
fwd_sphere = mne.make_forward_solution(evoked.info, None, src, sphere)
578+
return evoked, fwd_sphere, noise_cov, data_cov
579+
580+
567581
@testing.requires_testing_data
568582
@pytest.mark.slowtest
569583
@pytest.mark.parametrize(
@@ -576,24 +590,16 @@ def test_make_lcmv_bem(tmp_path, reg, proj, kind):
576590
(None, "max-power"),
577591
],
578592
)
579-
def test_make_lcmv_sphere(pick_ori, weight_norm):
593+
def test_make_lcmv_sphere(pick_ori, weight_norm, evoked_fwd_noise_data):
580594
"""Test LCMV with sphere head model."""
581595
# unit-noise gain beamformer and orientation
582596
# selection and rank reduction of the leadfield
583-
_, _, evoked, data_cov, noise_cov, _, _, _, _, _ = _get_data(proj=True)
584-
assert "eeg" not in evoked
585-
assert "meg" in evoked
586-
sphere = mne.make_sphere_model(r0=(0.0, 0.0, 0.0), head_radius=0.080)
587-
src = mne.setup_volume_source_space(
588-
pos=25.0, sphere=sphere, mindist=5.0, exclude=2.0
589-
)
590-
fwd_sphere = mne.make_forward_solution(evoked.info, None, src, sphere)
591-
597+
evoked, fwd_sphere, noise_cov, data_cov = evoked_fwd_noise_data
592598
# Test that we get an error if not reducing rank
593599
with (
594600
pytest.raises(ValueError, match="Singular matrix detected"),
595601
_record_warnings(),
596-
pytest.warns(RuntimeWarning, match="positive semidefinite"),
602+
pytest.warns(RuntimeWarning, match="(positive semidefinite|largest eigenvalu)"),
597603
):
598604
make_lcmv(
599605
evoked.info,

0 commit comments

Comments
 (0)