

def test_rename_channels():
    'Test rename channels\n    '
    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)
    mapping['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'])

dataset/ETHPy150Open mne-tools/mne-python/mne/channels/tests/test_channels.py test_rename_channels/VarMisuse@102/156 `info2`->`mapping`