{"action":"created","comment":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments/84761351","pull_request_review_id":5518485,"id":84761351,"diff_hunk":"@@ -407,6 +407,28 @@ def test_euclidean_distances():\n     assert_greater(np.max(np.abs(wrong_D - D1)), .01)\n \n \n+def test_cosine_distances():\n+    # Check the pairwise cosine_distances distances computation\n+    rng = np.random.RandomState(1337)\n+    x = np.abs(rng.rand(910))\n+    XA = np.vstack([x, x])\n+    D = cosine_distances(XA)\n+    assert_array_almost_equal(D, [[0., 0.], [0., 0.]])\n+    # check that all elements are in [0, 2]\n+    assert_true(np.all(D >= 0.))","path":"sklearn/metrics/tests/test_pairwise.py","position":12,"original_position":12,"commit_id":"0713cc2da9c656c6057c1f8d01b7531a8825bb78","original_commit_id":"0713cc2da9c656c6057c1f8d01b7531a8825bb78","user":{"login":"amueller","id":449558,"avatar_url":"https://avatars.githubusercontent.com/u/449558?v=3","gravatar_id":"","url":"https://api.github.com/users/amueller","html_url":"https://github.com/amueller","followers_url":"https://api.github.com/users/amueller/followers","following_url":"https://api.github.com/users/amueller/following{/other_user}","gists_url":"https://api.github.com/users/amueller/gists{/gist_id}","starred_url":"https://api.github.com/users/amueller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amueller/subscriptions","organizations_url":"https://api.github.com/users/amueller/orgs","repos_url":"https://api.github.com/users/amueller/repos","events_url":"https://api.github.com/users/amueller/events{/privacy}","received_events_url":"https://api.github.com/users/amueller/received_events","type":"User","site_admin":false},"body":"I would like that. It's not saying that your test doesn't make sense, but after the first ``assert_array_almost_equal`` it is certain that the tests pass, right? I guess the ``>=0`` checks if it's actually >= and not only \"almost\" but if it's \"almost zero\" it is certainly smaller than two.","created_at":"2016-10-24T19:11:16Z","updated_at":"2016-10-24T19:11:16Z","html_url":"https://github.com/scikit-learn/scikit-learn/pull/7732#discussion_r84761351","pull_request_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/7732","_links":{"self":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments/84761351"},"html":{"href":"https://github.com/scikit-learn/scikit-learn/pull/7732#discussion_r84761351"},"pull_request":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/7732"}}},"pull_request":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/7732","id":90541206,"html_url":"https://github.com/scikit-learn/scikit-learn/pull/7732","diff_url":"https://github.com/scikit-learn/scikit-learn/pull/7732.diff","patch_url":"https://github.com/scikit-learn/scikit-learn/pull/7732.patch","issue_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/7732","number":7732,"state":"open","locked":false,"title":"[MRG] fix bug with negative values in cosine_distances","user":{"login":"asanakoy","id":1690869,"avatar_url":"https://avatars.githubusercontent.com/u/1690869?v=3","gravatar_id":"","url":"https://api.github.com/users/asanakoy","html_url":"https://github.com/asanakoy","followers_url":"https://api.github.com/users/asanakoy/followers","following_url":"https://api.github.com/users/asanakoy/following{/other_user}","gists_url":"https://api.github.com/users/asanakoy/gists{/gist_id}","starred_url":"https://api.github.com/users/asanakoy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asanakoy/subscriptions","organizations_url":"https://api.github.com/users/asanakoy/orgs","repos_url":"https://api.github.com/users/asanakoy/repos","events_url":"https://api.github.com/users/asanakoy/events{/privacy}","received_events_url":"https://api.github.com/users/asanakoy/received_events","type":"User","site_admin":false},"body":"<!--\r\nThanks for contributing a pull request! Please ensure you have taken a look at\r\nthe contribution guidelines: https://github.com/scikit-learn/scikit-learn/blob/master/CONTRIBUTING.md#Contributing-Pull-Requests\r\n-->\r\n#### Reference Issue\r\nFixes #5772\r\n<!-- Example: Fixes #1234 -->\r\n\r\n\r\n#### What does this implement/fix? Explain your changes.\r\nFix bug `cosine_distances` returning small negative values.\r\n\r\nEssentially:\r\n\r\n- clip cosine distances to [0, 2].\r\n- set distances between vectors and themselves to 0.\r\n\r\n\r\n#### Any other comments?\r\n\r\nDid it analogously as it was implemented in `euclidean_distances`.","created_at":"2016-10-24T02:22:40Z","updated_at":"2016-10-24T19:11:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"27840be4f878d7ca0da8fbd87bcff3baa387d8c9","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/7732/commits","review_comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/7732/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/7732/comments","statuses_url":"https://api.github.com/repos/scikit-learn/scikit-learn/statuses/0713cc2da9c656c6057c1f8d01b7531a8825bb78","head":{"label":"asanakoy:fix-negative-cosine-dist","ref":"fix-negative-cosine-dist","sha":"0713cc2da9c656c6057c1f8d01b7531a8825bb78","user":{"login":"asanakoy","id":1690869,"avatar_url":"https://avatars.githubusercontent.com/u/1690869?v=3","gravatar_id":"","url":"https://api.github.com/users/asanakoy","html_url":"https://github.com/asanakoy","followers_url":"https://api.github.com/users/asanakoy/followers","following_url":"https://api.github.com/users/asanakoy/following{/other_user}","gists_url":"https://api.github.com/users/asanakoy/gists{/gist_id}","starred_url":"https://api.github.com/users/asanakoy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asanakoy/subscriptions","organizations_url":"https://api.github.com/users/asanakoy/orgs","repos_url":"https://api.github.com/users/asanakoy/repos","events_url":"https://api.github.com/users/asanakoy/events{/privacy}","received_events_url":"https://api.github.com/users/asanakoy/received_events","type":"User","site_admin":false},"repo":{"id":71742008,"name":"scikit-learn","full_name":"asanakoy/scikit-learn","owner":{"login":"asanakoy","id":1690869,"avatar_url":"https://avatars.githubusercontent.com/u/1690869?v=3","gravatar_id":"","url":"https://api.github.com/users/asanakoy","html_url":"https://github.com/asanakoy","followers_url":"https://api.github.com/users/asanakoy/followers","following_url":"https://api.github.com/users/asanakoy/following{/other_user}","gists_url":"https://api.github.com/users/asanakoy/gists{/gist_id}","starred_url":"https://api.github.com/users/asanakoy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asanakoy/subscriptions","organizations_url":"https://api.github.com/users/asanakoy/orgs","repos_url":"https://api.github.com/users/asanakoy/repos","events_url":"https://api.github.com/users/asanakoy/events{/privacy}","received_events_url":"https://api.github.com/users/asanakoy/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/asanakoy/scikit-learn","description":"scikit-learn: machine learning in Python","fork":true,"url":"https://api.github.com/repos/asanakoy/scikit-learn","forks_url":"https://api.github.com/repos/asanakoy/scikit-learn/forks","keys_url":"https://api.github.com/repos/asanakoy/scikit-learn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/asanakoy/scikit-learn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/asanakoy/scikit-learn/teams","hooks_url":"https://api.github.com/repos/asanakoy/scikit-learn/hooks","issue_events_url":"https://api.github.com/repos/asanakoy/scikit-learn/issues/events{/number}","events_url":"https://api.github.com/repos/asanakoy/scikit-learn/events","assignees_url":"https://api.github.com/repos/asanakoy/scikit-learn/assignees{/user}","branches_url":"https://api.github.com/repos/asanakoy/scikit-learn/branches{/branch}","tags_url":"https://api.github.com/repos/asanakoy/scikit-learn/tags","blobs_url":"https://api.github.com/repos/asanakoy/scikit-learn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/asanakoy/scikit-learn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/asanakoy/scikit-learn/git/refs{/sha}","trees_url":"https://api.github.com/repos/asanakoy/scikit-learn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/asanakoy/scikit-learn/statuses/{sha}","languages_url":"https://api.github.com/repos/asanakoy/scikit-learn/languages","stargazers_url":"https://api.github.com/repos/asanakoy/scikit-learn/stargazers","contributors_url":"https://api.github.com/repos/asanakoy/scikit-learn/contributors","subscribers_url":"https://api.github.com/repos/asanakoy/scikit-learn/subscribers","subscription_url":"https://api.github.com/repos/asanakoy/scikit-learn/subscription","commits_url":"https://api.github.com/repos/asanakoy/scikit-learn/commits{/sha}","git_commits_url":"https://api.github.com/repos/asanakoy/scikit-learn/git/commits{/sha}","comments_url":"https://api.github.com/repos/asanakoy/scikit-learn/comments{/number}","issue_comment_url":"https://api.github.com/repos/asanakoy/scikit-learn/issues/comments{/number}","contents_url":"https://api.github.com/repos/asanakoy/scikit-learn/contents/{+path}","compare_url":"https://api.github.com/repos/asanakoy/scikit-learn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/asanakoy/scikit-learn/merges","archive_url":"https://api.github.com/repos/asanakoy/scikit-learn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/asanakoy/scikit-learn/downloads","issues_url":"https://api.github.com/repos/asanakoy/scikit-learn/issues{/number}","pulls_url":"https://api.github.com/repos/asanakoy/scikit-learn/pulls{/number}","milestones_url":"https://api.github.com/repos/asanakoy/scikit-learn/milestones{/number}","notifications_url":"https://api.github.com/repos/asanakoy/scikit-learn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/asanakoy/scikit-learn/labels{/name}","releases_url":"https://api.github.com/repos/asanakoy/scikit-learn/releases{/id}","deployments_url":"https://api.github.com/repos/asanakoy/scikit-learn/deployments","created_at":"2016-10-24T01:43:47Z","updated_at":"2016-10-24T01:43:56Z","pushed_at":"2016-10-24T03:19:18Z","git_url":"git://github.com/asanakoy/scikit-learn.git","ssh_url":"git@github.com:asanakoy/scikit-learn.git","clone_url":"https://github.com/asanakoy/scikit-learn.git","svn_url":"https://github.com/asanakoy/scikit-learn","homepage":"http://scikit-learn.org","size":76110,"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":"f122efa1515c036095bc4c7dd2d68e6cf1231221","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}","deployments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/deployments","created_at":"2010-08-17T09:43:38Z","updated_at":"2016-10-24T19:00:19Z","pushed_at":"2016-10-24T19:07:49Z","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":126784,"stargazers_count":14262,"watchers_count":14262,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8119,"mirror_url":null,"open_issues_count":1187,"forks":8119,"open_issues":1187,"watchers":14262,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/7732"},"html":{"href":"https://github.com/scikit-learn/scikit-learn/pull/7732"},"issue":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/7732"},"comments":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/7732/comments"},"review_comments":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/7732/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/7732/commits"},"statuses":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/statuses/0713cc2da9c656c6057c1f8d01b7531a8825bb78"}}}}
{"actor":{"display_login":"amueller"}}