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:
@@ -132,8 +132,7 @@ impl OneHotEncoder {
|
||||
data.copy_col_as_vec(idx, &mut col_buf);
|
||||
if !validate_col_is_categorical(&col_buf) {
|
||||
let msg = format!(
|
||||
"Column {} of data matrix containts non categorizable (integer) values",
|
||||
idx
|
||||
"Column {idx} of data matrix containts non categorizable (integer) values"
|
||||
);
|
||||
return Err(Failed::fit(&msg[..]));
|
||||
}
|
||||
@@ -182,7 +181,7 @@ impl OneHotEncoder {
|
||||
match oh_vec {
|
||||
None => {
|
||||
// Since we support T types, bad value in a series causes in to be invalid
|
||||
let msg = format!("At least one value in column {} doesn't conform to category definition", old_cidx);
|
||||
let msg = format!("At least one value in column {old_cidx} doesn't conform to category definition");
|
||||
return Err(Failed::transform(&msg[..]));
|
||||
}
|
||||
Some(v) => {
|
||||
@@ -338,11 +337,7 @@ mod tests {
|
||||
]);
|
||||
|
||||
let params = OneHotEncoderParams::from_cat_idx(&[1]);
|
||||
match OneHotEncoder::fit(&m, params) {
|
||||
Err(_) => {
|
||||
assert!(true);
|
||||
}
|
||||
_ => assert!(false),
|
||||
}
|
||||
let result = OneHotEncoder::fit(&m, params);
|
||||
assert!(result.is_err());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,7 +294,7 @@ mod tests {
|
||||
&[0.5708488802, 0.1846414616, 0.9590802982, 0.5591871046],
|
||||
&[0.8387612750, 0.5754861361, 0.5537109852, 0.1077646442],
|
||||
]));
|
||||
println!("{}", transformed_values);
|
||||
println!("{transformed_values}");
|
||||
assert!(transformed_values.approximate_eq(
|
||||
&DenseMatrix::from_2d_array(&[
|
||||
&[-1.1154020653, -0.4031985330, 0.9284605204, -0.4271473866],
|
||||
|
||||
@@ -206,7 +206,7 @@ mod tests {
|
||||
#[test]
|
||||
fn from_categories() {
|
||||
let fake_categories: Vec<usize> = vec![1, 2, 3, 4, 5, 3, 5, 3, 1, 2, 4];
|
||||
let it = fake_categories.iter().map(|&a| a);
|
||||
let it = fake_categories.iter().copied();
|
||||
let enc = CategoryMapper::<usize>::fit_to_iter(it);
|
||||
let oh_vec: Vec<f64> = match enc.get_one_hot(&1) {
|
||||
None => panic!("Wrong categories"),
|
||||
@@ -218,8 +218,8 @@ mod tests {
|
||||
|
||||
fn build_fake_str_enc<'a>() -> CategoryMapper<&'a str> {
|
||||
let fake_category_pos = vec!["background", "dog", "cat"];
|
||||
let enc = CategoryMapper::<&str>::from_positional_category_vec(fake_category_pos);
|
||||
enc
|
||||
|
||||
CategoryMapper::<&str>::from_positional_category_vec(fake_category_pos)
|
||||
}
|
||||
#[cfg_attr(
|
||||
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||
@@ -275,7 +275,7 @@ mod tests {
|
||||
let lab = enc.invert_one_hot(res).unwrap();
|
||||
assert_eq!(lab, "dog");
|
||||
if let Err(e) = enc.invert_one_hot(vec![0.0, 0.0, 0.0]) {
|
||||
let pos_entries = format!("Expected a single positive entry, 0 entires found");
|
||||
let pos_entries = "Expected a single positive entry, 0 entires found".to_string();
|
||||
assert_eq!(e, Failed::transform(&pos_entries[..]));
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user