Fix bug/handling of withdrawn candidates in Meek STV

This commit is contained in:
RunasSudo 2021-01-13 22:40:59 +11:00
parent 5f9d18cb04
commit 77c5cfca75
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
1 changed files with 7 additions and 1 deletions

View File

@ -46,6 +46,12 @@ class MeekSTVCounter(BaseSTVCounter):
BaseSTVCounter.__init__(self, *args)
self.candidates = SafeDict([(c, MeekCountCard()) for c in self.election.candidates])
# Withdraw candidates
for candidate in self.election.withdrawn:
__pragma__('opov')
self.candidates[candidate].state = CandidateState.WITHDRAWN
__pragma__('noopov')
self._quota_tolerance = Num('1.0001')
def reset(self):
@ -117,7 +123,7 @@ class MeekSTVCounter(BaseSTVCounter):
__pragma__('noopov')
remaining_value = Num(0)
break
elif count_card.state == CandidateState.EXCLUDED:
elif count_card.state == CandidateState.EXCLUDED or count_card.state == CandidateState.WITHDRAWN:
# Excluded candidate has keep value 0, so skip over this candidate
pass
elif count_card.state == CandidateState.ELECTED: