mne-python icon indicating copy to clipboard operation
mne-python copied to clipboard

Refactor test_plot_alignment_basic()

Open nordme opened this issue 2 months ago • 3 comments

What does this implement/fix?

This is a PR to simplify an overly long and complicated test in the testing suite for #D visualization. This refactor breaks testing of the function mne.viz.plot_alignment into manageable chunks, separating tests of different parameters, and separating error checking from test plots (except where doing so would add extra up front instantiations).

nordme avatar Oct 29 '25 18:10 nordme

@larsoner @drammock Hey Eric, something I noticed while doing this refactor is that our volumetric source space example in our testing data set does not have a value for the subject field, i.e. src._subject is blank. I can hack it to make it work for this PR, but I wondered if perhaps we should update the volumetric source space in the testing data (MNE-testing-data/subjects/sample/bem/sample-volume-7mm-src.fif), since plotting functions want the subject field filled. What do you think?

nordme avatar Nov 12 '25 21:11 nordme

We could, but it's also pretty easy to add a

@pytest.fixture
@testing.requires_testing_data
def vol_src():
    src = mne.read_source_spaces(...)
    src._subject = "sample"
    return src

instead, which might be preferable anyway since it avoids some boilerplate. There are some similar things here already

https://github.com/mne-tools/mne-python/blob/7ed5e27dc794171ed5248605804034b4cc44c928/mne/conftest.py#L783

larsoner avatar Nov 13 '25 18:11 larsoner

Code coverage is equal between main and this branch, so I think this is ready to go!

nordme avatar Nov 19 '25 21:11 nordme