Hide votes required for election in Meek STV
This commit is contained in:
parent
c9b189fefe
commit
99dbbcd5d5
@ -19,7 +19,7 @@ use crate::constraints::{Constraints, ConstraintMatrix};
|
|||||||
use crate::logger::Logger;
|
use crate::logger::Logger;
|
||||||
use crate::numbers::Number;
|
use crate::numbers::Number;
|
||||||
use crate::sharandom::SHARandom;
|
use crate::sharandom::SHARandom;
|
||||||
use crate::stv::{QuotaMode, STVOptions};
|
use crate::stv::{self, STVOptions};
|
||||||
|
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
|
||||||
@ -281,7 +281,7 @@ impl<'a, N: Number> CountState<'a, N> {
|
|||||||
result.push_str(&format!("Total votes: {:.dps$}\n", total_vote, dps=opts.pp_decimals));
|
result.push_str(&format!("Total votes: {:.dps$}\n", total_vote, dps=opts.pp_decimals));
|
||||||
|
|
||||||
result.push_str(&format!("Quota: {:.dps$}\n", self.quota.as_ref().unwrap(), dps=opts.pp_decimals));
|
result.push_str(&format!("Quota: {:.dps$}\n", self.quota.as_ref().unwrap(), dps=opts.pp_decimals));
|
||||||
if opts.quota_mode == QuotaMode::ERS97 || opts.quota_mode == QuotaMode::ERS76 {
|
if stv::should_show_vre(opts) {
|
||||||
result.push_str(&format!("Vote required for election: {:.dps$}\n", self.vote_required_election.as_ref().unwrap(), dps=opts.pp_decimals));
|
result.push_str(&format!("Vote required for election: {:.dps$}\n", self.vote_required_election.as_ref().unwrap(), dps=opts.pp_decimals));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1721,3 +1721,17 @@ fn update_tiebreaks<N: Number>(state: &mut CountState<N>, _opts: &STVOptions) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns `true` if the votes required for election should be displayed, based on the given [STVOptions]
|
||||||
|
pub fn should_show_vre(opts: &STVOptions) -> bool {
|
||||||
|
if opts.quota_mode == QuotaMode::ERS97 || opts.quota_mode == QuotaMode::ERS76 {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if opts.surplus == SurplusMethod::Meek {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if opts.early_bulk_elect {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@ -316,11 +316,6 @@ fn describe_count<N: Number>(filename: String, election: &Election<N>, opts: &st
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn should_show_vre(opts: &stv::STVOptions) -> bool {
|
|
||||||
return opts.quota_mode == stv::QuotaMode::ERS97 || opts.quota_mode == stv::QuotaMode::ERS76 || opts.early_bulk_elect;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Generate the first column of the HTML results table
|
/// Generate the first column of the HTML results table
|
||||||
fn init_results_table<N: Number>(election: &Election<N>, opts: &stv::STVOptions, report_style: &str) -> String {
|
fn init_results_table<N: Number>(election: &Election<N>, opts: &stv::STVOptions, report_style: &str) -> String {
|
||||||
let mut result = String::from(r#"<tr class="stage-no"><td rowspan="3"></td></tr><tr class="stage-kind"></tr><tr class="stage-comment"></tr>"#);
|
let mut result = String::from(r#"<tr class="stage-no"><td rowspan="3"></td></tr><tr class="stage-kind"></tr><tr class="stage-comment"></tr>"#);
|
||||||
@ -349,7 +344,7 @@ fn init_results_table<N: Number>(election: &Election<N>, opts: &stv::STVOptions,
|
|||||||
result.push_str(r#"<tr class="info transfers"><td rowspan="2">Loss by fraction</td></tr><tr class="info votes"></tr><tr class="info transfers"><td>Total</td></tr><tr class="info transfers"><td>Quota</td></tr>"#);
|
result.push_str(r#"<tr class="info transfers"><td rowspan="2">Loss by fraction</td></tr><tr class="info votes"></tr><tr class="info transfers"><td>Total</td></tr><tr class="info transfers"><td>Quota</td></tr>"#);
|
||||||
}
|
}
|
||||||
|
|
||||||
if should_show_vre(opts) {
|
if stv::should_show_vre(opts) {
|
||||||
result.push_str(r#"<tr class="info transfers"><td>Vote required for election</td></tr>"#);
|
result.push_str(r#"<tr class="info transfers"><td>Vote required for election</td></tr>"#);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -597,7 +592,7 @@ fn update_results_table<N: Number>(stage_num: usize, state: &CountState<N>, opts
|
|||||||
result.push(&format!(r#"<td class="{}count"></td><td class="count">{}</td>"#, classes_i, pp(state.quota.as_ref().unwrap(), opts.pp_decimals)).into());
|
result.push(&format!(r#"<td class="{}count"></td><td class="count">{}</td>"#, classes_i, pp(state.quota.as_ref().unwrap(), opts.pp_decimals)).into());
|
||||||
}
|
}
|
||||||
|
|
||||||
if should_show_vre(opts) {
|
if stv::should_show_vre(opts) {
|
||||||
if let Some(vre) = &state.vote_required_election {
|
if let Some(vre) = &state.vote_required_election {
|
||||||
if report_style == "votes" || (report_style == "votes_transposed" && hide_xfers_trsp) {
|
if report_style == "votes" || (report_style == "votes_transposed" && hide_xfers_trsp) {
|
||||||
result.push(&format!(r#"<td class="{}count">{}</td>"#, classes_i, pp(vre, opts.pp_decimals)).into());
|
result.push(&format!(r#"<td class="{}count">{}</td>"#, classes_i, pp(vre, opts.pp_decimals)).into());
|
||||||
|
Loading…
Reference in New Issue
Block a user