Skip to content

Refactor test_plot_alignment_basic() - #13472

Merged
drammock merged 18 commits into
mne-tools:mainfrom
nordme:refctr_test
Jul 29, 2026
Merged

Refactor test_plot_alignment_basic()#13472
drammock merged 18 commits into
mne-tools:mainfrom
nordme:refctr_test

Conversation

@nordme

@nordme nordme commented Oct 29, 2025

Copy link
Copy Markdown
Contributor

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).

@drammock drammock left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nice! a few suggestions below (terse, because @nordme and I were reviewing this together in real time)

Comment thread mne/viz/tests/test_3d.py Outdated
Comment thread mne/viz/tests/test_3d.py
Comment thread mne/viz/tests/test_3d.py Outdated
Comment thread mne/viz/tests/test_3d.py Outdated
Comment thread mne/viz/tests/test_3d.py Outdated
Comment thread mne/viz/tests/test_3d.py Outdated
Comment thread mne/viz/tests/test_3d.py Outdated
Comment on lines +698 to +701
info,
trans=trans_fname,
subject="sample",
subjects_dir=subjects_dir,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pull out a shared_kwargs dict with these 4 params, to make clearer which params are different between each call to plot_alignment in this test

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this one is still pending

Comment thread mne/viz/tests/test_3d.py Outdated
Comment thread mne/viz/tests/test_3d.py Outdated
Comment thread mne/viz/tests/test_3d.py Outdated
@nordme

nordme commented Nov 12, 2025

Copy link
Copy Markdown
Contributor Author

@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?

@larsoner

Copy link
Copy Markdown
Member

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

def fwd_volume_small(_fwd_subvolume):

@nordme
nordme marked this pull request as ready for review November 19, 2025 21:41
@nordme
nordme requested a review from dengemann as a code owner November 19, 2025 21:41
@nordme

nordme commented Nov 19, 2025

Copy link
Copy Markdown
Contributor Author

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

@larsoner larsoner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nordme sorry I missed the ping for final review, just two small things then I think we can merge! I also merged main into this branch but you can force-push over that if needed

Comment thread mne/viz/tests/test_3d.py Outdated
Comment on lines +580 to +587
pytest.raises(
TypeError,
plot_alignment,
"foo",
trans_fname,
subject="sample",
subjects_dir=subjects_dir,
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's modernize with context manager

with pytest.raises(..., match="...):
    call(...)

Comment thread mne/viz/tests/test_3d.py Outdated
Comment on lines +698 to +701
info,
trans=trans_fname,
subject="sample",
subjects_dir=subjects_dir,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this one is still pending

@drammock
drammock merged commit b1fb893 into mne-tools:main Jul 29, 2026
29 checks passed
larsoner added a commit to larsoner/mne-python that referenced this pull request Aug 4, 2026
* upstream/main: (35 commits)
  Fix bug with coreg scaling (mne-tools#14132)
  MAINT: Update code credit (mne-tools#14131)
  Fix bugs with dark mode panels (mne-tools#14109)
  Improve code credit workflow (mne-tools#14120)
  Align _AbstractRenderer.tube with the PyVista implementation (mne-tools#14125)
  Assign instead of compare when marking explicit zeros in spatio_temporal_dist_adjacency (mne-tools#14124)
  MAINT: Update pre-commit hook versions (mne-tools#14122)
  MAINT: Update dependency specifiers (mne-tools#14121)
  fix: correct typo in comment (mne-tools#14117)
  [dependabot]: Bump the actions group with 2 updates (mne-tools#14123)
  Fix` read_raw_eyelink()` failure when recording blocks are empty or starting with empty values (mne-tools#13571)
  ENH: Add `event_key` parameter to `read_raw_egi` for MFF event metadata (mne-tools#14086)
  fix for scipy sparse deprecations (mne-tools#14118)
  Fix notch spectrum fit (mne-tools#14116)
  Speed up notch filter spectrum fit (mne-tools#14114)
  fix MNE-RT links and update roadmap (mne-tools#14096)
  Clarify `docdict["filter_length_notch"]` (mne-tools#14113)
  Refactor test_plot_alignment_basic() (mne-tools#13472)
  BUG: Cleanup cHPI filtering using smooth interpolation (mne-tools#14112)
  Use redirector app (mne-tools#14111)
  ...

# Conflicts:
#	mne/tests/test_filter.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants