def test_rename_channels():
 info = read_info(raw_fname)
 mapping = {'EEG 160': 'EEG060'}
 assert_raises(ValueError, rename_channels, info, mapping)
 mapping = {'MEG 2641': 1.0}
 assert_raises(ValueError, rename_channels, info, mapping)
 mapping = {'MEG 2641': 'MEG 2642'}
 assert_raises(ValueError, rename_channels, info, mapping)
 assert_raises(ValueError, rename_channels, info, 1.0)
 info2 = deepcopy(info)
 info2['bads'] = ['EEG 060', 'EOG 061']
 mapping = {'EEG 060': 'EEG060', 'EOG 061': 'EOG061'}
 rename_channels(info2, mapping)
 assert_true((info2['chs'][374]['ch_name'] == 'EEG060'))
 assert_true((info2['ch_names'][374] == 'EEG060'))
 assert_true((info2['chs'][375]['ch_name'] == 'EOG061'))
 assert_true((info2['ch_names'][375] == 'EOG061'))
 assert_array_equal(['EEG060', 'EOG061'], info2['bads'])
 info2 = deepcopy(info)
 rename_channels(info2, (lambda x: x.replace(' ', '')))
 assert_true((info2['chs'][373]['ch_name'] == 'EEG059'))
 info2 = deepcopy(info)
 info2['bads'] = ['EEG 060', 'EEG 060']
 rename_channels(info2, mapping)
 assert_array_equal(['EEG060', 'EEG060'], info2['bads'])

def test_rename_channels ( ) : info = read_info ( raw_fname ) mapping = { 'EEG 160' : 'EEG060' } assert_raises ( ValueError , rename_channels , info , mapping ) mapping = { 'MEG 2641' : 1.0 } assert_raises ( ValueError , rename_channels , info , mapping ) mapping = { 'MEG 2641' : 'MEG 2642' } assert_raises ( ValueError , rename_channels , info , mapping ) assert_raises ( ValueError , rename_channels , info , 1.0 ) info2 = deepcopy ( info ) info2 [ 'bads' ] = [ 'EEG 060' , 'EOG 061' ] mapping = { 'EEG 060' : 'EEG060' , 'EOG 061' : 'EOG061' } rename_channels ( info2 , mapping ) assert_true ( ( info2 [ 'chs' ] [ 374 ] [ 'ch_name' ] == 'EEG060' ) ) assert_true ( ( info2 [ 'ch_names' ] [ 374 ] == 'EEG060' ) ) assert_true ( ( info2 [ 'chs' ] [ 375 ] [ 'ch_name' ] == 'EOG061' ) ) assert_true ( ( info2 [ 'ch_names' ] [ 375 ] == 'EOG061' ) ) assert_array_equal ( [ 'EEG060' , 'EOG061' ] , info2 [ 'bads' ] ) info2 = deepcopy ( info ) rename_channels ( info2 , ( lambda x : x . replace ( ' ' , '' ) ) ) assert_true ( ( info2 [ 'chs' ] [ 373 ] [ 'ch_name' ] == 'EEG059' ) ) info2 = deepcopy ( info ) info2 [ 'bads' ] = [ 'EEG 060' , 'EEG 060' ] rename_channels ( info2 , mapping ) assert_array_equal ( [ 'EEG060' , 'EEG060' ] , info2 [ 'bads' ] )
test rename channels .