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 330685e9675d0f13b5bff5c11631c3a5053b5d0b Author: Greg Stein <[email protected]> AuthorDate: Thu Jun 2 00:19:42 2022 -0500 Fix calc_aheads() The algorithm should use .vote, according to the STV.java that is the pattern for this code. Note: this slightly alters the values/progression of .ahead values during the processing of an election. Note: no ASF Board meeting election over the past 16 years is affected. --- monitoring/stv_tool.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/monitoring/stv_tool.py b/monitoring/stv_tool.py index 12609e7..1a7dc63 100755 --- a/monitoring/stv_tool.py +++ b/monitoring/stv_tool.py @@ -211,11 +211,15 @@ class CandidateList(object): return (c1.vote > c2.vote) - (c1.vote < c2.vote) return 1 + ### the algorithm below seems very obtuse, to produce very little + ### change. It alters .ahead on the first iteration, then does + ### minor tweaks afterwards. And it seems to only work pair-wise. + ### It feels this could be simplified. + ### refer to STV.java::calcAheads() c_sorted = sorted(self.l, key=functools.cmp_to_key(compare)) last = 0 for i in range(1, len(c_sorted)+1): - ### STV.java:L233 ... This may need .vote on the latter compare - if i == len(c_sorted) or c_sorted[last] != c_sorted[i]: + if i == len(c_sorted) or c_sorted[last].vote != c_sorted[i].vote: for c in c_sorted[last:i]: c.ahead = (i - 1) + last last = i
