Skip to content

Commit eab2fbe

Browse files
committed
added test for raising error when averaging over epochs containing NaNs and renamed test function
1 parent 7cefb20 commit eab2fbe

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

mne/tests/test_epochs.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5307,7 +5307,7 @@ def test_empty_error(method, epochs_empty):
53075307
getattr(epochs_empty.copy(), method[0])(**method[1])
53085308

53095309

5310-
def test_mark_bad_epochs_by_channel():
5310+
def test_mask_epochs_per_channel():
53115311
"""Test channel-specific epoch rejection."""
53125312
# load raw and events data without loading data to disk
53135313
raw, ev, _ = _get_data(preload=False)
@@ -5328,7 +5328,7 @@ def test_mark_bad_epochs_by_channel():
53285328
ep.load_data()
53295329

53305330
# test if reject_mask == None returns epochs
5331-
assert ep == ep.mark_bad_epochs_by_channel(None)
5331+
assert ep == ep.mask_epochs_per_channel(None)
53325332

53335333
# set epochs to bad in reject mask
53345334
reject_mask = np.zeros((n_epochs, n_channels), dtype=bool) # all epochs are good
@@ -5341,7 +5341,7 @@ def test_mark_bad_epochs_by_channel():
53415341
# reject_mask[:, 1] = True # all epochs from channel two are bad
53425342

53435343
# drop bad epochs
5344-
ep.mark_bad_epochs_by_channel(reject_mask)
5344+
ep.mask_epochs_per_channel(reject_mask)
53455345

53465346
# verify bad epochs are NaN after dropping them
53475347
data = ep.get_data()
@@ -5359,11 +5359,9 @@ def test_mark_bad_epochs_by_channel():
53595359
# channel length must match
53605360
assert len(ep.nave_per_channel) == len(ep.ch_names)
53615361

5362-
# make sure averaging works (allowing for NaNs)
5363-
ev = ep.average()
5364-
5365-
# check if nave of evoked data is minimum of nave_per_channel of epoched data
5366-
assert ev.nave == ep.nave_per_channel.min()
5362+
# make sure averaging breaks
5363+
with pytest.raises(ValueError, match="Cannot average epochs containing NaNs"):
5364+
ep.average()
53675365

53685366
# test mask that contains floats instead of bool
53695367
float_mask = reject_mask.astype(float)

0 commit comments

Comments
 (0)