CSV output for bulk election
This commit is contained in:
parent
ab3067566d
commit
523b039d2a
|
@ -395,8 +395,8 @@ fn print_stage<N: Number>(stage_num: u32, state: &CountState<N>, opts: &STVOptio
|
||||||
println!("");
|
println!("");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------
|
// ----------------------------------
|
||||||
// eSTV-style CSV report
|
// Wichmann/eSTV/ERS-style CSV report
|
||||||
|
|
||||||
fn count_election_csv<N: Number>(mut election: Election<N>, opts: STVOptions) -> Result<(), i32>
|
fn count_election_csv<N: Number>(mut election: Election<N>, opts: STVOptions) -> Result<(), i32>
|
||||||
where
|
where
|
||||||
|
@ -462,6 +462,11 @@ where
|
||||||
stage_results[4 + election.candidates.len()].push(String::from(r#""Totals""#));
|
stage_results[4 + election.candidates.len()].push(String::from(r#""Totals""#));
|
||||||
stage_results[4 + election.candidates.len()].push(format!(r#"{:.0}"#, valid_votes));
|
stage_results[4 + election.candidates.len()].push(format!(r#"{:.0}"#, valid_votes));
|
||||||
|
|
||||||
|
//let mut orig_states = HashMap::new();
|
||||||
|
//for (candidate, count_card) in state.candidates.iter() {
|
||||||
|
// orig_states.insert(*candidate, count_card.state);
|
||||||
|
//}
|
||||||
|
|
||||||
// -----------------
|
// -----------------
|
||||||
// Subsequent stages
|
// Subsequent stages
|
||||||
|
|
||||||
|
@ -496,10 +501,18 @@ where
|
||||||
stage_results[2].push(format!(r#""{}""#, candidate.name));
|
stage_results[2].push(format!(r#""{}""#, candidate.name));
|
||||||
}
|
}
|
||||||
StageKind::ExclusionOf(candidates) => {
|
StageKind::ExclusionOf(candidates) => {
|
||||||
stage_results[2].push(format!(r#""{}""#, candidates.iter().map(|c| &c.name).join("+")));
|
stage_results[2].push(format!(r#""{}""#, candidates.iter().map(|c| &c.name).sorted().join("+")));
|
||||||
}
|
}
|
||||||
StageKind::SurplusesDistributed => todo!(),
|
StageKind::SurplusesDistributed => todo!(),
|
||||||
StageKind::BulkElection => todo!(),
|
StageKind::BulkElection => {
|
||||||
|
//let mut elected_candidates = Vec::new();
|
||||||
|
//for candidate in election.candidates.iter() {
|
||||||
|
// if state.candidates[candidate].state == CandidateState::Hopeful && orig_states[candidate].state != CandidateState::Hopeful {
|
||||||
|
// elected_candidates.push(candidate);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
stage_results[2].push(String::from(r#""Bulk election""#));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
stage_results[2].push(String::from(r#""#));
|
stage_results[2].push(String::from(r#""#));
|
||||||
|
|
||||||
|
@ -535,6 +548,10 @@ where
|
||||||
// Totals
|
// Totals
|
||||||
stage_results[4 + election.candidates.len()].push(String::new());
|
stage_results[4 + election.candidates.len()].push(String::new());
|
||||||
stage_results[4 + election.candidates.len()].push(format!(r#"{:.dps$}"#, valid_votes, dps=opts.pp_decimals));
|
stage_results[4 + election.candidates.len()].push(format!(r#"{:.dps$}"#, valid_votes, dps=opts.pp_decimals));
|
||||||
|
|
||||||
|
//for (candidate, count_card) in state.candidates.iter() {
|
||||||
|
// orig_states.insert(*candidate, count_card.state);
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------
|
// ----------------
|
||||||
|
|
|
@ -508,10 +508,7 @@ impl<N: Number> Ballot<N> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// State of a [Candidate] during a count
|
/// State of a [Candidate] during a count
|
||||||
#[allow(dead_code)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
#[derive(PartialEq)]
|
|
||||||
#[derive(Clone)]
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub enum CandidateState {
|
pub enum CandidateState {
|
||||||
/// Hopeful (continuing candidate)
|
/// Hopeful (continuing candidate)
|
||||||
Hopeful,
|
Hopeful,
|
||||||
|
|
Loading…
Reference in New Issue