Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit cca3d52

Browse files
committed
libtest: declare variables as floats instead of casting them (clippy::unnecessary_cast)
1 parent 0d7faaf commit cca3d52

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/libtest/stats.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ impl Stats for [f64] {
204204
}
205205

206206
fn median(&self) -> f64 {
207-
self.percentile(50 as f64)
207+
self.percentile(50_f64)
208208
}
209209

210210
fn var(&self) -> f64 {
@@ -230,7 +230,7 @@ impl Stats for [f64] {
230230
}
231231

232232
fn std_dev_pct(&self) -> f64 {
233-
let hundred = 100 as f64;
233+
let hundred = 100_f64;
234234
(self.std_dev() / self.mean()) * hundred
235235
}
236236

@@ -244,7 +244,7 @@ impl Stats for [f64] {
244244
}
245245

246246
fn median_abs_dev_pct(&self) -> f64 {
247-
let hundred = 100 as f64;
247+
let hundred = 100_f64;
248248
(self.median_abs_dev() / self.median()) * hundred
249249
}
250250

@@ -257,11 +257,11 @@ impl Stats for [f64] {
257257
fn quartiles(&self) -> (f64, f64, f64) {
258258
let mut tmp = self.to_vec();
259259
local_sort(&mut tmp);
260-
let first = 25f64;
260+
let first = 25_f64;
261261
let a = percentile_of_sorted(&tmp, first);
262-
let second = 50f64;
262+
let second = 50_f64;
263263
let b = percentile_of_sorted(&tmp, second);
264-
let third = 75f64;
264+
let third = 75_f64;
265265
let c = percentile_of_sorted(&tmp, third);
266266
(a, b, c)
267267
}
@@ -281,7 +281,7 @@ fn percentile_of_sorted(sorted_samples: &[f64], pct: f64) -> f64 {
281281
}
282282
let zero: f64 = 0.0;
283283
assert!(zero <= pct);
284-
let hundred = 100f64;
284+
let hundred = 100_f64;
285285
assert!(pct <= hundred);
286286
if pct == hundred {
287287
return sorted_samples[sorted_samples.len() - 1];
@@ -307,7 +307,7 @@ pub fn winsorize(samples: &mut [f64], pct: f64) {
307307
let mut tmp = samples.to_vec();
308308
local_sort(&mut tmp);
309309
let lo = percentile_of_sorted(&tmp, pct);
310-
let hundred = 100 as f64;
310+
let hundred = 100_f64;
311311
let hi = percentile_of_sorted(&tmp, hundred - pct);
312312
for samp in samples {
313313
if *samp > hi {

0 commit comments

Comments
 (0)