Skip to content

Commit

Permalink
fix NaN case
Browse files Browse the repository at this point in the history
  • Loading branch information
brenzi committed Mar 19, 2024
1 parent f7b7509 commit b126323
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions client/src/commands/encointer_ceremonies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ pub fn list_attestees(_args: &str, matches: &ArgMatches<'_>) -> Result<(), clap:
let vote = api
.get_meetup_participant_count_vote((cid, cindex), attestor.clone(), at_block)
.await
.unwrap();
.unwrap_or(0);
let attestation_state =
AttestationState::new((cid, cindex), meetup_index, vote, w, attestor, attestees);

Expand Down Expand Up @@ -307,7 +307,11 @@ pub fn list_attestees(_args: &str, matches: &ArgMatches<'_>) -> Result<(), clap:
votes.push(a.vote);
}
}
let mean_vote: f64 = votes.iter().sum::<u32>() as f64 / votes.len() as f64;
let mut mean_vote: f64 = votes.iter().sum::<u32>() as f64 / votes.len() as f64;
if mean_vote.is_nan() {
mean_vote = 0f64;
}

all_votes.insert(*m, mean_vote);
println!(
"CSVmeetupVotes: {cindex}, {cid}, {m}, {}, {:.3}, {:?}",
Expand All @@ -317,7 +321,12 @@ pub fn list_attestees(_args: &str, matches: &ArgMatches<'_>) -> Result<(), clap:
);
}

println!("CSV: {cindex}, {cid}, {wcount}, {}", all_votes.values().sum::<f64>());
println!("cindex, cid, assignees, attestors, sum of mean votes");
println!(
"CSV: {cindex}, {cid}, {}, {wcount}, {}",
meetup_sizes.values().sum::<usize>(),
all_votes.values().sum::<f64>()
);
Ok(())
})
.into()
Expand Down

0 comments on commit b126323

Please sign in to comment.