Fix clippy warnings
This commit is contained in:
parent
86a411143e
commit
3f22412aa3
|
@ -33,12 +33,12 @@ macro_rules! define_histogram {
|
||||||
pub fn with_const_width(start: f64, end: f64) -> Self {
|
pub fn with_const_width(start: f64, end: f64) -> Self {
|
||||||
let step = (end - start) / (LEN as f64);
|
let step = (end - start) / (LEN as f64);
|
||||||
let mut range = [0.; LEN + 1];
|
let mut range = [0.; LEN + 1];
|
||||||
for i in 0..(LEN + 1) {
|
for (i, r) in range.iter_mut().enumerate() {
|
||||||
range[i] = step * (i as f64);
|
*r = step * (i as f64);
|
||||||
}
|
}
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
range: range,
|
range,
|
||||||
bin: [0; LEN],
|
bin: [0; LEN],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ macro_rules! define_histogram {
|
||||||
return Err(());
|
return Err(());
|
||||||
}
|
}
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
range: range,
|
range,
|
||||||
bin: [0; LEN],
|
bin: [0; LEN],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,9 +33,7 @@ impl Min {
|
||||||
/// Create a new minium estimator from a given value.
|
/// Create a new minium estimator from a given value.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_value(x: f64) -> Min {
|
pub fn from_value(x: f64) -> Min {
|
||||||
Min {
|
Min { x }
|
||||||
x: x,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new minimum estimator.
|
/// Create a new minimum estimator.
|
||||||
|
@ -115,9 +113,7 @@ impl Max {
|
||||||
/// Create a new maxium estimator from a given value.
|
/// Create a new maxium estimator from a given value.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_value(x: f64) -> Max {
|
pub fn from_value(x: f64) -> Max {
|
||||||
Max {
|
Max { x }
|
||||||
x: x,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new maximum estimator.
|
/// Create a new maximum estimator.
|
||||||
|
|
|
@ -44,6 +44,11 @@ impl Moments {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn is_empty(&self) -> bool {
|
||||||
|
self.n == 0
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn len(&self) -> u64 {
|
pub fn len(&self) -> u64 {
|
||||||
self.n
|
self.n
|
||||||
|
|
|
@ -21,12 +21,12 @@ pub trait Histogram:
|
||||||
|
|
||||||
/// Return an iterator over the bins normalized by the bin widths.
|
/// Return an iterator over the bins normalized by the bin widths.
|
||||||
fn normalized_bins(&self) -> IterNormalized<<&Self as IntoIterator>::IntoIter> {
|
fn normalized_bins(&self) -> IterNormalized<<&Self as IntoIterator>::IntoIter> {
|
||||||
IterNormalized { histogram_iter: (&self).into_iter() }
|
IterNormalized { histogram_iter: self.into_iter() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return an iterator over the bin widths.
|
/// Return an iterator over the bin widths.
|
||||||
fn widths(&self) -> IterWidths<<&Self as IntoIterator>::IntoIter> {
|
fn widths(&self) -> IterWidths<<&Self as IntoIterator>::IntoIter> {
|
||||||
IterWidths { histogram_iter: (&self).into_iter() }
|
IterWidths { histogram_iter: self.into_iter() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ define_histogram!(Histogram10, 10);
|
||||||
fn with_const_width() {
|
fn with_const_width() {
|
||||||
let mut h = Histogram10::with_const_width(0., 100.);
|
let mut h = Histogram10::with_const_width(0., 100.);
|
||||||
for i in 0..100 {
|
for i in 0..100 {
|
||||||
h.add(i as f64).unwrap();
|
h.add(f64::from(i)).unwrap();
|
||||||
}
|
}
|
||||||
assert_eq!(h.bins(), &[10, 10, 10, 10, 10, 10, 10, 10, 10, 10]);
|
assert_eq!(h.bins(), &[10, 10, 10, 10, 10, 10, 10, 10, 10, 10]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue