Browse Source

Cap the amount of buckets with the number of values read

pull/2/head
JuanLeon Lahoz 5 years ago
parent
commit
b19e77b870
  1. 2
      src/app.rs
  2. 3
      src/main.rs

2
src/app.rs

@ -67,7 +67,7 @@ pub fn get_app() -> App<'static> {
Arg::new("intervals")
.long("intervals")
.short('i')
.about("Use that many buckets to classify data")
.about("Use no more than this amount of buckets to classify data")
.default_value("20")
.takes_value(true)
);

3
src/main.rs

@ -88,7 +88,8 @@ fn main() {
let width = sub_matches.value_of_t("width").unwrap();
match matches.subcommand_name() {
Some("hist") => {
let intervals = sub_matches.value_of_t("intervals").unwrap();
let mut intervals: usize = sub_matches.value_of_t("intervals").unwrap();
intervals = intervals.min(vec.len());
let mut histogram = histogram::Histogram::new(
intervals,
(stats.max - stats.min) / intervals as f64,

Loading…
Cancel
Save