From acc467d0bd575807a9189396afa7f7c9db6e17f9 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Mon, 9 May 2016 14:06:29 -0400 Subject: [PATCH] FIX: Fix epoch eq with no events --- mne/epochs.py | 3 +++ mne/tests/test_epochs.py | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/mne/epochs.py b/mne/epochs.py index fb3869fca4b..8dbc202590c 100644 --- a/mne/epochs.py +++ b/mne/epochs.py @@ -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 diff --git a/mne/tests/test_epochs.py b/mne/tests/test_epochs.py index f7ca57dd6af..9803d09b627 100644 --- a/mne/tests/test_epochs.py +++ b/mne/tests/test_epochs.py @@ -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():