-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor of NoisyChannels tests and split into separate methods #84
Conversation
Codecov Report
@@ Coverage Diff @@
## master #84 +/- ##
=======================================
Coverage 98.37% 98.37%
=======================================
Files 7 7
Lines 677 677
=======================================
Hits 666 666
Misses 11 11 Continue to review full report at Codecov.
|
Huh, looks like this had the unintended effect of making other sections of the test suite slower? Looking back at the old tests it looks like the current pyprep/tests/test_find_noisy_channels.py Lines 15 to 32 in bc46978
Since the above code tries to clean bad channels from the recording, I'm guessing that meant it took fewer iterations to re-reference during later tests. Regardless, I doubt that was intentional so I guess this PR fixes that as well! |
tests/conftest.py
Outdated
# The eegbci data has non-standard channel names. We need to rename them: | ||
eegbci.standardize(raw) | ||
# Re-reference the data after interpolating bad channels | ||
mne.set_eeg_reference(raw, 'average', copy=False, ch_type='eeg') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am surprised that BLACK does not complain here. It usually formats all quotation marks as " instead of ', right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I honestly don't know, I haven't really used black formatting before! If you have a preference for double quotes over singles for this project I'll definitely stick to that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mostly have a preference for using a consistent style - and preferably one that is enforced by a tool with a large community backing, such as black :-)
But if it doesn't enforce a format here, it's fine with me 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the look of it, PyPREP doesn't have any sort of automatic linting for Black enabled other than the 88 line length, is that something that should be fixed?
And that make sense! My general habit to use single-quotes for data (e.g., variable names, argument strings, key names, etc.) and double-quotes for strings that are meant to be read as text (e.g. docstrings, print messages, exception messages, etc.), but I'm happy to conform to whatever conventions a project uses. From what I can tell the Black style guide prefers double-quotes to singles (like you thought), so up to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
argh, good point actually. This line is supposed to ensure in CI that all code is BLACK formatted:
pyprep/.github/workflows/python_tests.yml
Line 41 in bc46978
black . |
But it should say black . --check
instead of black .
--> the former does a check, whereas the latter just applies the formatting, which is then obviously lost because it's not committed.
And for devs, the development environment should be setup automatically such that BLACK formatting is applied prior to each commit (pre-commit hook, see https://github.com/sappelhoff/pyprep#installation)
I'll make a PR for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see: #85
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM in general :) again -> a very helpful addition, thanks!
I left a few comments, but should be easy to address overall and then get it merged.
Thanks! I'll fix the formatting in #85 and make sure that the CI will check this in the future. |
PR Description
This PR takes the
test_findnoisychannels
function and splits it into separate unit tests for each type of bad channel, making it easier to maintain and figure out which specific part(s) are broken by a given change.I also changed the test file from the current (very noisy) one to one with only two noisy channels to start with, saving time repeatedly running
NoisyChannels
and interpolating bads at the start to try and produce a clean recording for subsequent tests. This also has the advantage of not depending onNoisyChannels
working properly in order to produce a dataset suitable for testingNoisyChannels
. To address #83 I manually set the Z threshold to 3.29 (as suggested) and added a note so we don't forget.Let me know what you think!
Merge Checklist
closes #<issue-number>
to automatically close an issue