{"action":"created","comment":{"url":"https://api.github.com/repos/welliam/data-structures/pulls/comments/76283485","id":76283485,"diff_hunk":"@@ -0,0 +1,122 @@\n+# -*- coding: utf-8 -*-\n+\n+\"\"\"Test heap functionality.\"\"\"\n+\n+import pytest\n+from binary_heap import BinaryHeap\n+from random import sample\n+\n+ITERABLES = [\n+    \"hello\",\n+    [5, 1, 2, 7, 3, 4, -592034, 5],\n+    range(10),\n+    range(10, 0, -1),\n+    sample(list(range(20)), 20),\n+    sample(list(range(300)), 300),\n+    sample(list(range(1000)), 1000)\n+]\n+\n+NONITERABLES = [lambda x: x, 1, True]\n+\n+\n+def test_basic_pushpop(emptyheap):\n+    \"\"\"Test basic push and pop.\"\"\"\n+    emptyheap.push(0)\n+    assert emptyheap.pop() == 0\n+\n+\n+@pytest.mark.parametrize('iterable', ITERABLES)\n+def test_init(iterable):\n+    \"\"\"Test initialization method.\"\"\"\n+    h = BinaryHeap(iterable)\n+    assert h.pop() == min(iterable)\n+\n+\n+@pytest.mark.parametrize('noniterable', NONITERABLES)\n+def test_init_error(noniterable):\n+    \"\"\"Test initialization method throws TypeError\n+\n+    When passed a non-iterable.\n+    \"\"\"\n+    with pytest.raises(TypeError):\n+        BinaryHeap(noniterable)\n+\n+\n+@pytest.mark.parametrize('iterable', ITERABLES)\n+def test_max_init(iterable):\n+    \"\"\"Test initialization method.\"\"\"\n+    h = BinaryHeap(iterable, compare=lambda x, y: x > y)\n+    assert h.pop() == max(iterable)\n+\n+\n+@pytest.mark.parametrize('iterable', ITERABLES)\n+def test_minimum(iterable):\n+    \"\"\"Test that sequential pops return larger values.\"\"\"\n+    h = BinaryHeap(iterable)\n+    minimum = h.pop()\n+    assert minimum < h.pop()\n+\n+\n+def test_empty_pop(emptyheap):\n+    \"\"\"Test that pop on an empty heap raises an IndexError.\"\"\"\n+    with pytest.raises(IndexError):\n+        emptyheap.pop()\n+\n+\n+@pytest.mark.parametrize('iterable', ITERABLES)\n+def test_binheap(iterable):\n+    \"\"\"Test that pop values from max heap are sorted.\"\"\"\n+    h = BinaryHeap(iterable)\n+    results = []\n+    try:\n+        for _ in iterable:\n+            results.append(h.pop())\n+    except IndexError:\n+        assert sorted(results) == results\n+\n+\n+@pytest.mark.parametrize('iterable', ITERABLES)\n+def test_binheap_2(iterable):","path":"src/test_heap.py","position":79,"original_position":79,"commit_id":"434e5dbc09e42f5a3230160dbf552db2a6e80d08","original_commit_id":"434e5dbc09e42f5a3230160dbf552db2a6e80d08","user":{"login":"WillWeatherford","id":7210312,"avatar_url":"https://avatars.githubusercontent.com/u/7210312?v=3","gravatar_id":"","url":"https://api.github.com/users/WillWeatherford","html_url":"https://github.com/WillWeatherford","followers_url":"https://api.github.com/users/WillWeatherford/followers","following_url":"https://api.github.com/users/WillWeatherford/following{/other_user}","gists_url":"https://api.github.com/users/WillWeatherford/gists{/gist_id}","starred_url":"https://api.github.com/users/WillWeatherford/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WillWeatherford/subscriptions","organizations_url":"https://api.github.com/users/WillWeatherford/orgs","repos_url":"https://api.github.com/users/WillWeatherford/repos","events_url":"https://api.github.com/users/WillWeatherford/events{/privacy}","received_events_url":"https://api.github.com/users/WillWeatherford/received_events","type":"User","site_admin":false},"body":"This test is a really good idea, but it isn't quite catching a small error with your heap.","created_at":"2016-08-25T17:01:46Z","updated_at":"2016-08-25T17:01:46Z","html_url":"https://github.com/welliam/data-structures/pull/8#discussion_r76283485","pull_request_url":"https://api.github.com/repos/welliam/data-structures/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/welliam/data-structures/pulls/comments/76283485"},"html":{"href":"https://github.com/welliam/data-structures/pull/8#discussion_r76283485"},"pull_request":{"href":"https://api.github.com/repos/welliam/data-structures/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/welliam/data-structures/pulls/8","id":82445562,"html_url":"https://github.com/welliam/data-structures/pull/8","diff_url":"https://github.com/welliam/data-structures/pull/8.diff","patch_url":"https://github.com/welliam/data-structures/pull/8.patch","issue_url":"https://api.github.com/repos/welliam/data-structures/issues/8","number":8,"state":"closed","locked":false,"title":"Binheap","user":{"login":"welliam","id":4933194,"avatar_url":"https://avatars.githubusercontent.com/u/4933194?v=3","gravatar_id":"","url":"https://api.github.com/users/welliam","html_url":"https://github.com/welliam","followers_url":"https://api.github.com/users/welliam/followers","following_url":"https://api.github.com/users/welliam/following{/other_user}","gists_url":"https://api.github.com/users/welliam/gists{/gist_id}","starred_url":"https://api.github.com/users/welliam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/welliam/subscriptions","organizations_url":"https://api.github.com/users/welliam/orgs","repos_url":"https://api.github.com/users/welliam/repos","events_url":"https://api.github.com/users/welliam/events{/privacy}","received_events_url":"https://api.github.com/users/welliam/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-08-23T21:35:53Z","updated_at":"2016-08-25T17:01:46Z","closed_at":"2016-08-24T20:29:24Z","merged_at":"2016-08-24T20:29:24Z","merge_commit_sha":"68d9c4ed039ccd34610cd8b7fde67b650c1f158e","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/welliam/data-structures/pulls/8/commits","review_comments_url":"https://api.github.com/repos/welliam/data-structures/pulls/8/comments","review_comment_url":"https://api.github.com/repos/welliam/data-structures/pulls/comments{/number}","comments_url":"https://api.github.com/repos/welliam/data-structures/issues/8/comments","statuses_url":"https://api.github.com/repos/welliam/data-structures/statuses/434e5dbc09e42f5a3230160dbf552db2a6e80d08","head":{"label":"welliam:binheap","ref":"binheap","sha":"434e5dbc09e42f5a3230160dbf552db2a6e80d08","user":{"login":"welliam","id":4933194,"avatar_url":"https://avatars.githubusercontent.com/u/4933194?v=3","gravatar_id":"","url":"https://api.github.com/users/welliam","html_url":"https://github.com/welliam","followers_url":"https://api.github.com/users/welliam/followers","following_url":"https://api.github.com/users/welliam/following{/other_user}","gists_url":"https://api.github.com/users/welliam/gists{/gist_id}","starred_url":"https://api.github.com/users/welliam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/welliam/subscriptions","organizations_url":"https://api.github.com/users/welliam/orgs","repos_url":"https://api.github.com/users/welliam/repos","events_url":"https://api.github.com/users/welliam/events{/privacy}","received_events_url":"https://api.github.com/users/welliam/received_events","type":"User","site_admin":false},"repo":{"id":65761270,"name":"data-structures","full_name":"welliam/data-structures","owner":{"login":"welliam","id":4933194,"avatar_url":"https://avatars.githubusercontent.com/u/4933194?v=3","gravatar_id":"","url":"https://api.github.com/users/welliam","html_url":"https://github.com/welliam","followers_url":"https://api.github.com/users/welliam/followers","following_url":"https://api.github.com/users/welliam/following{/other_user}","gists_url":"https://api.github.com/users/welliam/gists{/gist_id}","starred_url":"https://api.github.com/users/welliam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/welliam/subscriptions","organizations_url":"https://api.github.com/users/welliam/orgs","repos_url":"https://api.github.com/users/welliam/repos","events_url":"https://api.github.com/users/welliam/events{/privacy}","received_events_url":"https://api.github.com/users/welliam/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/welliam/data-structures","description":"Data structure implementations for Code Fellows Python 401","fork":false,"url":"https://api.github.com/repos/welliam/data-structures","forks_url":"https://api.github.com/repos/welliam/data-structures/forks","keys_url":"https://api.github.com/repos/welliam/data-structures/keys{/key_id}","collaborators_url":"https://api.github.com/repos/welliam/data-structures/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/welliam/data-structures/teams","hooks_url":"https://api.github.com/repos/welliam/data-structures/hooks","issue_events_url":"https://api.github.com/repos/welliam/data-structures/issues/events{/number}","events_url":"https://api.github.com/repos/welliam/data-structures/events","assignees_url":"https://api.github.com/repos/welliam/data-structures/assignees{/user}","branches_url":"https://api.github.com/repos/welliam/data-structures/branches{/branch}","tags_url":"https://api.github.com/repos/welliam/data-structures/tags","blobs_url":"https://api.github.com/repos/welliam/data-structures/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/welliam/data-structures/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/welliam/data-structures/git/refs{/sha}","trees_url":"https://api.github.com/repos/welliam/data-structures/git/trees{/sha}","statuses_url":"https://api.github.com/repos/welliam/data-structures/statuses/{sha}","languages_url":"https://api.github.com/repos/welliam/data-structures/languages","stargazers_url":"https://api.github.com/repos/welliam/data-structures/stargazers","contributors_url":"https://api.github.com/repos/welliam/data-structures/contributors","subscribers_url":"https://api.github.com/repos/welliam/data-structures/subscribers","subscription_url":"https://api.github.com/repos/welliam/data-structures/subscription","commits_url":"https://api.github.com/repos/welliam/data-structures/commits{/sha}","git_commits_url":"https://api.github.com/repos/welliam/data-structures/git/commits{/sha}","comments_url":"https://api.github.com/repos/welliam/data-structures/comments{/number}","issue_comment_url":"https://api.github.com/repos/welliam/data-structures/issues/comments{/number}","contents_url":"https://api.github.com/repos/welliam/data-structures/contents/{+path}","compare_url":"https://api.github.com/repos/welliam/data-structures/compare/{base}...{head}","merges_url":"https://api.github.com/repos/welliam/data-structures/merges","archive_url":"https://api.github.com/repos/welliam/data-structures/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/welliam/data-structures/downloads","issues_url":"https://api.github.com/repos/welliam/data-structures/issues{/number}","pulls_url":"https://api.github.com/repos/welliam/data-structures/pulls{/number}","milestones_url":"https://api.github.com/repos/welliam/data-structures/milestones{/number}","notifications_url":"https://api.github.com/repos/welliam/data-structures/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/welliam/data-structures/labels{/name}","releases_url":"https://api.github.com/repos/welliam/data-structures/releases{/id}","deployments_url":"https://api.github.com/repos/welliam/data-structures/deployments","created_at":"2016-08-15T20:04:47Z","updated_at":"2016-08-16T20:19:29Z","pushed_at":"2016-08-25T13:59:25Z","git_url":"git://github.com/welliam/data-structures.git","ssh_url":"git@github.com:welliam/data-structures.git","clone_url":"https://github.com/welliam/data-structures.git","svn_url":"https://github.com/welliam/data-structures","homepage":null,"size":57,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"welliam:master","ref":"master","sha":"69839ba05ab16af3d946618f62ca8897d24e8b6a","user":{"login":"welliam","id":4933194,"avatar_url":"https://avatars.githubusercontent.com/u/4933194?v=3","gravatar_id":"","url":"https://api.github.com/users/welliam","html_url":"https://github.com/welliam","followers_url":"https://api.github.com/users/welliam/followers","following_url":"https://api.github.com/users/welliam/following{/other_user}","gists_url":"https://api.github.com/users/welliam/gists{/gist_id}","starred_url":"https://api.github.com/users/welliam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/welliam/subscriptions","organizations_url":"https://api.github.com/users/welliam/orgs","repos_url":"https://api.github.com/users/welliam/repos","events_url":"https://api.github.com/users/welliam/events{/privacy}","received_events_url":"https://api.github.com/users/welliam/received_events","type":"User","site_admin":false},"repo":{"id":65761270,"name":"data-structures","full_name":"welliam/data-structures","owner":{"login":"welliam","id":4933194,"avatar_url":"https://avatars.githubusercontent.com/u/4933194?v=3","gravatar_id":"","url":"https://api.github.com/users/welliam","html_url":"https://github.com/welliam","followers_url":"https://api.github.com/users/welliam/followers","following_url":"https://api.github.com/users/welliam/following{/other_user}","gists_url":"https://api.github.com/users/welliam/gists{/gist_id}","starred_url":"https://api.github.com/users/welliam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/welliam/subscriptions","organizations_url":"https://api.github.com/users/welliam/orgs","repos_url":"https://api.github.com/users/welliam/repos","events_url":"https://api.github.com/users/welliam/events{/privacy}","received_events_url":"https://api.github.com/users/welliam/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/welliam/data-structures","description":"Data structure implementations for Code Fellows Python 401","fork":false,"url":"https://api.github.com/repos/welliam/data-structures","forks_url":"https://api.github.com/repos/welliam/data-structures/forks","keys_url":"https://api.github.com/repos/welliam/data-structures/keys{/key_id}","collaborators_url":"https://api.github.com/repos/welliam/data-structures/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/welliam/data-structures/teams","hooks_url":"https://api.github.com/repos/welliam/data-structures/hooks","issue_events_url":"https://api.github.com/repos/welliam/data-structures/issues/events{/number}","events_url":"https://api.github.com/repos/welliam/data-structures/events","assignees_url":"https://api.github.com/repos/welliam/data-structures/assignees{/user}","branches_url":"https://api.github.com/repos/welliam/data-structures/branches{/branch}","tags_url":"https://api.github.com/repos/welliam/data-structures/tags","blobs_url":"https://api.github.com/repos/welliam/data-structures/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/welliam/data-structures/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/welliam/data-structures/git/refs{/sha}","trees_url":"https://api.github.com/repos/welliam/data-structures/git/trees{/sha}","statuses_url":"https://api.github.com/repos/welliam/data-structures/statuses/{sha}","languages_url":"https://api.github.com/repos/welliam/data-structures/languages","stargazers_url":"https://api.github.com/repos/welliam/data-structures/stargazers","contributors_url":"https://api.github.com/repos/welliam/data-structures/contributors","subscribers_url":"https://api.github.com/repos/welliam/data-structures/subscribers","subscription_url":"https://api.github.com/repos/welliam/data-structures/subscription","commits_url":"https://api.github.com/repos/welliam/data-structures/commits{/sha}","git_commits_url":"https://api.github.com/repos/welliam/data-structures/git/commits{/sha}","comments_url":"https://api.github.com/repos/welliam/data-structures/comments{/number}","issue_comment_url":"https://api.github.com/repos/welliam/data-structures/issues/comments{/number}","contents_url":"https://api.github.com/repos/welliam/data-structures/contents/{+path}","compare_url":"https://api.github.com/repos/welliam/data-structures/compare/{base}...{head}","merges_url":"https://api.github.com/repos/welliam/data-structures/merges","archive_url":"https://api.github.com/repos/welliam/data-structures/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/welliam/data-structures/downloads","issues_url":"https://api.github.com/repos/welliam/data-structures/issues{/number}","pulls_url":"https://api.github.com/repos/welliam/data-structures/pulls{/number}","milestones_url":"https://api.github.com/repos/welliam/data-structures/milestones{/number}","notifications_url":"https://api.github.com/repos/welliam/data-structures/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/welliam/data-structures/labels{/name}","releases_url":"https://api.github.com/repos/welliam/data-structures/releases{/id}","deployments_url":"https://api.github.com/repos/welliam/data-structures/deployments","created_at":"2016-08-15T20:04:47Z","updated_at":"2016-08-16T20:19:29Z","pushed_at":"2016-08-25T13:59:25Z","git_url":"git://github.com/welliam/data-structures.git","ssh_url":"git@github.com:welliam/data-structures.git","clone_url":"https://github.com/welliam/data-structures.git","svn_url":"https://github.com/welliam/data-structures","homepage":null,"size":57,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/welliam/data-structures/pulls/8"},"html":{"href":"https://github.com/welliam/data-structures/pull/8"},"issue":{"href":"https://api.github.com/repos/welliam/data-structures/issues/8"},"comments":{"href":"https://api.github.com/repos/welliam/data-structures/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/welliam/data-structures/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/welliam/data-structures/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/welliam/data-structures/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/welliam/data-structures/statuses/434e5dbc09e42f5a3230160dbf552db2a6e80d08"}}}}
{"actor":{"display_login":"WillWeatherford"}}