def test_info(): """Test info object.""" raw = read_raw_fif(raw_fname) event_id, tmin, tmax = 1, -0.2, 0.5 events = read_events(event_name) event_id = int(events[0, 2]) epochs = Epochs(raw, events[:1], event_id, tmin, tmax, picks=None) evoked = epochs.average() # Test subclassing was successful. info = Info(a=7, b='aaaaa') assert ('a' in info) assert ('b' in info) info[42] = 'foo' assert (info[42] == 'foo') # Test info attribute in API objects for obj in [raw, epochs, evoked]: assert (isinstance(obj.info, Info)) info_str = '%s' % obj.info assert len(info_str.split('\n')) == len(obj.info.keys()) + 2 assert all(k in info_str for k in obj.info.keys()) rep = repr(obj.info) assert '2002-12-03 19:01:10 GMT' in rep, rep assert '146 items (3 Cardinal, 4 HPI, 61 EEG, 78 Extra)' in rep dig_rep = repr(obj.info['dig'][0]) assert 'LPA' in dig_rep, dig_rep assert '(-71.4, 0.0, 0.0) mm' in dig_rep, dig_rep assert 'head frame' in dig_rep, dig_rep # Test our BunchConstNamed support for func in (str, repr): assert '4 (FIFFV_COORD_HEAD)' == \ func(obj.info['dig'][0]['coord_frame']) # Test read-only fields info = raw.info.copy() nchan = len(info['chs']) ch_names = [ch['ch_name'] for ch in info['chs']] assert info['nchan'] == nchan assert list(info['ch_names']) == ch_names # Deleting of regular fields should work info['foo'] = 'bar' del info['foo'] # Test updating of fields del info['chs'][-1] info._update_redundant() assert info['nchan'] == nchan - 1 assert list(info['ch_names']) == ch_names[:-1] info['chs'][0]['ch_name'] = 'foo' info._update_redundant() assert info['ch_names'][0] == 'foo' # Test casting to and from a dict info_dict = dict(info) info2 = Info(info_dict) assert info == info2
def test_info(): """Test info object.""" raw = read_raw_fif(raw_fname, add_eeg_ref=False) event_id, tmin, tmax = 1, -0.2, 0.5 events = read_events(event_name) event_id = int(events[0, 2]) epochs = Epochs(raw, events[:1], event_id, tmin, tmax, picks=None, baseline=(None, 0), add_eeg_ref=False) evoked = epochs.average() events = read_events(event_name) # Test subclassing was successful. info = Info(a=7, b='aaaaa') assert_true('a' in info) assert_true('b' in info) info[42] = 'foo' assert_true(info[42] == 'foo') # Test info attribute in API objects for obj in [raw, epochs, evoked]: assert_true(isinstance(obj.info, Info)) info_str = '%s' % obj.info assert_equal(len(info_str.split('\n')), len(obj.info.keys()) + 2) assert_true(all(k in info_str for k in obj.info.keys())) # Test read-only fields info = raw.info.copy() nchan = len(info['chs']) ch_names = [ch['ch_name'] for ch in info['chs']] assert_equal(info['nchan'], nchan) assert_equal(list(info['ch_names']), ch_names) # Deleting of regular fields should work info['foo'] = 'bar' del info['foo'] # Test updating of fields del info['chs'][-1] info._update_redundant() assert_equal(info['nchan'], nchan - 1) assert_equal(list(info['ch_names']), ch_names[:-1]) info['chs'][0]['ch_name'] = 'foo' info._update_redundant() assert_equal(info['ch_names'][0], 'foo') # Test casting to and from a dict info_dict = dict(info) info2 = Info(info_dict) assert_equal(info, info2)
def test_info(): """Test info object.""" raw = read_raw_fif(raw_fname) event_id, tmin, tmax = 1, -0.2, 0.5 events = read_events(event_name) event_id = int(events[0, 2]) epochs = Epochs(raw, events[:1], event_id, tmin, tmax, picks=None, baseline=(None, 0)) evoked = epochs.average() # Test subclassing was successful. info = Info(a=7, b='aaaaa') assert ('a' in info) assert ('b' in info) info[42] = 'foo' assert (info[42] == 'foo') # Test info attribute in API objects for obj in [raw, epochs, evoked]: assert (isinstance(obj.info, Info)) info_str = '%s' % obj.info assert len(info_str.split('\n')) == len(obj.info.keys()) + 2 assert all(k in info_str for k in obj.info.keys()) assert '2002-12-03 19:01:10 GMT' in repr(obj.info), repr(obj.info) # Test read-only fields info = raw.info.copy() nchan = len(info['chs']) ch_names = [ch['ch_name'] for ch in info['chs']] assert info['nchan'] == nchan assert list(info['ch_names']) == ch_names # Deleting of regular fields should work info['foo'] = 'bar' del info['foo'] # Test updating of fields del info['chs'][-1] info._update_redundant() assert info['nchan'] == nchan - 1 assert list(info['ch_names']) == ch_names[:-1] info['chs'][0]['ch_name'] = 'foo' info._update_redundant() assert info['ch_names'][0] == 'foo' # Test casting to and from a dict info_dict = dict(info) info2 = Info(info_dict) assert info == info2
def test_info(): """Test info object""" raw = Raw(raw_fname) event_id, tmin, tmax = 1, -0.2, 0.5 events = read_events(event_name) event_id = int(events[0, 2]) epochs = Epochs(raw, events[:1], event_id, tmin, tmax, picks=None, baseline=(None, 0)) evoked = epochs.average() events = read_events(event_name) # Test subclassing was successful. info = Info(a=7, b='aaaaa') assert_true('a' in info) assert_true('b' in info) info[42] = 'foo' assert_true(info[42] == 'foo') # Test info attribute in API objects for obj in [raw, epochs, evoked]: assert_true(isinstance(obj.info, Info)) info_str = '%s' % obj.info assert_equal(len(info_str.split('\n')), len(obj.info.keys()) + 2) assert_true(all(k in info_str for k in obj.info.keys())) # Test read-only fields info = raw.info.copy() nchan = len(info['chs']) ch_names = [ch['ch_name'] for ch in info['chs']] assert_equal(info['nchan'], nchan) assert_equal(list(info['ch_names']), ch_names) # Deleting of regular fields should work info['foo'] = 'bar' del info['foo'] # Test updating of fields del info['chs'][-1] info._update_redundant() assert_equal(info['nchan'], nchan - 1) assert_equal(list(info['ch_names']), ch_names[:-1]) info['chs'][0]['ch_name'] = 'foo' info._update_redundant() assert_equal(info['ch_names'][0], 'foo') # Test casting to and from a dict info_dict = dict(info) info2 = Info(info_dict) assert_equal(info, info2)
def test_info(): """Test info object.""" raw = read_raw_fif(raw_fname) event_id, tmin, tmax = 1, -0.2, 0.5 events = read_events(event_name) event_id = int(events[0, 2]) epochs = Epochs(raw, events[:1], event_id, tmin, tmax, picks=None, baseline=(None, 0)) evoked = epochs.average() # Test subclassing was successful. info = Info(a=7, b='aaaaa') assert ('a' in info) assert ('b' in info) info[42] = 'foo' assert (info[42] == 'foo') # Test info attribute in API objects for obj in [raw, epochs, evoked]: assert (isinstance(obj.info, Info)) info_str = '%s' % obj.info assert len(info_str.split('\n')) == len(obj.info.keys()) + 2 assert all(k in info_str for k in obj.info.keys()) assert '2002-12-03 19:01:10 GMT' in repr(obj.info), repr(obj.info) # Test read-only fields info = raw.info.copy() nchan = len(info['chs']) ch_names = [ch['ch_name'] for ch in info['chs']] assert info['nchan'] == nchan assert list(info['ch_names']) == ch_names # Deleting of regular fields should work info['foo'] = 'bar' del info['foo'] # Test updating of fields del info['chs'][-1] info._update_redundant() assert info['nchan'] == nchan - 1 assert list(info['ch_names']) == ch_names[:-1] info['chs'][0]['ch_name'] = 'foo' info._update_redundant() assert info['ch_names'][0] == 'foo' # Test casting to and from a dict info_dict = dict(info) info2 = Info(info_dict) assert info == info2
def test_info(): """Test info object.""" raw = read_raw_fif(raw_fname) event_id, tmin, tmax = 1, -0.2, 0.5 events = read_events(event_name) event_id = int(events[0, 2]) epochs = Epochs(raw, events[:1], event_id, tmin, tmax, picks=None, baseline=(None, 0)) evoked = epochs.average() events = read_events(event_name) # Test subclassing was successful. info = Info(a=7, b="aaaaa") assert_true("a" in info) assert_true("b" in info) info[42] = "foo" assert_true(info[42] == "foo") # Test info attribute in API objects for obj in [raw, epochs, evoked]: assert_true(isinstance(obj.info, Info)) info_str = "%s" % obj.info assert_equal(len(info_str.split("\n")), len(obj.info.keys()) + 2) assert_true(all(k in info_str for k in obj.info.keys())) # Test read-only fields info = raw.info.copy() nchan = len(info["chs"]) ch_names = [ch["ch_name"] for ch in info["chs"]] assert_equal(info["nchan"], nchan) assert_equal(list(info["ch_names"]), ch_names) # Deleting of regular fields should work info["foo"] = "bar" del info["foo"] # Test updating of fields del info["chs"][-1] info._update_redundant() assert_equal(info["nchan"], nchan - 1) assert_equal(list(info["ch_names"]), ch_names[:-1]) info["chs"][0]["ch_name"] = "foo" info._update_redundant() assert_equal(info["ch_names"][0], "foo") # Test casting to and from a dict info_dict = dict(info) info2 = Info(info_dict) assert_equal(info, info2)
def test_info(): """Test info object.""" raw = read_raw_fif(raw_fname) event_id, tmin, tmax = 1, -0.2, 0.5 events = read_events(event_name) event_id = int(events[0, 2]) epochs = Epochs(raw, events[:1], event_id, tmin, tmax, picks=None, baseline=(None, 0)) evoked = epochs.average() # Test subclassing was successful. info = Info(a=7, b='aaaaa') assert ('a' in info) assert ('b' in info) info[42] = 'foo' assert (info[42] == 'foo') # Test info attribute in API objects for obj in [raw, epochs, evoked]: assert (isinstance(obj.info, Info)) info_str = '%s' % obj.info assert len(info_str.split('\n')) == len(obj.info.keys()) + 2 assert all(k in info_str for k in obj.info.keys()) rep = repr(obj.info) assert '2002-12-03 19:01:10 GMT' in rep, rep assert '146 items (3 Cardinal, 4 HPI, 61 EEG, 78 Extra)' in rep dig_rep = repr(obj.info['dig'][0]) assert 'LPA' in dig_rep, dig_rep assert '(-71.4, 0.0, 0.0) mm' in dig_rep, dig_rep assert 'head frame' in dig_rep, dig_rep # Test our BunchConstNamed support for func in (str, repr): assert '4 (FIFFV_COORD_HEAD)' == \ func(obj.info['dig'][0]['coord_frame']) # Test read-only fields info = raw.info.copy() nchan = len(info['chs']) ch_names = [ch['ch_name'] for ch in info['chs']] assert info['nchan'] == nchan assert list(info['ch_names']) == ch_names # Deleting of regular fields should work info['foo'] = 'bar' del info['foo'] # Test updating of fields del info['chs'][-1] info._update_redundant() assert info['nchan'] == nchan - 1 assert list(info['ch_names']) == ch_names[:-1] info['chs'][0]['ch_name'] = 'foo' info._update_redundant() assert info['ch_names'][0] == 'foo' # Test casting to and from a dict info_dict = dict(info) info2 = Info(info_dict) assert info == info2