From 77c5cfca7565c9e5b685e57216220eadc4dff06e Mon Sep 17 00:00:00 2001 From: RunasSudo Date: Wed, 13 Jan 2021 22:40:59 +1100 Subject: [PATCH] Fix bug/handling of withdrawn candidates in Meek STV --- pyRCV2/method/meek.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pyRCV2/method/meek.py b/pyRCV2/method/meek.py index 8530dda..f22519d 100644 --- a/pyRCV2/method/meek.py +++ b/pyRCV2/method/meek.py @@ -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: