{"action":"created","comment":{"url":"https://api.github.com/repos/mne-tools/mne-python/pulls/comments/52992049","id":52992049,"diff_hunk":"@@ -226,58 +262,74 @@ def predict(self, epochs):\n             raise ValueError('`test_times` must be a dict or \"diagonal\"')\n \n         if 'slices' not in test_times:\n+            if 'length' not in self.train_times_.keys():\n+                ValueError('Need test_times[\"slices\"] with adhoc train_times.')\n             # Check that same number of time sample in testing than in training\n             # (otherwise it won 't be the same number of features')\n-            if 'length' not in test_times:\n-                test_times['length'] = self.train_times_['length']\n-            if test_times['length'] != self.train_times_['length']:\n-                raise ValueError('`train_times` and `test_times` must have '\n-                                 'identical `length` keys')\n+            test_times['length'] = test_times.get('length',\n+                                                  self.train_times_['length'])\n             # Make a sliding window for each training time.\n             slices_list = list()\n-            times_list = list()\n-            for t in range(0, len(self.train_times_['slices'])):\n+            for _ in range(len(self.train_times_['slices'])):\n                 test_times_ = _sliding_window(epochs.times, test_times,\n                                               epochs.info['sfreq'])\n-                times_list += [test_times_['times']]\n                 slices_list += [test_times_['slices']]\n             test_times = test_times_\n             test_times['slices'] = slices_list\n-            test_times['times'] = times_list\n+        test_times['times'] = [_set_window_time(test, epochs.times)\n+                               for test in test_times['slices']]\n+\n+        for train, tests in zip(self.train_times_['slices'],\n+                                test_times['slices']):\n+            # The user may define irregular timing. We thus need to ensure\n+            # that the dimensionality of each estimator (i.e. training\n+            # time) corresponds to the dimensionality of each testing time)","path":"mne/decoding/time_gen.py","position":174,"original_position":196,"commit_id":"e482c90cc60ab200d43926c817c161aeaf8fca00","original_commit_id":"cd016c4dcc7a91e3944510f154bbba739b626ade","user":{"login":"jasmainak","id":15852194,"avatar_url":"https://avatars.githubusercontent.com/u/15852194?v=3","gravatar_id":"","url":"https://api.github.com/users/jasmainak","html_url":"https://github.com/jasmainak","followers_url":"https://api.github.com/users/jasmainak/followers","following_url":"https://api.github.com/users/jasmainak/following{/other_user}","gists_url":"https://api.github.com/users/jasmainak/gists{/gist_id}","starred_url":"https://api.github.com/users/jasmainak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasmainak/subscriptions","organizations_url":"https://api.github.com/users/jasmainak/orgs","repos_url":"https://api.github.com/users/jasmainak/repos","events_url":"https://api.github.com/users/jasmainak/events{/privacy}","received_events_url":"https://api.github.com/users/jasmainak/received_events","type":"User","site_admin":false},"body":"yes, fine with me.","created_at":"2016-02-16T10:22:56Z","updated_at":"2016-02-16T10:22:56Z","html_url":"https://github.com/mne-tools/mne-python/pull/2856#discussion_r52992049","pull_request_url":"https://api.github.com/repos/mne-tools/mne-python/pulls/2856","_links":{"self":{"href":"https://api.github.com/repos/mne-tools/mne-python/pulls/comments/52992049"},"html":{"href":"https://github.com/mne-tools/mne-python/pull/2856#discussion_r52992049"},"pull_request":{"href":"https://api.github.com/repos/mne-tools/mne-python/pulls/2856"}}},"pull_request":{"url":"https://api.github.com/repos/mne-tools/mne-python/pulls/2856","id":58532036,"html_url":"https://github.com/mne-tools/mne-python/pull/2856","diff_url":"https://github.com/mne-tools/mne-python/pull/2856.diff","patch_url":"https://github.com/mne-tools/mne-python/pull/2856.patch","issue_url":"https://api.github.com/repos/mne-tools/mne-python/issues/2856","number":2856,"state":"open","locked":false,"title":"ENH: GAT refactor _predict, model_selection","user":{"login":"kingjr","id":4881164,"avatar_url":"https://avatars.githubusercontent.com/u/4881164?v=3","gravatar_id":"","url":"https://api.github.com/users/kingjr","html_url":"https://github.com/kingjr","followers_url":"https://api.github.com/users/kingjr/followers","following_url":"https://api.github.com/users/kingjr/following{/other_user}","gists_url":"https://api.github.com/users/kingjr/gists{/gist_id}","starred_url":"https://api.github.com/users/kingjr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kingjr/subscriptions","organizations_url":"https://api.github.com/users/kingjr/orgs","repos_url":"https://api.github.com/users/kingjr/repos","events_url":"https://api.github.com/users/kingjr/events{/privacy}","received_events_url":"https://api.github.com/users/kingjr/received_events","type":"User","site_admin":false},"body":"* `gat.y_pred_` and `gat.scores_` are now a np.array, with same dimensionalities as before (when it used to be a list of list). np array can be irregular too, and the data reading and writing is now much faster.\r\n* cleanup the `predict` function: put all test as early as possible, segment `X` only once, before the parallel processing (some speed gain here)\r\n* accepts sklearn new model_selection cv. Closes https://github.com/mne-tools/mne-python/issues/2820\r\n* accepts non deterministic cv objects (e.g. shufflesplit @teonlamont ). Closes https://github.com/mne-tools/mne-python/issues/2596 \r\n* automatically sets cv to `KFold` and not `StratifiedKfold`in case of regression and not classification. Closes bug noted in https://github.com/mne-tools/mne-python/pull/2833.\r\n* automatically sets scoring metrics. ENH to close https://github.com/mne-tools/mne-python/issues/2176 should be an easy PR.\r\n* add test for irregular train test times definition. Here the API was actually broken (the lack of complains suggests that I am the only one who used this function...). \r\n\r\nThis last feature (having irregular training and testing time points) is one of the main factor responsible for the script complexity. I have now fixed the API, but I think we we eventually go for refactoring, we may want to just remove this option. \r\n\r\nAs discussed below, the other factors are \r\n* parallel jobs are performed across time chunks to optimize speed and  memory: this makes the CV an inside loop (unlike sklearn), and complexifies the code (we chunk the data, adjust the selected time samples accordingly etc)\r\n* we now accept other methods than `predict`. This is because most users do use `predict_proba`, so this option facilitate their work, but it is a deep departure from sklearn.","created_at":"2016-02-06T22:19:31Z","updated_at":"2016-02-16T10:22:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d62ed705f335f0e0a8f6041a34d0facb08cb539d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mne-tools/mne-python/pulls/2856/commits","review_comments_url":"https://api.github.com/repos/mne-tools/mne-python/pulls/2856/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/2856/comments","statuses_url":"https://api.github.com/repos/mne-tools/mne-python/statuses/e482c90cc60ab200d43926c817c161aeaf8fca00","head":{"label":"kingjr:gat_np_array","ref":"gat_np_array","sha":"e482c90cc60ab200d43926c817c161aeaf8fca00","user":{"login":"kingjr","id":4881164,"avatar_url":"https://avatars.githubusercontent.com/u/4881164?v=3","gravatar_id":"","url":"https://api.github.com/users/kingjr","html_url":"https://github.com/kingjr","followers_url":"https://api.github.com/users/kingjr/followers","following_url":"https://api.github.com/users/kingjr/following{/other_user}","gists_url":"https://api.github.com/users/kingjr/gists{/gist_id}","starred_url":"https://api.github.com/users/kingjr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kingjr/subscriptions","organizations_url":"https://api.github.com/users/kingjr/orgs","repos_url":"https://api.github.com/users/kingjr/repos","events_url":"https://api.github.com/users/kingjr/events{/privacy}","received_events_url":"https://api.github.com/users/kingjr/received_events","type":"User","site_admin":false},"repo":{"id":19731468,"name":"mne-python","full_name":"kingjr/mne-python","owner":{"login":"kingjr","id":4881164,"avatar_url":"https://avatars.githubusercontent.com/u/4881164?v=3","gravatar_id":"","url":"https://api.github.com/users/kingjr","html_url":"https://github.com/kingjr","followers_url":"https://api.github.com/users/kingjr/followers","following_url":"https://api.github.com/users/kingjr/following{/other_user}","gists_url":"https://api.github.com/users/kingjr/gists{/gist_id}","starred_url":"https://api.github.com/users/kingjr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kingjr/subscriptions","organizations_url":"https://api.github.com/users/kingjr/orgs","repos_url":"https://api.github.com/users/kingjr/repos","events_url":"https://api.github.com/users/kingjr/events{/privacy}","received_events_url":"https://api.github.com/users/kingjr/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kingjr/mne-python","description":"MNE : Magnetoencephalography (MEG) and Electroencephalography (EEG) in Python","fork":true,"url":"https://api.github.com/repos/kingjr/mne-python","forks_url":"https://api.github.com/repos/kingjr/mne-python/forks","keys_url":"https://api.github.com/repos/kingjr/mne-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kingjr/mne-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kingjr/mne-python/teams","hooks_url":"https://api.github.com/repos/kingjr/mne-python/hooks","issue_events_url":"https://api.github.com/repos/kingjr/mne-python/issues/events{/number}","events_url":"https://api.github.com/repos/kingjr/mne-python/events","assignees_url":"https://api.github.com/repos/kingjr/mne-python/assignees{/user}","branches_url":"https://api.github.com/repos/kingjr/mne-python/branches{/branch}","tags_url":"https://api.github.com/repos/kingjr/mne-python/tags","blobs_url":"https://api.github.com/repos/kingjr/mne-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kingjr/mne-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kingjr/mne-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/kingjr/mne-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kingjr/mne-python/statuses/{sha}","languages_url":"https://api.github.com/repos/kingjr/mne-python/languages","stargazers_url":"https://api.github.com/repos/kingjr/mne-python/stargazers","contributors_url":"https://api.github.com/repos/kingjr/mne-python/contributors","subscribers_url":"https://api.github.com/repos/kingjr/mne-python/subscribers","subscription_url":"https://api.github.com/repos/kingjr/mne-python/subscription","commits_url":"https://api.github.com/repos/kingjr/mne-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/kingjr/mne-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/kingjr/mne-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/kingjr/mne-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/kingjr/mne-python/contents/{+path}","compare_url":"https://api.github.com/repos/kingjr/mne-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kingjr/mne-python/merges","archive_url":"https://api.github.com/repos/kingjr/mne-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kingjr/mne-python/downloads","issues_url":"https://api.github.com/repos/kingjr/mne-python/issues{/number}","pulls_url":"https://api.github.com/repos/kingjr/mne-python/pulls{/number}","milestones_url":"https://api.github.com/repos/kingjr/mne-python/milestones{/number}","notifications_url":"https://api.github.com/repos/kingjr/mne-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kingjr/mne-python/labels{/name}","releases_url":"https://api.github.com/repos/kingjr/mne-python/releases{/id}","deployments_url":"https://api.github.com/repos/kingjr/mne-python/deployments","created_at":"2014-05-13T08:28:44Z","updated_at":"2014-06-02T12:58:51Z","pushed_at":"2016-02-16T02:31:07Z","git_url":"git://github.com/kingjr/mne-python.git","ssh_url":"git@github.com:kingjr/mne-python.git","clone_url":"https://github.com/kingjr/mne-python.git","svn_url":"https://github.com/kingjr/mne-python","homepage":"http://martinos.org/mne/","size":81609,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"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":"b070a510a8f4323dcddb1bc78a250dfdb271fab8","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}","deployments_url":"https://api.github.com/repos/mne-tools/mne-python/deployments","created_at":"2011-01-28T03:31:13Z","updated_at":"2016-02-16T07:46:05Z","pushed_at":"2016-02-16T08:55:43Z","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":170870,"stargazers_count":179,"watchers_count":179,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":163,"mirror_url":null,"open_issues_count":183,"forks":163,"open_issues":183,"watchers":179,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mne-tools/mne-python/pulls/2856"},"html":{"href":"https://github.com/mne-tools/mne-python/pull/2856"},"issue":{"href":"https://api.github.com/repos/mne-tools/mne-python/issues/2856"},"comments":{"href":"https://api.github.com/repos/mne-tools/mne-python/issues/2856/comments"},"review_comments":{"href":"https://api.github.com/repos/mne-tools/mne-python/pulls/2856/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/2856/commits"},"statuses":{"href":"https://api.github.com/repos/mne-tools/mne-python/statuses/e482c90cc60ab200d43926c817c161aeaf8fca00"}}}}