Fix clippy warnings.
This commit is contained in:
@@ -140,7 +140,7 @@ where
|
||||
) where
|
||||
S2: DataMut<Elem = f64>,
|
||||
{
|
||||
if self.len() > 0 {
|
||||
if !self.is_empty() {
|
||||
let mut reversed;
|
||||
let mut forward;
|
||||
|
||||
@@ -850,7 +850,7 @@ where
|
||||
find_parallel_columns_in(a, c, column_is_parallel);
|
||||
find_parallel_columns_between(a, b, c, column_is_parallel);
|
||||
let mut has_resampled = false;
|
||||
for (i, is_parallel) in column_is_parallel.into_iter().enumerate() {
|
||||
for (i, is_parallel) in column_is_parallel.iter_mut().enumerate() {
|
||||
if *is_parallel {
|
||||
resample_column(a, i, rng, sample);
|
||||
has_resampled = true;
|
||||
@@ -871,7 +871,7 @@ where
|
||||
i < a.dim().1,
|
||||
"Trying to resample column with index exceeding matrix dimensions"
|
||||
);
|
||||
assert!(sample.len() > 0);
|
||||
assert!(!sample.is_empty());
|
||||
a.column_mut(i)
|
||||
.mapv_inplace(|_| sample[rng.gen_range(0, sample.len())]);
|
||||
}
|
||||
|
||||
@@ -187,8 +187,8 @@ impl PadeOrder for $ty {
|
||||
_ => unreachable!()
|
||||
};
|
||||
|
||||
work.zip_mut_with(a_pow, |x, &y| *x = *x + c_2k1 * y);
|
||||
v.zip_mut_with(a_pow, |x, &y| *x = *x + c_2k * y);
|
||||
work.zip_mut_with(a_pow, |x, &y| *x += c_2k1 * y);
|
||||
v.zip_mut_with(a_pow, |x, &y| *x += c_2k * y);
|
||||
}
|
||||
|
||||
let (a_slice, a_layout) = as_slice_with_layout(a).expect("Matrix `a` not contiguous.");
|
||||
@@ -601,7 +601,7 @@ impl Expm {
|
||||
use std::f64;
|
||||
let mut s = cmp::max(f64::ceil(f64::log2(eta_5 / THETA_13)) as i32, 0);
|
||||
self.a1.mapv_inplace(|x| x / 2f64.powi(s));
|
||||
s = s + self.ell(13);
|
||||
s += self.ell(13);
|
||||
self.a1.zip_mut_with(a, |x, &y| *x = y / 2f64.powi(s));
|
||||
self.a2.mapv_inplace(|x| x / 2f64.powi(2 * s));
|
||||
self.a4.mapv_inplace(|x| x / 2f64.powi(4 * s));
|
||||
@@ -693,7 +693,7 @@ impl Expm {
|
||||
self.work.assign(v);
|
||||
|
||||
Zip::from(&mut *v).and(&self.u).apply(|x, &y| {
|
||||
*x = *x + y;
|
||||
*x += y;
|
||||
});
|
||||
|
||||
Zip::from(&mut self.u).and(&self.work).apply(|x, &y| {
|
||||
|
||||
@@ -146,10 +146,10 @@ impl Fitter for RecursiveFitter {
|
||||
let k = self.p_p[i].dot(&self.h)
|
||||
/ (1.0 + self.xs[i] * self.h.dot(&self.p_p[i]).dot(&self.h));
|
||||
|
||||
let k = Array1::from(k);
|
||||
// let k = Array1::from(k);
|
||||
|
||||
self.m_f[i] =
|
||||
&self.m_p[i] + &(&k * (&self.ns[i] - &self.xs[i] * &self.h.dot(&self.m_p[i])));
|
||||
&self.m_p[i] + &(&k * (self.ns[i] - self.xs[i] * self.h.dot(&self.m_p[i])));
|
||||
|
||||
// Covariance matrix is computed using the Joseph form.
|
||||
let outer = (self.xs[i] * &k)
|
||||
@@ -274,7 +274,7 @@ impl Fitter for RecursiveFitter {
|
||||
}
|
||||
|
||||
fn vs(&self, idx: usize) -> f64 {
|
||||
*&self.vs[idx]
|
||||
self.vs[idx]
|
||||
}
|
||||
|
||||
fn vs_mut(&mut self, idx: usize) -> &mut f64 {
|
||||
@@ -282,7 +282,7 @@ impl Fitter for RecursiveFitter {
|
||||
}
|
||||
|
||||
fn ms(&self, idx: usize) -> f64 {
|
||||
*&self.ms[idx]
|
||||
self.ms[idx]
|
||||
}
|
||||
|
||||
fn ms_mut(&mut self, idx: usize) -> &mut f64 {
|
||||
@@ -290,7 +290,7 @@ impl Fitter for RecursiveFitter {
|
||||
}
|
||||
|
||||
fn xs(&self, idx: usize) -> f64 {
|
||||
*&self.xs[idx]
|
||||
self.xs[idx]
|
||||
}
|
||||
|
||||
fn xs_mut(&mut self, idx: usize) -> &mut f64 {
|
||||
@@ -298,7 +298,7 @@ impl Fitter for RecursiveFitter {
|
||||
}
|
||||
|
||||
fn ns(&self, idx: usize) -> f64 {
|
||||
*&self.ns[idx]
|
||||
self.ns[idx]
|
||||
}
|
||||
|
||||
fn ns_mut(&mut self, idx: usize) -> &mut f64 {
|
||||
|
||||
@@ -28,7 +28,7 @@ pub struct BinaryModel {
|
||||
impl BinaryModel {
|
||||
pub fn new(win_obs: BinaryModelObservation) -> Self {
|
||||
BinaryModel {
|
||||
storage: Storage::new(),
|
||||
storage: Storage::default(),
|
||||
last_t: f64::NEG_INFINITY,
|
||||
win_obs,
|
||||
observations: Vec::new(),
|
||||
|
||||
@@ -23,7 +23,7 @@ pub struct DifferenceModel {
|
||||
impl DifferenceModel {
|
||||
pub fn new(var: f64) -> Self {
|
||||
DifferenceModel {
|
||||
storage: Storage::new(),
|
||||
storage: Storage::default(),
|
||||
last_t: f64::NEG_INFINITY,
|
||||
observations: Vec::new(),
|
||||
_last_method: None,
|
||||
|
||||
@@ -30,7 +30,7 @@ pub struct TernaryModel {
|
||||
impl TernaryModel {
|
||||
pub fn new(obs: TernaryModelObservation, margin: f64) -> Self {
|
||||
TernaryModel {
|
||||
storage: Storage::new(),
|
||||
storage: Storage::default(),
|
||||
last_t: f64::NEG_INFINITY,
|
||||
obs, // default = probit
|
||||
observations: Vec::new(),
|
||||
|
||||
@@ -8,13 +8,6 @@ pub struct Storage {
|
||||
}
|
||||
|
||||
impl Storage {
|
||||
pub fn new() -> Self {
|
||||
Storage {
|
||||
keys: HashMap::new(),
|
||||
items: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn contains_key(&self, key: &str) -> bool {
|
||||
self.keys.contains_key(key)
|
||||
}
|
||||
@@ -54,3 +47,12 @@ impl Storage {
|
||||
self.keys.keys()
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Storage {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
keys: HashMap::new(),
|
||||
items: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user