From b9e66fde734fe6852b9f86eefee6093799f2e0f1 Mon Sep 17 00:00:00 2001 From: RunasSudo Date: Tue, 17 Aug 2021 01:56:43 +1000 Subject: [PATCH] Correct number of ballot papers reported to be transferred in exclusive Gregory method --- src/stv/gregory.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/stv/gregory.rs b/src/stv/gregory.rs index cd5e3f9..f55405a 100644 --- a/src/stv/gregory.rs +++ b/src/stv/gregory.rs @@ -253,9 +253,7 @@ where state.title = String::from(&elected_candidate.name); state.logger.log_literal(format!("Surplus of {} distributed.", elected_candidate.name)); - let count_card = state.candidates.get_mut(elected_candidate).unwrap(); - count_card.ballot_transfers = -count_card.num_ballots(); - + let count_card = &state.candidates[elected_candidate]; let surplus = &count_card.votes - state.quota.as_ref().unwrap(); // Determine which votes to examine @@ -311,6 +309,9 @@ where let total_ballots = &transferable_ballots + &exhausted_ballots; let total_votes = &transferable_votes + &exhausted_votes; + let count_card = state.candidates.get_mut(elected_candidate).unwrap(); + count_card.ballot_transfers = -&total_ballots; + let surplus_denom = calculate_surplus_denom(&surplus, &transferable_ballots, &transferable_votes, &total_ballots, &total_votes, is_weighted, opts.transferable_only); let mut surplus_fraction; match surplus_denom {