chore: justify the cast_precision_loss allows with reasons (#1474 slice)
This commit is contained in:
parent
09bcf9fd7a
commit
c819eab947
3 changed files with 40 additions and 10 deletions
|
|
@ -367,9 +367,15 @@ fn fill_buckets(
|
|||
let avg = if sorted.is_empty() {
|
||||
0.0
|
||||
} else {
|
||||
#[allow(clippy::cast_precision_loss)]
|
||||
#[allow(
|
||||
clippy::cast_precision_loss,
|
||||
reason = "stat magnitudes (counts, token + duration sums) stay well under f64's 2^53 exact-integer range, so this averaging cast loses no precision in practice"
|
||||
)]
|
||||
let sum_f = sorted.iter().sum::<i64>() as f64;
|
||||
#[allow(clippy::cast_precision_loss)]
|
||||
#[allow(
|
||||
clippy::cast_precision_loss,
|
||||
reason = "stat magnitudes (counts, token + duration sums) stay well under f64's 2^53 exact-integer range, so this averaging cast loses no precision in practice"
|
||||
)]
|
||||
let len_f = sorted.len() as f64;
|
||||
sum_f / len_f
|
||||
};
|
||||
|
|
@ -378,9 +384,15 @@ fn fill_buckets(
|
|||
let avg_ctx = if acc.turn_count == 0 {
|
||||
0.0
|
||||
} else {
|
||||
#[allow(clippy::cast_precision_loss)]
|
||||
#[allow(
|
||||
clippy::cast_precision_loss,
|
||||
reason = "stat magnitudes (counts, token + duration sums) stay well under f64's 2^53 exact-integer range, so this averaging cast loses no precision in practice"
|
||||
)]
|
||||
let sum_f = acc.ctx_sum as f64;
|
||||
#[allow(clippy::cast_precision_loss)]
|
||||
#[allow(
|
||||
clippy::cast_precision_loss,
|
||||
reason = "stat magnitudes (counts, token + duration sums) stay well under f64's 2^53 exact-integer range, so this averaging cast loses no precision in practice"
|
||||
)]
|
||||
let cnt_f = acc.turn_count as f64;
|
||||
sum_f / cnt_f
|
||||
};
|
||||
|
|
@ -427,9 +439,15 @@ fn summarize_durations(all: &mut [i64]) -> DurationSummary {
|
|||
return DurationSummary::default();
|
||||
}
|
||||
all.sort_unstable();
|
||||
#[allow(clippy::cast_precision_loss)]
|
||||
#[allow(
|
||||
clippy::cast_precision_loss,
|
||||
reason = "stat magnitudes (counts, token + duration sums) stay well under f64's 2^53 exact-integer range, so this averaging cast loses no precision in practice"
|
||||
)]
|
||||
let sum_f = all.iter().sum::<i64>() as f64;
|
||||
#[allow(clippy::cast_precision_loss)]
|
||||
#[allow(
|
||||
clippy::cast_precision_loss,
|
||||
reason = "stat magnitudes (counts, token + duration sums) stay well under f64's 2^53 exact-integer range, so this averaging cast loses no precision in practice"
|
||||
)]
|
||||
let len_f = all.len() as f64;
|
||||
DurationSummary {
|
||||
avg_ms: sum_f / len_f,
|
||||
|
|
|
|||
Loading…
Reference in a new issue