This is an automated email from the ASF dual-hosted git repository. gstein pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/steve.git
commit 19e8ae1c0d9fc5b6de789a670752d6fab3f7a7ea Author: Greg Stein <[email protected]> AuthorDate: Thu Jun 2 01:51:48 2022 -0500 move calc_totals() to CandidateList --- monitoring/stv_tool.py | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/monitoring/stv_tool.py b/monitoring/stv_tool.py index 1a7dc63..6e644cb 100755 --- a/monitoring/stv_tool.py +++ b/monitoring/stv_tool.py @@ -224,6 +224,26 @@ class CandidateList(object): c.ahead = (i - 1) + last last = i + def apply_votes(self, votes): + for c in self.l: + c.vote = 0.0 + excess = 0.0 + for choices in votes: + vote = 1.0 + for c in choices: + if c.status == HOPEFUL: + c.vote += vote + vote = 0.0 + break + if c.status != ELIMINATED: + wv = c.weight * vote # weighted vote + c.vote += wv + vote -= wv + if vote == 0.0: # nothing left to distribute + break + excess += vote + return excess + class Candidate(object): def __init__(self, name, rand, ahead): @@ -279,25 +299,9 @@ def recalc(votes, candidates, num_seats): return any_changed, quota, surplus +#@deprecated def calc_totals(votes, candidates): - for c in candidates.l: - c.vote = 0.0 - excess = 0.0 - for choices in votes: - vote = 1.0 - for c in choices: - if c.status == HOPEFUL: - c.vote += vote - vote = 0.0 - break - if c.status != ELIMINATED: - wv = c.weight * vote # weighted vote - c.vote += wv - vote -= wv - if vote == 0.0: # nothing left to distribute - break - excess += vote - return excess + return candidates.apply_votes(votes) #@deprecated
