Skip to content

Commit

Permalink
FIX: Fix epoch eq with no events
Browse files Browse the repository at this point in the history
  • Loading branch information
larsoner committed May 9, 2016
1 parent ee8ac19 commit acc467d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mne/epochs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2326,6 +2326,9 @@ def _minimize_time_diff(t_shorter, t_longer):
"""Find a boolean mask to minimize timing differences"""
from scipy.interpolate import interp1d
keep = np.ones((len(t_longer)), dtype=bool)
if len(t_shorter) == 0:
keep.fill(False)
return keep
scores = np.ones((len(t_longer)))
x1 = np.arange(len(t_shorter))
# The first set of keep masks to test
Expand Down
7 changes: 7 additions & 0 deletions mne/tests/test_epochs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,13 @@ def test_epoch_eq():
assert_raises(ValueError, epochs.equalize_event_counts, c, copy=False)
assert_raises(KeyError, epochs.equalize_event_counts,
["a/no_match", "b"], copy=False)
# test equalization with no events of one type
epochs.drop(np.arange(10))
assert_equal(len(epochs['a/x']), 0)
assert_true(len(epochs['a/y']) > 0)
epochs.equalize_event_counts(['a/x', 'a/y'], copy=False)
assert_equal(len(epochs['a/x']), 0)
assert_equal(len(epochs['a/y']), 0)


def test_access_by_name():
Expand Down

0 comments on commit acc467d

Please sign in to comment.