Run cargo clippy --fix (#250)

* Run `cargo clippy --fix`
* Run `cargo clippy --all-features --fix`
* Fix other clippy warnings
* cargo fmt

Co-authored-by: Luis Moreno <morenol@users.noreply.github.com>
This commit is contained in:
morenol
2023-01-27 06:41:18 -04:00
committed by GitHub
parent 83dcf9a8ac
commit c7353d0b57
47 changed files with 146 additions and 222 deletions
+1 -4
View File
@@ -425,10 +425,7 @@ impl<TX: FloatNumber + RealNumber, TY: Number, X: Array2<TX>, Y: Array1<TY>>
for (i, col_std_i) in col_std.iter().enumerate() {
if (*col_std_i - TX::zero()).abs() < TX::epsilon() {
return Err(Failed::fit(&format!(
"Cannot rescale constant column {}",
i
)));
return Err(Failed::fit(&format!("Cannot rescale constant column {i}")));
}
}
+1 -4
View File
@@ -356,10 +356,7 @@ impl<TX: FloatNumber + RealNumber, TY: Number, X: Array2<TX>, Y: Array1<TY>> Las
for (i, col_std_i) in col_std.iter().enumerate() {
if (*col_std_i - TX::zero()).abs() < TX::epsilon() {
return Err(Failed::fit(&format!(
"Cannot rescale constant column {}",
i
)));
return Err(Failed::fit(&format!("Cannot rescale constant column {i}")));
}
}
+7 -8
View File
@@ -449,8 +449,7 @@ impl<TX: Number + FloatNumber + RealNumber, TY: Number + Ord, X: Array2<TX>, Y:
match k.cmp(&2) {
Ordering::Less => Err(Failed::fit(&format!(
"incorrect number of classes: {}. Should be >= 2.",
k
"incorrect number of classes: {k}. Should be >= 2."
))),
Ordering::Equal => {
let x0 = Vec::zeros(num_attributes + 1);
@@ -636,19 +635,19 @@ mod tests {
assert!((g[0] + 33.000068218163484).abs() < std::f64::EPSILON);
let f = objective.f(&vec![1., 2., 3., 4., 5., 6., 7., 8., 9.]);
let f = objective.f(&[1., 2., 3., 4., 5., 6., 7., 8., 9.]);
assert!((f - 408.0052230582765).abs() < std::f64::EPSILON);
let objective_reg = MultiClassObjectiveFunction {
x: &x,
y: y.clone(),
y,
k: 3,
alpha: 1.0,
_phantom_t: PhantomData,
};
let f = objective_reg.f(&vec![1., 2., 3., 4., 5., 6., 7., 8., 9.]);
let f = objective_reg.f(&[1., 2., 3., 4., 5., 6., 7., 8., 9.]);
assert!((f - 487.5052).abs() < 1e-4);
objective_reg.df(&mut g, &vec![1., 2., 3., 4., 5., 6., 7., 8., 9.]);
@@ -697,18 +696,18 @@ mod tests {
assert!((g[1] - 10.239000702928523).abs() < std::f64::EPSILON);
assert!((g[2] - 3.869294270156324).abs() < std::f64::EPSILON);
let f = objective.f(&vec![1., 2., 3.]);
let f = objective.f(&[1., 2., 3.]);
assert!((f - 59.76994756647412).abs() < std::f64::EPSILON);
let objective_reg = BinaryObjectiveFunction {
x: &x,
y: y.clone(),
y,
alpha: 1.0,
_phantom_t: PhantomData,
};
let f = objective_reg.f(&vec![1., 2., 3.]);
let f = objective_reg.f(&[1., 2., 3.]);
assert!((f - 62.2699).abs() < 1e-4);
objective_reg.df(&mut g, &vec![1., 2., 3.]);
+1 -4
View File
@@ -384,10 +384,7 @@ impl<
for (i, col_std_i) in col_std.iter().enumerate() {
if (*col_std_i - TX::zero()).abs() < TX::epsilon() {
return Err(Failed::fit(&format!(
"Cannot rescale constant column {}",
i
)));
return Err(Failed::fit(&format!("Cannot rescale constant column {i}")));
}
}