Repository navigation
[MRG] Warn when removing channels needed to compensation matrices. - #5581
Conversation
5a1a652 to
ec8a248
Compare
|
Is there a way to setup a local environment that mirrors one of the testing ones? This test is passing locally and I'm not quite sure what the issue is. open to thoughts. |
|
Use the environment.yml file, two of the Travis runs use it Also Travis runs the PR merged with master so you might need to rebase (or merge) to see the same errors |
|
It's also possible there is a default verbosity level difference, so you might need verbose=True in a call if you are checking an info level output. Also due to how warnings are caught and emitted (sometimes only once) it's possible you will see the error with a |
| if len(pick) > 0: | ||
| pytest.raises(RuntimeError, pick_info, info, pick) | ||
| with catch_logging() as log: | ||
| pick_info(info, pick) |
There was a problem hiding this comment.
you need verbose=True here because this is a info-level warning. This fails on my machine because I have MNE_LOGGING_LEVEL=warning in my config
There was a problem hiding this comment.
(and you'll need to add verbose kwarg and decorator to pick_info, too)
| with catch_logging() as log: | ||
| Epochs(raw, events, None, -0.2, 0.2, preload=False, | ||
| picks=picks) | ||
| assert('Compensation grade 1' in log.getvalue()) |
There was a problem hiding this comment.
Even with verbose=True in the Epochs constructor (to get info-level messages) I get:
AssertionError: assert 'Compensation grade 1' in '10 matching events found\nApplying baseline correction (mode: mean)\nNot setting metadata\nRemoving 5 compensators from info because not all compensation channels were picked.\n0 projection items activated\n'
|
@bloyl I pushed a commit to add the test that fails on |
|
This should hopefully pass. A downside is that this info message is going to crop up a fair amount (plotting data etc.) not sure if that is a problem. |
|
info level output happening frequently is okay |
|
Do you think I caught all the PRs/issues that were related to this issue? |
Codecov Report
@@ Coverage Diff @@
## master #5581 +/- ##
==========================================
- Coverage 88.44% 88.44% -0.01%
==========================================
Files 363 363
Lines 68071 68042 -29
Branches 11503 11494 -9
==========================================
- Hits 60205 60177 -28
+ Misses 5027 5026 -1
Partials 2839 2839 |
|
@bloyl I pushed a commit to add |
|
I quickly went through the 4 PRs you added. From what I can see none of them directly clear I would say we should leave them as most likely we will need them (or something like them) as part of #5342 |
| assert 'Removing 5 compensators' in log | ||
| raw_pick.save(out_fname, overwrite=True) # should work | ||
| read_raw_fif(out_fname) | ||
| read_raw_fif(out_fname, preload=True) |
There was a problem hiding this comment.
Either you test that save and reads do not raise, or you save+read and assert that the objects do the roundtrip without changing.
There was a problem hiding this comment.
execution time without asserting is not worth in the testing
There was a problem hiding this comment.
I think these calls are mainly to test that save and read do not raise exceptions. how would you assert that no exception was raised?
I added some regression tests for the channels and some data...
| with pytest.raises(RuntimeError, match='Compensation grade 1 has been'): | ||
| raw.copy().pick_types(**pick_kwargs) | ||
| for comp_grade in [0, 1]: | ||
| if comp_grade != 0: |
There was a problem hiding this comment.
This is not needed. Apply it for 0 and 1. We just asserted that raw.compesation_grade is 0 two lines above.
raw.apply_gradient_compensation(comp_grade)
| assert 'Removing 5 compensators' in log | ||
| raw_pick.save(out_fname, overwrite=True) # should work | ||
| read_raw_fif(out_fname) | ||
| read_raw_fif(out_fname, preload=True) |
There was a problem hiding this comment.
execution time without asserting is not worth in the testing
| pytest.raises(RuntimeError, pick_info, info, pick) | ||
| with catch_logging() as log: | ||
| pick_info(info, pick, verbose=True) | ||
| assert msg in log.getvalue() |
There was a problem hiding this comment.
If assert 'Removing {} compensators'.format(len(info['comps']) in log.getvalue() does not fit in a single line, I would define msg closer to the assert. It helps when reading pytest trace
7cf2925 to
4d6ff2e
Compare
|
@massich are you happy now? |
This is converts the RuntimeError that was raised when removing channels that were needed for applied compensation matrices to a Warning.
this is an initial PR in response to issue: #5342
If there are any other PRs that were made to skip this issue please add it to this list.
PRs to check
Closes #5384.