{"action":"created","comment":{"url":"https://api.github.com/repos/mne-tools/mne-python/pulls/comments/48777295","id":48777295,"diff_hunk":"@@ -60,8 +124,11 @@ class Info(dict):\n     bads : list of str\n         List of bad (noisy/broken) channels, by name. These channels will by\n         default be ignored by many processing steps.\n-    ch_names : list of str\n+    ch_names : instance of _ChannelNameList (read-only)","path":"mne/io/meas_info.py","position":96,"original_position":96,"commit_id":"080851496c9c932885cbb747861fb0cb2fcfbb19","original_commit_id":"080851496c9c932885cbb747861fb0cb2fcfbb19","user":{"login":"agramfort","id":161052,"avatar_url":"https://avatars.githubusercontent.com/u/161052?v=3","gravatar_id":"","url":"https://api.github.com/users/agramfort","html_url":"https://github.com/agramfort","followers_url":"https://api.github.com/users/agramfort/followers","following_url":"https://api.github.com/users/agramfort/following{/other_user}","gists_url":"https://api.github.com/users/agramfort/gists{/gist_id}","starred_url":"https://api.github.com/users/agramfort/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agramfort/subscriptions","organizations_url":"https://api.github.com/users/agramfort/orgs","repos_url":"https://api.github.com/users/agramfort/repos","events_url":"https://api.github.com/users/agramfort/events{/privacy}","received_events_url":"https://api.github.com/users/agramfort/received_events","type":"User","site_admin":false},"body":"don't expose private object in docstring\r\n\r\nI would write\r\n\r\nch_names : non-mutable list-like of str","created_at":"2016-01-04T20:31:11Z","updated_at":"2016-01-04T20:31:11Z","html_url":"https://github.com/mne-tools/mne-python/pull/2765#discussion_r48777295","pull_request_url":"https://api.github.com/repos/mne-tools/mne-python/pulls/2765","_links":{"self":{"href":"https://api.github.com/repos/mne-tools/mne-python/pulls/comments/48777295"},"html":{"href":"https://github.com/mne-tools/mne-python/pull/2765#discussion_r48777295"},"pull_request":{"href":"https://api.github.com/repos/mne-tools/mne-python/pulls/2765"}}},"pull_request":{"url":"https://api.github.com/repos/mne-tools/mne-python/pulls/2765","id":54984055,"html_url":"https://github.com/mne-tools/mne-python/pull/2765","diff_url":"https://github.com/mne-tools/mne-python/pull/2765.diff","patch_url":"https://github.com/mne-tools/mne-python/pull/2765.patch","issue_url":"https://api.github.com/repos/mne-tools/mne-python/issues/2765","number":2765,"state":"open","locked":false,"title":"[WIP] Automatic info['nchan'] and info['ch_names']","user":{"login":"wmvanvliet","id":428273,"avatar_url":"https://avatars.githubusercontent.com/u/428273?v=3","gravatar_id":"","url":"https://api.github.com/users/wmvanvliet","html_url":"https://github.com/wmvanvliet","followers_url":"https://api.github.com/users/wmvanvliet/followers","following_url":"https://api.github.com/users/wmvanvliet/following{/other_user}","gists_url":"https://api.github.com/users/wmvanvliet/gists{/gist_id}","starred_url":"https://api.github.com/users/wmvanvliet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wmvanvliet/subscriptions","organizations_url":"https://api.github.com/users/wmvanvliet/orgs","repos_url":"https://api.github.com/users/wmvanvliet/repos","events_url":"https://api.github.com/users/wmvanvliet/events{/privacy}","received_events_url":"https://api.github.com/users/wmvanvliet/received_events","type":"User","site_admin":false},"body":"The info object has two redundant fields: `nchan` and `ch_names`. They are there as convenience fields. However, whenever the `chs` list is updated, these fields need to be manually updated as well.\r\n\r\nThis PR makes these fields behave more like properties.\r\n\r\nIt does so by making `Info` a subclass of `collections.MutableMapping`, which allows it to redefine `__setitem__` and `__getitem__` while retaining full compatibility with the default Python dict.\r\n\r\nThe `nchan` field just maps to `len(info['chs'])`.\r\n\r\nThe `ch_names` field is a bit more tricky. From the outside, it behaves as a mapping to `[ch['ch_name'] for ch in info['chs']]`. However, in order not to generate a new list every time the field is accessed, the field is an instance of `_ChannelNameList`.\r\n\r\nThe `_ChannelNameList` class is a subclass of `collections.Sequence`, thus implementing a list that is read-only, but otherwise fully compatible with a normal Python list. It overwrites the `__getitem(self, index)__` method to map to `info['chs'][index]['ch_name']` on the fly. It also defines a neat `make_index_map()` function that generates a dictionary that maps channel names to integer indices, which can be used to speed things up when many lookups are needed.\r\n\r\nThe rest of the code is updated to no longer set the `nchan` and `ch_names` fields of Info objects.","created_at":"2016-01-04T15:10:00Z","updated_at":"2016-01-04T20:31:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e23f05e4c7c9fac73b7cbb18fecc39ad42c6e396","assignee":null,"milestone":{"url":"https://api.github.com/repos/mne-tools/mne-python/milestones/8","html_url":"https://github.com/mne-tools/mne-python/milestones/0.12","labels_url":"https://api.github.com/repos/mne-tools/mne-python/milestones/8/labels","id":1429321,"number":8,"title":"0.12","description":"","creator":{"login":"Eric89GXL","id":2365790,"avatar_url":"https://avatars.githubusercontent.com/u/2365790?v=3","gravatar_id":"","url":"https://api.github.com/users/Eric89GXL","html_url":"https://github.com/Eric89GXL","followers_url":"https://api.github.com/users/Eric89GXL/followers","following_url":"https://api.github.com/users/Eric89GXL/following{/other_user}","gists_url":"https://api.github.com/users/Eric89GXL/gists{/gist_id}","starred_url":"https://api.github.com/users/Eric89GXL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Eric89GXL/subscriptions","organizations_url":"https://api.github.com/users/Eric89GXL/orgs","repos_url":"https://api.github.com/users/Eric89GXL/repos","events_url":"https://api.github.com/users/Eric89GXL/events{/privacy}","received_events_url":"https://api.github.com/users/Eric89GXL/received_events","type":"User","site_admin":false},"open_issues":31,"closed_issues":9,"state":"open","created_at":"2015-11-25T13:36:18Z","updated_at":"2016-01-04T15:28:36Z","due_on":"2016-04-29T04:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/mne-tools/mne-python/pulls/2765/commits","review_comments_url":"https://api.github.com/repos/mne-tools/mne-python/pulls/2765/comments","review_comment_url":"https://api.github.com/repos/mne-tools/mne-python/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mne-tools/mne-python/issues/2765/comments","statuses_url":"https://api.github.com/repos/mne-tools/mne-python/statuses/080851496c9c932885cbb747861fb0cb2fcfbb19","head":{"label":"wmvanvliet:info_read_only_fields","ref":"info_read_only_fields","sha":"080851496c9c932885cbb747861fb0cb2fcfbb19","user":{"login":"wmvanvliet","id":428273,"avatar_url":"https://avatars.githubusercontent.com/u/428273?v=3","gravatar_id":"","url":"https://api.github.com/users/wmvanvliet","html_url":"https://github.com/wmvanvliet","followers_url":"https://api.github.com/users/wmvanvliet/followers","following_url":"https://api.github.com/users/wmvanvliet/following{/other_user}","gists_url":"https://api.github.com/users/wmvanvliet/gists{/gist_id}","starred_url":"https://api.github.com/users/wmvanvliet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wmvanvliet/subscriptions","organizations_url":"https://api.github.com/users/wmvanvliet/orgs","repos_url":"https://api.github.com/users/wmvanvliet/repos","events_url":"https://api.github.com/users/wmvanvliet/events{/privacy}","received_events_url":"https://api.github.com/users/wmvanvliet/received_events","type":"User","site_admin":false},"repo":{"id":23457160,"name":"mne-python","full_name":"wmvanvliet/mne-python","owner":{"login":"wmvanvliet","id":428273,"avatar_url":"https://avatars.githubusercontent.com/u/428273?v=3","gravatar_id":"","url":"https://api.github.com/users/wmvanvliet","html_url":"https://github.com/wmvanvliet","followers_url":"https://api.github.com/users/wmvanvliet/followers","following_url":"https://api.github.com/users/wmvanvliet/following{/other_user}","gists_url":"https://api.github.com/users/wmvanvliet/gists{/gist_id}","starred_url":"https://api.github.com/users/wmvanvliet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wmvanvliet/subscriptions","organizations_url":"https://api.github.com/users/wmvanvliet/orgs","repos_url":"https://api.github.com/users/wmvanvliet/repos","events_url":"https://api.github.com/users/wmvanvliet/events{/privacy}","received_events_url":"https://api.github.com/users/wmvanvliet/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/wmvanvliet/mne-python","description":"MNE : Magnetoencephalography (MEG) and Electroencephalography (EEG) in Python","fork":true,"url":"https://api.github.com/repos/wmvanvliet/mne-python","forks_url":"https://api.github.com/repos/wmvanvliet/mne-python/forks","keys_url":"https://api.github.com/repos/wmvanvliet/mne-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wmvanvliet/mne-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wmvanvliet/mne-python/teams","hooks_url":"https://api.github.com/repos/wmvanvliet/mne-python/hooks","issue_events_url":"https://api.github.com/repos/wmvanvliet/mne-python/issues/events{/number}","events_url":"https://api.github.com/repos/wmvanvliet/mne-python/events","assignees_url":"https://api.github.com/repos/wmvanvliet/mne-python/assignees{/user}","branches_url":"https://api.github.com/repos/wmvanvliet/mne-python/branches{/branch}","tags_url":"https://api.github.com/repos/wmvanvliet/mne-python/tags","blobs_url":"https://api.github.com/repos/wmvanvliet/mne-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wmvanvliet/mne-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wmvanvliet/mne-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/wmvanvliet/mne-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wmvanvliet/mne-python/statuses/{sha}","languages_url":"https://api.github.com/repos/wmvanvliet/mne-python/languages","stargazers_url":"https://api.github.com/repos/wmvanvliet/mne-python/stargazers","contributors_url":"https://api.github.com/repos/wmvanvliet/mne-python/contributors","subscribers_url":"https://api.github.com/repos/wmvanvliet/mne-python/subscribers","subscription_url":"https://api.github.com/repos/wmvanvliet/mne-python/subscription","commits_url":"https://api.github.com/repos/wmvanvliet/mne-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/wmvanvliet/mne-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/wmvanvliet/mne-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/wmvanvliet/mne-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/wmvanvliet/mne-python/contents/{+path}","compare_url":"https://api.github.com/repos/wmvanvliet/mne-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wmvanvliet/mne-python/merges","archive_url":"https://api.github.com/repos/wmvanvliet/mne-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wmvanvliet/mne-python/downloads","issues_url":"https://api.github.com/repos/wmvanvliet/mne-python/issues{/number}","pulls_url":"https://api.github.com/repos/wmvanvliet/mne-python/pulls{/number}","milestones_url":"https://api.github.com/repos/wmvanvliet/mne-python/milestones{/number}","notifications_url":"https://api.github.com/repos/wmvanvliet/mne-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wmvanvliet/mne-python/labels{/name}","releases_url":"https://api.github.com/repos/wmvanvliet/mne-python/releases{/id}","created_at":"2014-08-29T08:06:25Z","updated_at":"2015-05-08T07:28:50Z","pushed_at":"2016-01-04T15:07:55Z","git_url":"git://github.com/wmvanvliet/mne-python.git","ssh_url":"git@github.com:wmvanvliet/mne-python.git","clone_url":"https://github.com/wmvanvliet/mne-python.git","svn_url":"https://github.com/wmvanvliet/mne-python","homepage":"http://martinos.org/mne/","size":80052,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"mne-tools:master","ref":"master","sha":"1ce476786f9d39ee3f3a43f05fb67b5bc4a7fcda","user":{"login":"mne-tools","id":583875,"avatar_url":"https://avatars.githubusercontent.com/u/583875?v=3","gravatar_id":"","url":"https://api.github.com/users/mne-tools","html_url":"https://github.com/mne-tools","followers_url":"https://api.github.com/users/mne-tools/followers","following_url":"https://api.github.com/users/mne-tools/following{/other_user}","gists_url":"https://api.github.com/users/mne-tools/gists{/gist_id}","starred_url":"https://api.github.com/users/mne-tools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mne-tools/subscriptions","organizations_url":"https://api.github.com/users/mne-tools/orgs","repos_url":"https://api.github.com/users/mne-tools/repos","events_url":"https://api.github.com/users/mne-tools/events{/privacy}","received_events_url":"https://api.github.com/users/mne-tools/received_events","type":"Organization","site_admin":false},"repo":{"id":1301584,"name":"mne-python","full_name":"mne-tools/mne-python","owner":{"login":"mne-tools","id":583875,"avatar_url":"https://avatars.githubusercontent.com/u/583875?v=3","gravatar_id":"","url":"https://api.github.com/users/mne-tools","html_url":"https://github.com/mne-tools","followers_url":"https://api.github.com/users/mne-tools/followers","following_url":"https://api.github.com/users/mne-tools/following{/other_user}","gists_url":"https://api.github.com/users/mne-tools/gists{/gist_id}","starred_url":"https://api.github.com/users/mne-tools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mne-tools/subscriptions","organizations_url":"https://api.github.com/users/mne-tools/orgs","repos_url":"https://api.github.com/users/mne-tools/repos","events_url":"https://api.github.com/users/mne-tools/events{/privacy}","received_events_url":"https://api.github.com/users/mne-tools/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mne-tools/mne-python","description":"MNE : Magnetoencephalography (MEG) and Electroencephalography (EEG) in Python","fork":false,"url":"https://api.github.com/repos/mne-tools/mne-python","forks_url":"https://api.github.com/repos/mne-tools/mne-python/forks","keys_url":"https://api.github.com/repos/mne-tools/mne-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mne-tools/mne-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mne-tools/mne-python/teams","hooks_url":"https://api.github.com/repos/mne-tools/mne-python/hooks","issue_events_url":"https://api.github.com/repos/mne-tools/mne-python/issues/events{/number}","events_url":"https://api.github.com/repos/mne-tools/mne-python/events","assignees_url":"https://api.github.com/repos/mne-tools/mne-python/assignees{/user}","branches_url":"https://api.github.com/repos/mne-tools/mne-python/branches{/branch}","tags_url":"https://api.github.com/repos/mne-tools/mne-python/tags","blobs_url":"https://api.github.com/repos/mne-tools/mne-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mne-tools/mne-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mne-tools/mne-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/mne-tools/mne-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mne-tools/mne-python/statuses/{sha}","languages_url":"https://api.github.com/repos/mne-tools/mne-python/languages","stargazers_url":"https://api.github.com/repos/mne-tools/mne-python/stargazers","contributors_url":"https://api.github.com/repos/mne-tools/mne-python/contributors","subscribers_url":"https://api.github.com/repos/mne-tools/mne-python/subscribers","subscription_url":"https://api.github.com/repos/mne-tools/mne-python/subscription","commits_url":"https://api.github.com/repos/mne-tools/mne-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/mne-tools/mne-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/mne-tools/mne-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/mne-tools/mne-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/mne-tools/mne-python/contents/{+path}","compare_url":"https://api.github.com/repos/mne-tools/mne-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mne-tools/mne-python/merges","archive_url":"https://api.github.com/repos/mne-tools/mne-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mne-tools/mne-python/downloads","issues_url":"https://api.github.com/repos/mne-tools/mne-python/issues{/number}","pulls_url":"https://api.github.com/repos/mne-tools/mne-python/pulls{/number}","milestones_url":"https://api.github.com/repos/mne-tools/mne-python/milestones{/number}","notifications_url":"https://api.github.com/repos/mne-tools/mne-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mne-tools/mne-python/labels{/name}","releases_url":"https://api.github.com/repos/mne-tools/mne-python/releases{/id}","created_at":"2011-01-28T03:31:13Z","updated_at":"2016-01-01T19:19:46Z","pushed_at":"2016-01-04T15:10:00Z","git_url":"git://github.com/mne-tools/mne-python.git","ssh_url":"git@github.com:mne-tools/mne-python.git","clone_url":"https://github.com/mne-tools/mne-python.git","svn_url":"https://github.com/mne-tools/mne-python","homepage":"http://martinos.org/mne/","size":169454,"stargazers_count":170,"watchers_count":170,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":156,"mirror_url":null,"open_issues_count":164,"forks":156,"open_issues":164,"watchers":170,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mne-tools/mne-python/pulls/2765"},"html":{"href":"https://github.com/mne-tools/mne-python/pull/2765"},"issue":{"href":"https://api.github.com/repos/mne-tools/mne-python/issues/2765"},"comments":{"href":"https://api.github.com/repos/mne-tools/mne-python/issues/2765/comments"},"review_comments":{"href":"https://api.github.com/repos/mne-tools/mne-python/pulls/2765/comments"},"review_comment":{"href":"https://api.github.com/repos/mne-tools/mne-python/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mne-tools/mne-python/pulls/2765/commits"},"statuses":{"href":"https://api.github.com/repos/mne-tools/mne-python/statuses/080851496c9c932885cbb747861fb0cb2fcfbb19"}}}}