From f0371673a43642314ae55ebb0006b8dd2163625e Mon Sep 17 00:00:00 2001 From: Volodymyr Orlov Date: Wed, 11 Nov 2020 17:23:49 -0800 Subject: [PATCH] fix: changes recommended by Clippy --- src/linear/logistic_regression.rs | 18 +++++++++--------- src/linear/ridge_regression.rs | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/linear/logistic_regression.rs b/src/linear/logistic_regression.rs index addede7..4b52529 100644 --- a/src/linear/logistic_regression.rs +++ b/src/linear/logistic_regression.rs @@ -110,8 +110,8 @@ impl> PartialEq for LogisticRegression { return false; } } - - return self.coefficients == other.coefficients && self.intercept == other.intercept; + + self.coefficients == other.coefficients && self.intercept == other.intercept } } } @@ -242,7 +242,7 @@ impl> LogisticRegression { let x0 = M::zeros(1, num_attributes + 1); let objective = BinaryObjectiveFunction { - x: x, + x, y: yi, phantom: PhantomData, }; @@ -254,8 +254,8 @@ impl> LogisticRegression { Ok(LogisticRegression { coefficients: weights.slice(0..1, 0..num_attributes), intercept: weights.slice(0..1, num_attributes..num_attributes + 1), - classes: classes, - num_attributes: num_attributes, + classes, + num_attributes, num_classes: k, }) } @@ -263,9 +263,9 @@ impl> LogisticRegression { let x0 = M::zeros(1, (num_attributes + 1) * k); let objective = MultiClassObjectiveFunction { - x: x, + x, y: yi, - k: k, + k, phantom: PhantomData, }; @@ -275,8 +275,8 @@ impl> LogisticRegression { Ok(LogisticRegression { coefficients: weights.slice(0..k, 0..num_attributes), intercept: weights.slice(0..k, num_attributes..num_attributes + 1), - classes: classes, - num_attributes: num_attributes, + classes, + num_attributes, num_classes: k, }) } diff --git a/src/linear/ridge_regression.rs b/src/linear/ridge_regression.rs index a718e2a..beac40b 100644 --- a/src/linear/ridge_regression.rs +++ b/src/linear/ridge_regression.rs @@ -129,13 +129,13 @@ impl> RidgeRegression { let (n, p) = x.shape(); if n <= p { - return Err(Failed::fit(&format!( + return Err(Failed::fit( "Number of rows in X should be >= number of columns in X" - ))); + )); } if y.len() != n { - return Err(Failed::fit(&format!("Number of rows in X should = len(y)"))); + return Err(Failed::fit("Number of rows in X should = len(y)")); } let y_column = M::from_row_vector(y.clone()).transpose();