Skip to content

Commit

Permalink
fix NaN issues
Browse files Browse the repository at this point in the history
  • Loading branch information
o-tho committed Nov 11, 2024
1 parent 882eb0b commit 3b1ac6d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl Question {
self.boxes
.clone()
.into_iter()
.map(|b| (b.blackness(&scan) * 100.0).round() / 100.0)
.map(|b| b.blackness(&scan))
.collect()
}

Expand All @@ -63,7 +63,12 @@ impl Question {
.collect()
}
pub fn choice(&self, scan: &Scan) -> Option<u32> {
let blackness = self.blacknesses(scan);
let blackness: Vec<f64> = self
.blacknesses(scan)
.iter()
.map(|&v| if v.is_nan() { 0.0 } else { v })
.collect();

if blackness.len() < 2 {
return None;
}
Expand Down

0 comments on commit 3b1ac6d

Please sign in to comment.