-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MRG: TESTS: Remove RuntimeWarnings (#375)
* TESTS: Remove RuntimeWarnings Make pytest fail on `RuntimeWarnings`, and only allow "legit", explicitly specified warnings in tests. At first, I wanted to "fix" or silence all warnings, but I quickly realized that maybe this wasn't the best idea – also because I ran into some weird interactions between the `warnings` module and pytest being configured to on warnings, which cost me hours to figure out. That's why I've now decided to filter warnings that a test is expected to raise via `pytest.mark.filterwarnings`. This allows us not only to specify a warning message and category, but also from which module to expect the warning, e.g. `mne_bids` or `mne`. I've been very careful to check if all warnings that are silenced this way are actually legit; there's only one warning in `test_write.test_fif()` about which I'm unsure (marked via `XXX`). * flake8 * Remove cruft * TESTS: Add back accidentally deleted comment * BF: Handle events with unknown onset or duration Fixes an issue with MNE-Python 0.19: `mne_bids.read._handle_events_reading()` would produce a warning when event onsets or durations are `'n/a'`. This is because it replaces all `'n/a'` strings with `np.nan` before creating annotations. When this Annotation object is then passed to `Raw.set_annotations()`, MNE calls `Annotations.crop()`, which executes the following line: ``` out_of_bounds = (absolute_onset > tmax) | (absolute_offset < tmin) ``` Since there's now `np.nan` in `absolute_onset` and / or `absolute_offset`, the desired behavior is unclear, and NumPy will emit a `RuntimeWarning`. This warning, however, only occurs with MNE-Python 0.19; with MNE `master`, the behavior of `Annotations.crop()` has obviously changed. To make things work without warning even with MNE-Python 0.19, I now drop events with an unknown (`'n/a'` or `np.nan`) onset before creating Annotations. And unknown durations are now simply assumed to be zero. * RF: Change order * Use warning string dict * Add changelog entry * Remove XXX
- Loading branch information
1 parent
3157ea1
commit 826a7da
Showing
6 changed files
with
55 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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