Display --no-bulk-elect as one stage on web version

This commit is contained in:
RunasSudo 2021-02-28 23:15:43 +11:00
parent 68abe072d8
commit 71de14ecfc
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
2 changed files with 17 additions and 5 deletions

View File

@ -57,7 +57,7 @@ This option allows you to specify whether the votes required for election can ch
When bulk election is enabled (default), all remaining candidates are declared elected in a single stage once the number of not-excluded candidates exactly equals the number of vacancies to fill. Further surplus distributions are not performed. This is typical of most STV rules. When bulk election is enabled (default), all remaining candidates are declared elected in a single stage once the number of not-excluded candidates exactly equals the number of vacancies to fill. Further surplus distributions are not performed. This is typical of most STV rules.
When bulk election is disabled, surpluses continue to be distributed even once the number of not-excluded candidates exactly equals the number of vacancies to fill. Once there are no more surpluses to distribute, the candidates are declared elected, one by one, in descending order of votes. This ensures that only one candidate is ever elected in each round and the order of election is well-defined, which is required e.g. for some affirmative action rules. When bulk election is disabled, surpluses continue to be distributed even once the number of not-excluded candidates exactly equals the number of vacancies to fill. Once there are no more surpluses to distribute, the candidates are declared elected, one by one, in descending order of votes. This ensures that only one candidate is ever elected at a time and the order of election is well-defined, which is required e.g. for some affirmative action rules.
## Bulk exclusion (--bulk-exclude) ## Bulk exclusion (--bulk-exclude)

View File

@ -304,11 +304,23 @@ class BaseSTVCounter:
# Declare elected one remaining candidate at a time # Declare elected one remaining candidate at a time
hopefuls = [(c, cc) for c, cc in self.candidates.items() if cc.state == CandidateState.HOPEFUL] hopefuls = [(c, cc) for c, cc in self.candidates.items() if cc.state == CandidateState.HOPEFUL]
hopefuls.sort(key=lambda x: x[1].votes, reverse=True) hopefuls.sort(key=lambda x: x[1].votes, reverse=True)
candidate_elected, count_card = self.choose_highest(hopefuls)
count_card.state = CandidateState.PROVISIONALLY_ELECTED order_elected = []
self.num_elected += 1
count_card.order_elected = self.num_elected while len(hopefuls) > 0:
x = self.choose_highest(hopefuls)
x[1].state = CandidateState.PROVISIONALLY_ELECTED
self.num_elected += 1
x[1].order_elected = self.num_elected
order_elected.append(x[0].name)
hopefuls.remove(x)
if len(order_elected) == 1:
self.logs.append(order_elected[0].name + ' is elected to fill the remaining vacancy.')
else:
self.logs.append(self.pretty_join(order_elected) + ' are elected to fill the remaining vacancies.')
return self.make_result('Bulk election') return self.make_result('Bulk election')