KemenyYoungVoting crashes
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
ballotbox |
New
|
Undecided
|
Unassigned |
Bug Description
KemenyYoungVoting only works if for every pair of candidates A and B there is at least one voter who prefers A to B.
This is the case for the example under
https:/
You can trigger the problem by having a single vote only:
>>> from ballotbox.
>>> bb = BallotBox(
>>> preference = {"Memphis": 1, "Nashville": 2, "Chattanooga": 3, "Knoxville": 4}
>>> bb.add_
>>> bb.get_winner()
The fix is to change this:
def get_ranks(self):
ranks = []
for possibility in itertools.
rank = 0
for index, option1 in enumerate(
for option2 in possibility[index + 1:]:
return sorted(ranks, reverse=True)
to this:
def get_ranks(self):
ranks = []
for possibility in itertools.
rank = 0
for index, option1 in enumerate(
for option2 in possibility[index + 1:]:
return sorted(ranks, reverse=True)