Skip to content

Commit

Permalink
histogram: fix test for downsampling histograms
Browse files Browse the repository at this point in the history
The downsample() test uses both an incrementing factor for the
downsampling as well as a mutable reference as the baseline.
This makes the effective downsampling rate increase at a non-linear
rate (1, 3, 6, ..). Fix by cloning the histogram and using a non-mutable
reference as the baseline.
  • Loading branch information
mihirn committed Oct 18, 2023
1 parent 05534f2 commit fc7191f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions histogram/src/standard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,8 @@ mod tests {
percentiles.append(&mut tail);

// Downsample and check the percentiles lie within error margin
for factor in 1..4 {
let h = histogram.clone();
for factor in 1..7 {
let error = histogram.config.error();

for p in &percentiles {
Expand All @@ -377,7 +378,7 @@ mod tests {
assert!(e < error);
}

histogram = histogram.downsample(factor).unwrap();
histogram = h.downsample(factor).unwrap();
}
}

Expand Down

0 comments on commit fc7191f

Please sign in to comment.