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