forked from berjc/election-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathelection.py
30 lines (27 loc) · 798 Bytes
/
election.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""
'election.py' implements the Election class.
"""
class Election:
# Election constructor
# @params
# contests <[Contest,]> : list of contests
# @return
# <Election>
def __init__(self, contests):
self.contests = contests
# Computes contest outcomes
# @params
# None
# @return
# None
def run(self):
for contest in self.contests:
contest.run()
# Returns the result of a post-election, ballot-polling audit
# @params
# auditor <func> : function to run audit of election outcomes
# @return
# <[(str, int),]> where each entry is a tuple representing the reported winner
# and the number of ballots checked, respectively.
def audit(self, auditor):
return [auditor(contest) for contest in self.contests]