{"action":"created","comment":{"url":"https://api.github.com/repos/Koozco/pmp/pulls/comments/183363447","pull_request_review_id":114315329,"id":183363447,"diff_hunk":"@@ -0,0 +1,30 @@\n+from .rule import Rule\n+\n+\n+class Sntv(Rule):\n+    \"\"\"Single non-transferable vote scoring rule.\"\"\"\n+\n+    def __init__(self, committee_size, candidates, preferences):\n+        Rule.__init__(self, committee_size, candidates, preferences)\n+        self.weights = self.__sntv_weights(len(candidates))\n+        self.scores = self.__clean_scores()\n+\n+    @staticmethod\n+    def __sntv_weights(size):\n+        weights = [0] * size\n+        weights[0] = 1\n+        return weights\n+\n+    def __clean_scores(self):\n+        return {candidate: 0 for candidate in self.candidates}\n+\n+    def find_committee(self):\n+        self.scores = self.__clean_scores()\n+        for pref in self.preferences:\n+            pref_winner = pref.order[0]\n+            self.scores[pref_winner] += 1\n+\n+        scores_with_candidates = [(self.scores[c], c) for c in self.candidates]\n+        winners = sorted(scores_with_candidates, reverse=True)[:self.k]\n+        committee = [w[1] for w in winners]","path":"rules/sntv.py","position":29,"original_position":29,"commit_id":"1e3fc4c8cd79c0166869511efd8c0ec81ee3a607","original_commit_id":"1e3fc4c8cd79c0166869511efd8c0ec81ee3a607","user":{"login":"katabana","id":23458038,"avatar_url":"https://avatars1.githubusercontent.com/u/23458038?v=4","gravatar_id":"","url":"https://api.github.com/users/katabana","html_url":"https://github.com/katabana","followers_url":"https://api.github.com/users/katabana/followers","following_url":"https://api.github.com/users/katabana/following{/other_user}","gists_url":"https://api.github.com/users/katabana/gists{/gist_id}","starred_url":"https://api.github.com/users/katabana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/katabana/subscriptions","organizations_url":"https://api.github.com/users/katabana/orgs","repos_url":"https://api.github.com/users/katabana/repos","events_url":"https://api.github.com/users/katabana/events{/privacy}","received_events_url":"https://api.github.com/users/katabana/received_events","type":"User","site_admin":false},"body":"Można prościej:\r\n```python\r\nwinners = sorted(self.scores, key=labda x: self.scores[x], reverse=True)\r\n```\r\nRaczej wydzieliłabym wyznaczanie komitetu z \"wygranych\" do osobnej funkcji, żeby móc w przyszłości te remisy w różny sposób rozstrzygać.","created_at":"2018-04-23T11:39:49Z","updated_at":"2018-04-23T11:42:33Z","html_url":"https://github.com/Koozco/pmp/pull/1#discussion_r183363447","pull_request_url":"https://api.github.com/repos/Koozco/pmp/pulls/1","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/Koozco/pmp/pulls/comments/183363447"},"html":{"href":"https://github.com/Koozco/pmp/pull/1#discussion_r183363447"},"pull_request":{"href":"https://api.github.com/repos/Koozco/pmp/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/Koozco/pmp/pulls/1","id":183293655,"html_url":"https://github.com/Koozco/pmp/pull/1","diff_url":"https://github.com/Koozco/pmp/pull/1.diff","patch_url":"https://github.com/Koozco/pmp/pull/1.patch","issue_url":"https://api.github.com/repos/Koozco/pmp/issues/1","number":1,"state":"closed","locked":false,"title":"Sntv","user":{"login":"Koozco","id":16130342,"avatar_url":"https://avatars0.githubusercontent.com/u/16130342?v=4","gravatar_id":"","url":"https://api.github.com/users/Koozco","html_url":"https://github.com/Koozco","followers_url":"https://api.github.com/users/Koozco/followers","following_url":"https://api.github.com/users/Koozco/following{/other_user}","gists_url":"https://api.github.com/users/Koozco/gists{/gist_id}","starred_url":"https://api.github.com/users/Koozco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Koozco/subscriptions","organizations_url":"https://api.github.com/users/Koozco/orgs","repos_url":"https://api.github.com/users/Koozco/repos","events_url":"https://api.github.com/users/Koozco/events{/privacy}","received_events_url":"https://api.github.com/users/Koozco/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-04-22T20:54:17Z","updated_at":"2018-04-23T11:42:33Z","closed_at":"2018-04-22T22:17:36Z","merged_at":null,"merge_commit_sha":"74d116cf451058fb95eab352c54c38e01f972a16","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Koozco/pmp/pulls/1/commits","review_comments_url":"https://api.github.com/repos/Koozco/pmp/pulls/1/comments","review_comment_url":"https://api.github.com/repos/Koozco/pmp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Koozco/pmp/issues/1/comments","statuses_url":"https://api.github.com/repos/Koozco/pmp/statuses/1e3fc4c8cd79c0166869511efd8c0ec81ee3a607","head":{"label":"Koozco:SNTV","ref":"SNTV","sha":"1e3fc4c8cd79c0166869511efd8c0ec81ee3a607","user":{"login":"Koozco","id":16130342,"avatar_url":"https://avatars0.githubusercontent.com/u/16130342?v=4","gravatar_id":"","url":"https://api.github.com/users/Koozco","html_url":"https://github.com/Koozco","followers_url":"https://api.github.com/users/Koozco/followers","following_url":"https://api.github.com/users/Koozco/following{/other_user}","gists_url":"https://api.github.com/users/Koozco/gists{/gist_id}","starred_url":"https://api.github.com/users/Koozco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Koozco/subscriptions","organizations_url":"https://api.github.com/users/Koozco/orgs","repos_url":"https://api.github.com/users/Koozco/repos","events_url":"https://api.github.com/users/Koozco/events{/privacy}","received_events_url":"https://api.github.com/users/Koozco/received_events","type":"User","site_admin":false},"repo":{"id":129810143,"name":"pmp","full_name":"Koozco/pmp","owner":{"login":"Koozco","id":16130342,"avatar_url":"https://avatars0.githubusercontent.com/u/16130342?v=4","gravatar_id":"","url":"https://api.github.com/users/Koozco","html_url":"https://github.com/Koozco","followers_url":"https://api.github.com/users/Koozco/followers","following_url":"https://api.github.com/users/Koozco/following{/other_user}","gists_url":"https://api.github.com/users/Koozco/gists{/gist_id}","starred_url":"https://api.github.com/users/Koozco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Koozco/subscriptions","organizations_url":"https://api.github.com/users/Koozco/orgs","repos_url":"https://api.github.com/users/Koozco/repos","events_url":"https://api.github.com/users/Koozco/events{/privacy}","received_events_url":"https://api.github.com/users/Koozco/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Koozco/pmp","description":null,"fork":false,"url":"https://api.github.com/repos/Koozco/pmp","forks_url":"https://api.github.com/repos/Koozco/pmp/forks","keys_url":"https://api.github.com/repos/Koozco/pmp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Koozco/pmp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Koozco/pmp/teams","hooks_url":"https://api.github.com/repos/Koozco/pmp/hooks","issue_events_url":"https://api.github.com/repos/Koozco/pmp/issues/events{/number}","events_url":"https://api.github.com/repos/Koozco/pmp/events","assignees_url":"https://api.github.com/repos/Koozco/pmp/assignees{/user}","branches_url":"https://api.github.com/repos/Koozco/pmp/branches{/branch}","tags_url":"https://api.github.com/repos/Koozco/pmp/tags","blobs_url":"https://api.github.com/repos/Koozco/pmp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Koozco/pmp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Koozco/pmp/git/refs{/sha}","trees_url":"https://api.github.com/repos/Koozco/pmp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Koozco/pmp/statuses/{sha}","languages_url":"https://api.github.com/repos/Koozco/pmp/languages","stargazers_url":"https://api.github.com/repos/Koozco/pmp/stargazers","contributors_url":"https://api.github.com/repos/Koozco/pmp/contributors","subscribers_url":"https://api.github.com/repos/Koozco/pmp/subscribers","subscription_url":"https://api.github.com/repos/Koozco/pmp/subscription","commits_url":"https://api.github.com/repos/Koozco/pmp/commits{/sha}","git_commits_url":"https://api.github.com/repos/Koozco/pmp/git/commits{/sha}","comments_url":"https://api.github.com/repos/Koozco/pmp/comments{/number}","issue_comment_url":"https://api.github.com/repos/Koozco/pmp/issues/comments{/number}","contents_url":"https://api.github.com/repos/Koozco/pmp/contents/{+path}","compare_url":"https://api.github.com/repos/Koozco/pmp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Koozco/pmp/merges","archive_url":"https://api.github.com/repos/Koozco/pmp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Koozco/pmp/downloads","issues_url":"https://api.github.com/repos/Koozco/pmp/issues{/number}","pulls_url":"https://api.github.com/repos/Koozco/pmp/pulls{/number}","milestones_url":"https://api.github.com/repos/Koozco/pmp/milestones{/number}","notifications_url":"https://api.github.com/repos/Koozco/pmp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Koozco/pmp/labels{/name}","releases_url":"https://api.github.com/repos/Koozco/pmp/releases{/id}","deployments_url":"https://api.github.com/repos/Koozco/pmp/deployments","created_at":"2018-04-16T21:49:37Z","updated_at":"2018-04-22T19:53:14Z","pushed_at":"2018-04-22T22:19:17Z","git_url":"git://github.com/Koozco/pmp.git","ssh_url":"git@github.com:Koozco/pmp.git","clone_url":"https://github.com/Koozco/pmp.git","svn_url":"https://github.com/Koozco/pmp","homepage":null,"size":9,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":3,"license":null,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"Koozco:develop","ref":"develop","sha":"2fc393d47a81b56f116bebbb91819b7c511d3b30","user":{"login":"Koozco","id":16130342,"avatar_url":"https://avatars0.githubusercontent.com/u/16130342?v=4","gravatar_id":"","url":"https://api.github.com/users/Koozco","html_url":"https://github.com/Koozco","followers_url":"https://api.github.com/users/Koozco/followers","following_url":"https://api.github.com/users/Koozco/following{/other_user}","gists_url":"https://api.github.com/users/Koozco/gists{/gist_id}","starred_url":"https://api.github.com/users/Koozco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Koozco/subscriptions","organizations_url":"https://api.github.com/users/Koozco/orgs","repos_url":"https://api.github.com/users/Koozco/repos","events_url":"https://api.github.com/users/Koozco/events{/privacy}","received_events_url":"https://api.github.com/users/Koozco/received_events","type":"User","site_admin":false},"repo":{"id":129810143,"name":"pmp","full_name":"Koozco/pmp","owner":{"login":"Koozco","id":16130342,"avatar_url":"https://avatars0.githubusercontent.com/u/16130342?v=4","gravatar_id":"","url":"https://api.github.com/users/Koozco","html_url":"https://github.com/Koozco","followers_url":"https://api.github.com/users/Koozco/followers","following_url":"https://api.github.com/users/Koozco/following{/other_user}","gists_url":"https://api.github.com/users/Koozco/gists{/gist_id}","starred_url":"https://api.github.com/users/Koozco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Koozco/subscriptions","organizations_url":"https://api.github.com/users/Koozco/orgs","repos_url":"https://api.github.com/users/Koozco/repos","events_url":"https://api.github.com/users/Koozco/events{/privacy}","received_events_url":"https://api.github.com/users/Koozco/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Koozco/pmp","description":null,"fork":false,"url":"https://api.github.com/repos/Koozco/pmp","forks_url":"https://api.github.com/repos/Koozco/pmp/forks","keys_url":"https://api.github.com/repos/Koozco/pmp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Koozco/pmp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Koozco/pmp/teams","hooks_url":"https://api.github.com/repos/Koozco/pmp/hooks","issue_events_url":"https://api.github.com/repos/Koozco/pmp/issues/events{/number}","events_url":"https://api.github.com/repos/Koozco/pmp/events","assignees_url":"https://api.github.com/repos/Koozco/pmp/assignees{/user}","branches_url":"https://api.github.com/repos/Koozco/pmp/branches{/branch}","tags_url":"https://api.github.com/repos/Koozco/pmp/tags","blobs_url":"https://api.github.com/repos/Koozco/pmp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Koozco/pmp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Koozco/pmp/git/refs{/sha}","trees_url":"https://api.github.com/repos/Koozco/pmp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Koozco/pmp/statuses/{sha}","languages_url":"https://api.github.com/repos/Koozco/pmp/languages","stargazers_url":"https://api.github.com/repos/Koozco/pmp/stargazers","contributors_url":"https://api.github.com/repos/Koozco/pmp/contributors","subscribers_url":"https://api.github.com/repos/Koozco/pmp/subscribers","subscription_url":"https://api.github.com/repos/Koozco/pmp/subscription","commits_url":"https://api.github.com/repos/Koozco/pmp/commits{/sha}","git_commits_url":"https://api.github.com/repos/Koozco/pmp/git/commits{/sha}","comments_url":"https://api.github.com/repos/Koozco/pmp/comments{/number}","issue_comment_url":"https://api.github.com/repos/Koozco/pmp/issues/comments{/number}","contents_url":"https://api.github.com/repos/Koozco/pmp/contents/{+path}","compare_url":"https://api.github.com/repos/Koozco/pmp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Koozco/pmp/merges","archive_url":"https://api.github.com/repos/Koozco/pmp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Koozco/pmp/downloads","issues_url":"https://api.github.com/repos/Koozco/pmp/issues{/number}","pulls_url":"https://api.github.com/repos/Koozco/pmp/pulls{/number}","milestones_url":"https://api.github.com/repos/Koozco/pmp/milestones{/number}","notifications_url":"https://api.github.com/repos/Koozco/pmp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Koozco/pmp/labels{/name}","releases_url":"https://api.github.com/repos/Koozco/pmp/releases{/id}","deployments_url":"https://api.github.com/repos/Koozco/pmp/deployments","created_at":"2018-04-16T21:49:37Z","updated_at":"2018-04-22T19:53:14Z","pushed_at":"2018-04-22T22:19:17Z","git_url":"git://github.com/Koozco/pmp.git","ssh_url":"git@github.com:Koozco/pmp.git","clone_url":"https://github.com/Koozco/pmp.git","svn_url":"https://github.com/Koozco/pmp","homepage":null,"size":9,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":3,"license":null,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Koozco/pmp/pulls/1"},"html":{"href":"https://github.com/Koozco/pmp/pull/1"},"issue":{"href":"https://api.github.com/repos/Koozco/pmp/issues/1"},"comments":{"href":"https://api.github.com/repos/Koozco/pmp/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/Koozco/pmp/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/Koozco/pmp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Koozco/pmp/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/Koozco/pmp/statuses/1e3fc4c8cd79c0166869511efd8c0ec81ee3a607"}},"author_association":"OWNER"}}
{"actor":{"display_login":"katabana"}}