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
+4 -9
View File
@@ -158,8 +158,7 @@ impl<T: Number + Unsigned> CategoricalNBDistribution<T> {
pub fn fit<X: Array2<T>, Y: Array1<T>>(x: &X, y: &Y, alpha: f64) -> Result<Self, Failed> {
if alpha < 0f64 {
return Err(Failed::fit(&format!(
"alpha should be >= 0, alpha=[{}]",
alpha
"alpha should be >= 0, alpha=[{alpha}]"
)));
}
@@ -167,15 +166,13 @@ impl<T: Number + Unsigned> CategoricalNBDistribution<T> {
let y_samples = y.shape();
if y_samples != n_samples {
return Err(Failed::fit(&format!(
"Size of x should equal size of y; |x|=[{}], |y|=[{}]",
n_samples, y_samples
"Size of x should equal size of y; |x|=[{n_samples}], |y|=[{y_samples}]"
)));
}
if n_samples == 0 {
return Err(Failed::fit(&format!(
"Size of x and y should greater than 0; |x|=[{}]",
n_samples
"Size of x and y should greater than 0; |x|=[{n_samples}]"
)));
}
let y: Vec<usize> = y.iterator(0).map(|y_i| y_i.to_usize().unwrap()).collect();
@@ -202,8 +199,7 @@ impl<T: Number + Unsigned> CategoricalNBDistribution<T> {
.max()
.ok_or_else(|| {
Failed::fit(&format!(
"Failed to get the categories for feature = {}",
feature
"Failed to get the categories for feature = {feature}"
))
})?;
n_categories.push(feature_max + 1);
@@ -429,7 +425,6 @@ mod tests {
fn search_parameters() {
let parameters = CategoricalNBSearchParameters {
alpha: vec![1., 2.],
..Default::default()
};
let mut iter = parameters.into_iter();
let next = iter.next().unwrap();