def test_add_events():
 raw = read_raw_fif(raw_fname)
 events = np.array([[raw.first_samp, 0, 1]])
 assert_raises(RuntimeError, raw.add_events, events, 'STI 014')
 raw = read_raw_fif(raw_fname, preload=True)
 orig_events = find_events(raw, 'STI 014')
 events = np.array([raw.first_samp, 0, 1])
 assert_raises(ValueError, raw.add_events, events, 'STI 014')
 events[0] = ((raw.first_samp + raw.n_times) + 1)
 events = events[np.newaxis, :]
 assert_raises(ValueError, raw.add_events, events, 'STI 014')
 events[(0, 0)] = (raw.first_samp - 1)
 assert_raises(ValueError, raw.add_events, events, 'STI 014')
 events[(0, 0)] = (raw.first_samp + 1)
 assert_raises(ValueError, raw.add_events, events, 'STI FOO')
 raw.add_events(events, 'STI 014')
 new_events = find_events(raw, 'STI 014')
 assert_array_equal(new_events, np.concatenate((events, orig_events)))

def test_add_events ( ) : raw = read_raw_fif ( raw_fname ) events = np . array ( [ [ raw . first_samp , 0 , 1 ] ] ) assert_raises ( RuntimeError , raw . add_events , events , 'STI 014' ) raw = read_raw_fif ( raw_fname , preload = True ) orig_events = find_events ( raw , 'STI 014' ) events = np . array ( [ raw . first_samp , 0 , 1 ] ) assert_raises ( ValueError , raw . add_events , events , 'STI 014' ) events [ 0 ] = ( ( raw . first_samp + raw . n_times ) + 1 ) events = events [ np . newaxis , : ] assert_raises ( ValueError , raw . add_events , events , 'STI 014' ) events [ ( 0 , 0 ) ] = ( raw . first_samp - 1 ) assert_raises ( ValueError , raw . add_events , events , 'STI 014' ) events [ ( 0 , 0 ) ] = ( raw . first_samp + 1 ) assert_raises ( ValueError , raw . add_events , events , 'STI FOO' ) raw . add_events ( events , 'STI 014' ) new_events = find_events ( raw , 'STI 014' ) assert_array_equal ( new_events , np . concatenate ( ( events , orig_events ) ) )
test adding events to a raw file .