Repository navigation
ENH: Validate frequencies and add docstring warning in SpectrumArray (#14596) - #14598
Merged
tsbinns merged 3 commits intoNov 28, 2026
Merged
Conversation
ishaaaan17
requested review from
agramfort,
drammock,
larsoner and
mscheltienne
as code owners
November 25, 2026 19:43
ishaaaan17
force-pushed
the
enh/spectrum-array-freqs-check
branch
from
November 25, 2026 19:43
148ab18 to
5eb5743
Compare
tsbinns
reviewed
Nov 25, 2026
tsbinns
left a comment
Member
There was a problem hiding this comment.
Thanks @ishaaaan17! I only notice two minor things.
tsbinns
reviewed
Nov 28, 2026
tsbinns
left a comment
Member
There was a problem hiding this comment.
Thanks @ishaaaan17. Just one tiny thing I missed earlier, the it would be good to merge.
tsbinns
enabled auto-merge (squash)
November 28, 2026 11:59
tsbinns
approved these changes
Nov 28, 2026
tsbinns
left a comment
Member
There was a problem hiding this comment.
Thanks @ishaaaan17! Marking for merge whgen green
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reference issue (if any)
Fixes #14596.
What does this implement/fix?
As discussed with @tsbinns and @larsoner in #14596, this PR adds minimal sanity checks and documentation warnings for
SpectrumArrayandEpochsSpectrumArray:_check_data_shapethat frequencies are one-sided (freqs >= 0) and do not exceed the Nyquist frequency (sfreq / 2), raising aValueErrorotherwise... warning::note to the docstrings of bothSpectrumArrayandEpochsSpectrumArrayindicating that input validation is minimal and inconsistently or incorrectly specifying parameters can lead to unexpected errors downstream.test_spectrum_array_errors, along with a Towncrier changelog entry (14598.bugfix.rst).Additional information
All tests pass locally (
pytest mne/time_frequency/tests/test_spectrum.py), and style/changelog checks are 100% clean.AI Assistance Disclosure: I formulated the plan and implemented the validation logic and docstrings myself, and used Antigravity (Gemini) to draft the unit tests and verify style/changelog consistency.