Fix bug when excluding candidate with 0 votes
This commit is contained in:
parent
a595f2ff6b
commit
5189a74010
|
@ -445,6 +445,9 @@ where
|
||||||
panic!("Invalid --exclusion");
|
panic!("Invalid --exclusion");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut checksum = N::new();
|
||||||
|
|
||||||
|
if votes.len() > 0 {
|
||||||
let value = &votes[0].value / &votes[0].ballot.orig_value;
|
let value = &votes[0].value / &votes[0].ballot.orig_value;
|
||||||
|
|
||||||
// Count next preferences
|
// Count next preferences
|
||||||
|
@ -457,8 +460,6 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transfer candidate votes
|
// Transfer candidate votes
|
||||||
let mut checksum = N::new();
|
|
||||||
|
|
||||||
for (candidate, entry) in result.candidates.into_iter() {
|
for (candidate, entry) in result.candidates.into_iter() {
|
||||||
let parcel = entry.votes as Parcel<N>;
|
let parcel = entry.votes as Parcel<N>;
|
||||||
let count_card = state.candidates.get_mut(candidate).unwrap();
|
let count_card = state.candidates.get_mut(candidate).unwrap();
|
||||||
|
@ -491,7 +492,10 @@ where
|
||||||
count_card.transfer(&-result.total_votes);
|
count_card.transfer(&-result.total_votes);
|
||||||
|
|
||||||
// By definition, there is no loss by fraction
|
// By definition, there is no loss by fraction
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if votes_remaining == 0 {
|
||||||
// Finalise candidate votes
|
// Finalise candidate votes
|
||||||
let count_card = state.candidates.get_mut(excluded_candidate).unwrap();
|
let count_card = state.candidates.get_mut(excluded_candidate).unwrap();
|
||||||
checksum -= &count_card.votes;
|
checksum -= &count_card.votes;
|
||||||
|
|
Loading…
Reference in New Issue