Skip to content

fix: Fix new clippy warnings #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#![allow(
clippy::type_complexity,
clippy::too_many_arguments,
clippy::many_single_char_names
clippy::many_single_char_names,
clippy::unnecessary_wraps
)]
#![warn(missing_docs)]
#![warn(missing_doc_code_examples)]
Expand Down
3 changes: 2 additions & 1 deletion src/linalg/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::wrong_self_convention)]
//! # Linear Algebra and Matrix Decomposition
//!
//! Most machine learning algorithms in SmartCore depend on linear algebra and matrix decomposition methods from this module.
Expand Down Expand Up @@ -265,7 +266,7 @@ pub trait BaseVector<T: RealNumber>: Clone + Debug {
sum += xi * xi;
}
mu /= div;
sum / div - mu * mu
sum / div - mu.powi(2)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering what is faster in Rust, mu * mu or mu.powi(2)? I always thought that multiplication is faster but that might not be true in Rust. This might be a small thing, but if repeated many times the difference will accumulate to a significant value.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
/// Computes the standard deviation.
fn std(&self) -> T {
Expand Down
2 changes: 1 addition & 1 deletion src/linalg/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub trait MatrixStats<T: RealNumber>: BaseMatrix<T> {
sum += a * a;
}
mu /= div;
*x_i = sum / div - mu * mu;
*x_i = sum / div - mu.powi(2);
}

x
Expand Down
2 changes: 1 addition & 1 deletion src/linear/lasso_optimizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl<T: RealNumber, M: Matrix<T>> InteriorPointOptimizer<T, M> {

for i in 0..p {
self.prb[i] = T::two() + self.d1[i];
self.prs[i] = self.prb[i] * self.d1[i] - self.d2[i] * self.d2[i];
self.prs[i] = self.prb[i] * self.d1[i] - self.d2[i].powi(2);
}

let normg = grad.norm2();
Expand Down
1 change: 1 addition & 0 deletions src/optimization/first_order/lbfgs.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::suspicious_operation_groupings)]
use std::default::Default;
use std::fmt::Debug;

Expand Down