def test_get_peak():
    'Test peak getter\n    '
    evoked = read_evokeds(fname, condition=0, proj=True)
    assert_raises(ValueError, evoked.get_peak, ch_type='mag', tmin=1)
    assert_raises(ValueError, evoked.get_peak, ch_type='mag', tmax=0.9)
    assert_raises(ValueError, evoked.get_peak, ch_type='mag', tmin=0.02, tmax=0.01)
    assert_raises(ValueError, evoked.get_peak, ch_type='mag', mode='foo')
    assert_raises(RuntimeError, evoked.get_peak, ch_type=None, mode='foo')
    assert_raises(ValueError, evoked.get_peak, ch_type='misc', mode='foo')
    (ch_idx, time_idx) = evoked.get_peak(ch_type='mag')
    assert_true((ch_idx in evoked.ch_names))
    assert_true((time_idx in evoked.times))
    (ch_idx, time_idx) = evoked.get_peak(ch_type='mag', time_as_index=True)
    assert_true((time_idx < len(evoked.times)))
    data = np.array([[0.0, 1.0, 2.0], [0.0, (- 3.0), 0]])
    times = np.array([0.1, 0.2, 0.3])
    (ch_idx, time_idx) = _get_peak(data, times, mode='abs')
    assert_equal(ch_idx, 1)
    assert_equal(time_idx, 1)
    (ch_idx, time_idx) = _get_peak((data * (- 1)), times, mode='neg')
    assert_equal(ch_idx, 0)
    assert_equal(time_idx, 2)
    (ch_idx, time_idx) = _get_peak(data, times, mode='pos')
    assert_equal(ch_idx, 0)
    assert_equal(time_idx, 2)
    assert_raises(ValueError, _get_peak, (data + 1000.0), times, mode='neg')
    assert_raises(ValueError, _get_peak, (data - 1000.0), times, mode='pos')
Test peak getter
def test_get_peak():
    '\n    '
    evoked = read_evokeds(fname, condition=0, proj=True)
    assert_raises(ValueError, evoked.get_peak, ch_type='mag', tmin=1)
    assert_raises(ValueError, evoked.get_peak, ch_type='mag', tmax=0.9)
    assert_raises(ValueError, evoked.get_peak, ch_type='mag', tmin=0.02, tmax=0.01)
    assert_raises(ValueError, evoked.get_peak, ch_type='mag', mode='foo')
    assert_raises(RuntimeError, evoked.get_peak, ch_type=None, mode='foo')
    assert_raises(ValueError, evoked.get_peak, ch_type='misc', mode='foo')
    (ch_idx, time_idx) = evoked.get_peak(ch_type='mag')
    assert_true((ch_idx in evoked.ch_names))
    assert_true((time_idx in evoked.times))
    (ch_idx, time_idx) = evoked.get_peak(ch_type='mag', time_as_index=True)
    assert_true((time_idx < len(evoked.times)))
    data = np.array([[0.0, 1.0, 2.0], [0.0, (- 3.0), 0]])
    times = np.array([0.1, 0.2, 0.3])
    (ch_idx, time_idx) = _get_peak(data, times, mode='abs')
    assert_equal(ch_idx, 1)
    assert_equal(time_idx, 1)
    (ch_idx, time_idx) = _get_peak((data * (- 1)), times, mode='neg')
    assert_equal(ch_idx, 0)
    assert_equal(time_idx, 2)
    (ch_idx, time_idx) = _get_peak(data, times, mode='pos')
    assert_equal(ch_idx, 0)
    assert_equal(time_idx, 2)
    assert_raises(ValueError, _get_peak, (data + 1000.0), times, mode='neg')
    assert_raises(ValueError, _get_peak, (data - 1000.0), times, mode='pos')