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

View File

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