fix needless-range and clippy::ptr_arg warnings. (#36)
* Fix needless for loop range * Do not ignore clippy::ptr_arg
This commit is contained in:
+6
-6
@@ -120,14 +120,14 @@ impl<T: RealNumber, M: Matrix<T>> Lasso<T, M> {
|
||||
|
||||
let mut w = optimizer.optimize(&scaled_x, y, ¶meters)?;
|
||||
|
||||
for j in 0..p {
|
||||
w.set(j, 0, w.get(j, 0) / col_std[j]);
|
||||
for (j, col_std_j) in col_std.iter().enumerate().take(p) {
|
||||
w.set(j, 0, w.get(j, 0) / *col_std_j);
|
||||
}
|
||||
|
||||
let mut b = T::zero();
|
||||
|
||||
for i in 0..p {
|
||||
b += w.get(i, 0) * col_mean[i];
|
||||
for (i, col_mean_i) in col_mean.iter().enumerate().take(p) {
|
||||
b += w.get(i, 0) * *col_mean_i;
|
||||
}
|
||||
|
||||
b = y.mean() - b;
|
||||
@@ -169,8 +169,8 @@ impl<T: RealNumber, M: Matrix<T>> Lasso<T, M> {
|
||||
let col_mean = x.mean(0);
|
||||
let col_std = x.std(0);
|
||||
|
||||
for i in 0..col_std.len() {
|
||||
if (col_std[i] - T::zero()).abs() < T::epsilon() {
|
||||
for (i, col_std_i) in col_std.iter().enumerate() {
|
||||
if (*col_std_i - T::zero()).abs() < T::epsilon() {
|
||||
return Err(Failed::fit(&format!(
|
||||
"Cannot rescale constant column {}",
|
||||
i
|
||||
|
||||
Reference in New Issue
Block a user