Skip to content

Commit

Permalink
Merge pull request #7 from miek/clippy
Browse files Browse the repository at this point in the history
Clippy fixes
  • Loading branch information
miek authored Jun 17, 2024
2 parents 9343e25 + 9804625 commit bf026fa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/csv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub struct Record {
pub freq_low: u64,
pub freq_high: u64,
pub freq_step: f32,
#[allow(dead_code)]
pub num_samples: u32,
pub samples: Vec<f32>,
}
Expand Down Expand Up @@ -56,7 +57,7 @@ pub fn load_records(input_path: &str) -> Result<RecordCollection, Box<dyn Error>
.trim(csv::Trim::All)
.from_reader(input);

let mut rc = RecordCollection{ freq_low: std::u64::MAX, ..Default::default() };
let mut rc = RecordCollection{ freq_low: u64::MAX, ..Default::default() };

// Loop through all lines & parse records
// also keep track of frequency range & unique timestamps to determine final image size
Expand All @@ -72,7 +73,7 @@ pub fn load_records(input_path: &str) -> Result<RecordCollection, Box<dyn Error>
rc.freq_low = std::cmp::min(rc.freq_low, record.freq_low);
rc.freq_high = std::cmp::max(rc.freq_high, record.freq_high);
if let Some(s) = step {
if (s - record.freq_step).abs() > std::f32::EPSILON {
if (s - record.freq_step).abs() > f32::EPSILON {
return Err("Frequency step must be constant".into());
}
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ pub fn colormaps() -> HashMap<&'static str, Gradient> {
}

fn build_lut(colormap: &Gradient) -> Vec<plotters::style::RGBColor> {
let mut lut = Vec::with_capacity(std::u16::MAX as usize + 1);
for i in 0..std::u16::MAX as usize + 1 {
let value = colormap.eval_continuous(i as f64 / std::u16::MAX as f64);
let mut lut = Vec::with_capacity(u16::MAX as usize + 1);
for i in 0..u16::MAX as usize + 1 {
let value = colormap.eval_continuous(i as f64 / u16::MAX as f64);
lut.push(plotters::style::RGBColor(value.r, value.g, value.b));
}
lut
Expand Down

0 comments on commit bf026fa

Please sign in to comment.