{"action":"created","comment":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments/33910626","id":33910626,"diff_hunk":"@@ -697,5 +703,34 @@ def check_skip_travis():\n     if os.environ.get('TRAVIS') == \"true\":\n         raise SkipTest(\"This test needs to be skipped on Travis\")\n \n+\n+def _delete_folder(folder_path, warn=False):\n+    \"\"\"Utility function to cleanup a temporary folder if still existing.\n+    Copy from joblib.pool (for independance)\"\"\"\n+    try:\n+        if os.path.exists(folder_path):\n+            shutil.rmtree(folder_path)  # This can fail under windows, but will succeed when called by atexit\n+    except shutil.WindowsError:\n+        if warn:\n+            warnings.warn(\"Could not delete temporary folder %s\" % folder_path)\n+\n+\n+class TempMemmap(object):\n+    def __init__(self, data, mmap_mode='r'):\n+        self.temp_folder = tempfile.mkdtemp(prefix='sklearn_testing_')\n+        self.mmap_mode = mmap_mode\n+        self.data = data\n+\n+    def __enter__(self):\n+        fpath = op.join(self.temp_folder, 'data.pkl')\n+        joblib.dump(self.data, fpath)\n+        data_read_only = joblib.load(fpath, mmap_mode=self.mmap_mode)\n+        atexit.register(lambda: _delete_folder(self.temp_folder, warn=True))\n+        return data_read_only\n+\n+    def __exit__(self, exc_type, exc_val, exc_tb):\n+        _delete_folder(self.temp_folder)","path":"sklearn/utils/testing.py","position":45,"original_position":45,"commit_id":"8f565ff6ed1962c8c5d22296443257a9c7900f2c","original_commit_id":"8f565ff6ed1962c8c5d22296443257a9c7900f2c","user":{"login":"arthurmensch","id":4078691,"avatar_url":"https://avatars.githubusercontent.com/u/4078691?v=3","gravatar_id":"","url":"https://api.github.com/users/arthurmensch","html_url":"https://github.com/arthurmensch","followers_url":"https://api.github.com/users/arthurmensch/followers","following_url":"https://api.github.com/users/arthurmensch/following{/other_user}","gists_url":"https://api.github.com/users/arthurmensch/gists{/gist_id}","starred_url":"https://api.github.com/users/arthurmensch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arthurmensch/subscriptions","organizations_url":"https://api.github.com/users/arthurmensch/orgs","repos_url":"https://api.github.com/users/arthurmensch/repos","events_url":"https://api.github.com/users/arthurmensch/events{/privacy}","received_events_url":"https://api.github.com/users/arthurmensch/received_events","type":"User","site_admin":false},"body":"It is used in specific read only mode test in `test_dict_learning` and `test_coordinate_descent`, and `test_least_square`","created_at":"2015-07-06T07:24:16Z","updated_at":"2015-07-06T07:24:16Z","html_url":"https://github.com/scikit-learn/scikit-learn/pull/4807#discussion_r33910626","pull_request_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/4807","_links":{"self":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments/33910626"},"html":{"href":"https://github.com/scikit-learn/scikit-learn/pull/4807#discussion_r33910626"},"pull_request":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/4807"}}},"pull_request":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/4807","id":36807118,"html_url":"https://github.com/scikit-learn/scikit-learn/pull/4807","diff_url":"https://github.com/scikit-learn/scikit-learn/pull/4807.diff","patch_url":"https://github.com/scikit-learn/scikit-learn/pull/4807.patch","issue_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/4807","number":4807,"state":"open","locked":false,"title":"[MRG+1] Read-only input data in common tests","user":{"login":"arthurmensch","id":4078691,"avatar_url":"https://avatars.githubusercontent.com/u/4078691?v=3","gravatar_id":"","url":"https://api.github.com/users/arthurmensch","html_url":"https://github.com/arthurmensch","followers_url":"https://api.github.com/users/arthurmensch/followers","following_url":"https://api.github.com/users/arthurmensch/following{/other_user}","gists_url":"https://api.github.com/users/arthurmensch/gists{/gist_id}","starred_url":"https://api.github.com/users/arthurmensch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arthurmensch/subscriptions","organizations_url":"https://api.github.com/users/arthurmensch/orgs","repos_url":"https://api.github.com/users/arthurmensch/repos","events_url":"https://api.github.com/users/arthurmensch/events{/privacy}","received_events_url":"https://api.github.com/users/arthurmensch/received_events","type":"User","site_admin":false},"body":"Following PR #4775, I added checks in estimator checks in order to verify `Estimator` behavior on read only mem-mapped data.\r\n\r\nA few issues there :\r\n- [ ] registering _clean_temp_memory with atexit yield failure, as it called at the end of every test, and delete _TEMP_MEMORY whereas the next test has already begun.\r\n- [ ] I overloaded make_blobs into _make_blobs in order to be able to easily yield a read-only memmap X which is only positive. This looks quite messy though.\r\n- [ ] cf PR #4775, this does not introduce tests that fails on current master, whereas `sklearn/linear_model/cd_fast.pyx` still raise errors on some use cases. This is related to the fact that we cannot make Lasso fails using simple read-only memmap as input.","created_at":"2015-06-03T08:02:48Z","updated_at":"2015-07-06T07:24:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f6f460af3035ff806743fa3fb0bff2140cb09006","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/4807/commits","review_comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/4807/comments","review_comment_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments{/number}","comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/4807/comments","statuses_url":"https://api.github.com/repos/scikit-learn/scikit-learn/statuses/8f565ff6ed1962c8c5d22296443257a9c7900f2c","head":{"label":"arthurmensch:common_test_read_only_improvement","ref":"common_test_read_only_improvement","sha":"8f565ff6ed1962c8c5d22296443257a9c7900f2c","user":{"login":"arthurmensch","id":4078691,"avatar_url":"https://avatars.githubusercontent.com/u/4078691?v=3","gravatar_id":"","url":"https://api.github.com/users/arthurmensch","html_url":"https://github.com/arthurmensch","followers_url":"https://api.github.com/users/arthurmensch/followers","following_url":"https://api.github.com/users/arthurmensch/following{/other_user}","gists_url":"https://api.github.com/users/arthurmensch/gists{/gist_id}","starred_url":"https://api.github.com/users/arthurmensch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arthurmensch/subscriptions","organizations_url":"https://api.github.com/users/arthurmensch/orgs","repos_url":"https://api.github.com/users/arthurmensch/repos","events_url":"https://api.github.com/users/arthurmensch/events{/privacy}","received_events_url":"https://api.github.com/users/arthurmensch/received_events","type":"User","site_admin":false},"repo":{"id":36289937,"name":"scikit-learn","full_name":"arthurmensch/scikit-learn","owner":{"login":"arthurmensch","id":4078691,"avatar_url":"https://avatars.githubusercontent.com/u/4078691?v=3","gravatar_id":"","url":"https://api.github.com/users/arthurmensch","html_url":"https://github.com/arthurmensch","followers_url":"https://api.github.com/users/arthurmensch/followers","following_url":"https://api.github.com/users/arthurmensch/following{/other_user}","gists_url":"https://api.github.com/users/arthurmensch/gists{/gist_id}","starred_url":"https://api.github.com/users/arthurmensch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arthurmensch/subscriptions","organizations_url":"https://api.github.com/users/arthurmensch/orgs","repos_url":"https://api.github.com/users/arthurmensch/repos","events_url":"https://api.github.com/users/arthurmensch/events{/privacy}","received_events_url":"https://api.github.com/users/arthurmensch/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/arthurmensch/scikit-learn","description":"scikit-learn: machine learning in Python","fork":true,"url":"https://api.github.com/repos/arthurmensch/scikit-learn","forks_url":"https://api.github.com/repos/arthurmensch/scikit-learn/forks","keys_url":"https://api.github.com/repos/arthurmensch/scikit-learn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/arthurmensch/scikit-learn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/arthurmensch/scikit-learn/teams","hooks_url":"https://api.github.com/repos/arthurmensch/scikit-learn/hooks","issue_events_url":"https://api.github.com/repos/arthurmensch/scikit-learn/issues/events{/number}","events_url":"https://api.github.com/repos/arthurmensch/scikit-learn/events","assignees_url":"https://api.github.com/repos/arthurmensch/scikit-learn/assignees{/user}","branches_url":"https://api.github.com/repos/arthurmensch/scikit-learn/branches{/branch}","tags_url":"https://api.github.com/repos/arthurmensch/scikit-learn/tags","blobs_url":"https://api.github.com/repos/arthurmensch/scikit-learn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/arthurmensch/scikit-learn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/arthurmensch/scikit-learn/git/refs{/sha}","trees_url":"https://api.github.com/repos/arthurmensch/scikit-learn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/arthurmensch/scikit-learn/statuses/{sha}","languages_url":"https://api.github.com/repos/arthurmensch/scikit-learn/languages","stargazers_url":"https://api.github.com/repos/arthurmensch/scikit-learn/stargazers","contributors_url":"https://api.github.com/repos/arthurmensch/scikit-learn/contributors","subscribers_url":"https://api.github.com/repos/arthurmensch/scikit-learn/subscribers","subscription_url":"https://api.github.com/repos/arthurmensch/scikit-learn/subscription","commits_url":"https://api.github.com/repos/arthurmensch/scikit-learn/commits{/sha}","git_commits_url":"https://api.github.com/repos/arthurmensch/scikit-learn/git/commits{/sha}","comments_url":"https://api.github.com/repos/arthurmensch/scikit-learn/comments{/number}","issue_comment_url":"https://api.github.com/repos/arthurmensch/scikit-learn/issues/comments{/number}","contents_url":"https://api.github.com/repos/arthurmensch/scikit-learn/contents/{+path}","compare_url":"https://api.github.com/repos/arthurmensch/scikit-learn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/arthurmensch/scikit-learn/merges","archive_url":"https://api.github.com/repos/arthurmensch/scikit-learn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/arthurmensch/scikit-learn/downloads","issues_url":"https://api.github.com/repos/arthurmensch/scikit-learn/issues{/number}","pulls_url":"https://api.github.com/repos/arthurmensch/scikit-learn/pulls{/number}","milestones_url":"https://api.github.com/repos/arthurmensch/scikit-learn/milestones{/number}","notifications_url":"https://api.github.com/repos/arthurmensch/scikit-learn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/arthurmensch/scikit-learn/labels{/name}","releases_url":"https://api.github.com/repos/arthurmensch/scikit-learn/releases{/id}","created_at":"2015-05-26T10:53:11Z","updated_at":"2015-05-26T10:53:18Z","pushed_at":"2015-07-06T07:17:19Z","git_url":"git://github.com/arthurmensch/scikit-learn.git","ssh_url":"git@github.com:arthurmensch/scikit-learn.git","clone_url":"https://github.com/arthurmensch/scikit-learn.git","svn_url":"https://github.com/arthurmensch/scikit-learn","homepage":"http://scikit-learn.org","size":64046,"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":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"scikit-learn:master","ref":"master","sha":"6a4aa3a9dfd9c6894ce6a07e4ee8e62f3415e91b","user":{"login":"scikit-learn","id":365630,"avatar_url":"https://avatars.githubusercontent.com/u/365630?v=3","gravatar_id":"","url":"https://api.github.com/users/scikit-learn","html_url":"https://github.com/scikit-learn","followers_url":"https://api.github.com/users/scikit-learn/followers","following_url":"https://api.github.com/users/scikit-learn/following{/other_user}","gists_url":"https://api.github.com/users/scikit-learn/gists{/gist_id}","starred_url":"https://api.github.com/users/scikit-learn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scikit-learn/subscriptions","organizations_url":"https://api.github.com/users/scikit-learn/orgs","repos_url":"https://api.github.com/users/scikit-learn/repos","events_url":"https://api.github.com/users/scikit-learn/events{/privacy}","received_events_url":"https://api.github.com/users/scikit-learn/received_events","type":"Organization","site_admin":false},"repo":{"id":843222,"name":"scikit-learn","full_name":"scikit-learn/scikit-learn","owner":{"login":"scikit-learn","id":365630,"avatar_url":"https://avatars.githubusercontent.com/u/365630?v=3","gravatar_id":"","url":"https://api.github.com/users/scikit-learn","html_url":"https://github.com/scikit-learn","followers_url":"https://api.github.com/users/scikit-learn/followers","following_url":"https://api.github.com/users/scikit-learn/following{/other_user}","gists_url":"https://api.github.com/users/scikit-learn/gists{/gist_id}","starred_url":"https://api.github.com/users/scikit-learn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scikit-learn/subscriptions","organizations_url":"https://api.github.com/users/scikit-learn/orgs","repos_url":"https://api.github.com/users/scikit-learn/repos","events_url":"https://api.github.com/users/scikit-learn/events{/privacy}","received_events_url":"https://api.github.com/users/scikit-learn/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/scikit-learn/scikit-learn","description":"scikit-learn: machine learning in Python","fork":false,"url":"https://api.github.com/repos/scikit-learn/scikit-learn","forks_url":"https://api.github.com/repos/scikit-learn/scikit-learn/forks","keys_url":"https://api.github.com/repos/scikit-learn/scikit-learn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scikit-learn/scikit-learn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scikit-learn/scikit-learn/teams","hooks_url":"https://api.github.com/repos/scikit-learn/scikit-learn/hooks","issue_events_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/events{/number}","events_url":"https://api.github.com/repos/scikit-learn/scikit-learn/events","assignees_url":"https://api.github.com/repos/scikit-learn/scikit-learn/assignees{/user}","branches_url":"https://api.github.com/repos/scikit-learn/scikit-learn/branches{/branch}","tags_url":"https://api.github.com/repos/scikit-learn/scikit-learn/tags","blobs_url":"https://api.github.com/repos/scikit-learn/scikit-learn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scikit-learn/scikit-learn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scikit-learn/scikit-learn/git/refs{/sha}","trees_url":"https://api.github.com/repos/scikit-learn/scikit-learn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scikit-learn/scikit-learn/statuses/{sha}","languages_url":"https://api.github.com/repos/scikit-learn/scikit-learn/languages","stargazers_url":"https://api.github.com/repos/scikit-learn/scikit-learn/stargazers","contributors_url":"https://api.github.com/repos/scikit-learn/scikit-learn/contributors","subscribers_url":"https://api.github.com/repos/scikit-learn/scikit-learn/subscribers","subscription_url":"https://api.github.com/repos/scikit-learn/scikit-learn/subscription","commits_url":"https://api.github.com/repos/scikit-learn/scikit-learn/commits{/sha}","git_commits_url":"https://api.github.com/repos/scikit-learn/scikit-learn/git/commits{/sha}","comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/comments{/number}","issue_comment_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/comments{/number}","contents_url":"https://api.github.com/repos/scikit-learn/scikit-learn/contents/{+path}","compare_url":"https://api.github.com/repos/scikit-learn/scikit-learn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scikit-learn/scikit-learn/merges","archive_url":"https://api.github.com/repos/scikit-learn/scikit-learn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scikit-learn/scikit-learn/downloads","issues_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues{/number}","pulls_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls{/number}","milestones_url":"https://api.github.com/repos/scikit-learn/scikit-learn/milestones{/number}","notifications_url":"https://api.github.com/repos/scikit-learn/scikit-learn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scikit-learn/scikit-learn/labels{/name}","releases_url":"https://api.github.com/repos/scikit-learn/scikit-learn/releases{/id}","created_at":"2010-08-17T09:43:38Z","updated_at":"2015-07-06T06:20:21Z","pushed_at":"2015-07-06T07:17:21Z","git_url":"git://github.com/scikit-learn/scikit-learn.git","ssh_url":"git@github.com:scikit-learn/scikit-learn.git","clone_url":"https://github.com/scikit-learn/scikit-learn.git","svn_url":"https://github.com/scikit-learn/scikit-learn","homepage":"http://scikit-learn.org","size":127201,"stargazers_count":6621,"watchers_count":6621,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3966,"mirror_url":null,"open_issues_count":700,"forks":3966,"open_issues":700,"watchers":6621,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/4807"},"html":{"href":"https://github.com/scikit-learn/scikit-learn/pull/4807"},"issue":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/4807"},"comments":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/4807/comments"},"review_comments":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/4807/comments"},"review_comment":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/4807/commits"},"statuses":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/statuses/8f565ff6ed1962c8c5d22296443257a9c7900f2c"}}}}