Skip to content

Commit 4ccb62e

Browse files
committed
style: Apply clippy and fmt fixes for v0.12.0 release (Refs release)
1 parent 299637d commit 4ccb62e

File tree

16 files changed

+56
-71
lines changed

16 files changed

+56
-71
lines changed

Cargo.lock

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/automl/params.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -503,46 +503,46 @@ mod tests {
503503
let p = RandomForestParam::NEstimators;
504504
let cloned = p;
505505
assert_eq!(p, cloned);
506-
assert!(format!("{:?}", p).contains("NEstimators"));
506+
assert!(format!("{p:?}").contains("NEstimators"));
507507
}
508508

509509
#[test]
510510
fn test_gradient_boosting_clone_debug() {
511511
let p = GradientBoostingParam::LearningRate;
512512
let cloned = p;
513513
assert_eq!(p, cloned);
514-
assert!(format!("{:?}", p).contains("LearningRate"));
514+
assert!(format!("{p:?}").contains("LearningRate"));
515515
}
516516

517517
#[test]
518518
fn test_knn_clone_debug() {
519519
let p = KNNParam::NNeighbors;
520520
let cloned = p;
521521
assert_eq!(p, cloned);
522-
assert!(format!("{:?}", p).contains("NNeighbors"));
522+
assert!(format!("{p:?}").contains("NNeighbors"));
523523
}
524524

525525
#[test]
526526
fn test_linear_clone_debug() {
527527
let p = LinearParam::Alpha;
528528
let cloned = p;
529529
assert_eq!(p, cloned);
530-
assert!(format!("{:?}", p).contains("Alpha"));
530+
assert!(format!("{p:?}").contains("Alpha"));
531531
}
532532

533533
#[test]
534534
fn test_decision_tree_clone_debug() {
535535
let p = DecisionTreeParam::MaxDepth;
536536
let cloned = p;
537537
assert_eq!(p, cloned);
538-
assert!(format!("{:?}", p).contains("MaxDepth"));
538+
assert!(format!("{p:?}").contains("MaxDepth"));
539539
}
540540

541541
#[test]
542542
fn test_kmeans_clone_debug() {
543543
let p = KMeansParam::NClusters;
544544
let cloned = p;
545545
assert_eq!(p, cloned);
546-
assert!(format!("{:?}", p).contains("NClusters"));
546+
assert!(format!("{p:?}").contains("NClusters"));
547547
}
548548
}

src/calibration.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,8 @@ mod tests {
510510
p2 >= p1,
511511
"Higher predictions should give higher calibrated values"
512512
);
513-
assert!(p1 >= 0.0 && p1 <= 1.0);
514-
assert!(p2 >= 0.0 && p2 <= 1.0);
513+
assert!((0.0..=1.0).contains(&p1));
514+
assert!((0.0..=1.0).contains(&p2));
515515
}
516516

517517
#[test]
@@ -530,9 +530,7 @@ mod tests {
530530
let curr = iso.predict(x);
531531
assert!(
532532
curr >= prev - 1e-6,
533-
"Isotonic should be monotonic: {} < {}",
534-
curr,
535-
prev
533+
"Isotonic should be monotonic: {curr} < {prev}"
536534
);
537535
prev = curr;
538536
}

src/citl/compiler.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,11 +1148,11 @@ mod tests {
11481148
fn test_rust_compiler_compile_valid_code() {
11491149
let compiler = RustCompiler::new();
11501150
// Use library-compatible code (no main function)
1151-
let code = r#"
1151+
let code = r"
11521152
pub fn add(a: i32, b: i32) -> i32 {
11531153
a + b
11541154
}
1155-
"#;
1155+
";
11561156
let result = compiler.compile(code, &CompileOptions::default());
11571157
assert!(result.is_ok());
11581158
let result = result.expect("Should compile");
@@ -1264,7 +1264,7 @@ pub fn add(a: i32, b: i32) -> i32 {
12641264
.write_to_temp()
12651265
.expect("Should write");
12661266

1267-
let dir = project.project_dir().expect("Has dir").to_path_buf();
1267+
let dir = project.project_dir().expect("Has dir").clone();
12681268
assert!(dir.exists());
12691269

12701270
drop(project);

src/citl/encoder.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -666,8 +666,7 @@ mod tests {
666666
let similarity = e1.cosine_similarity(&e2);
667667
assert!(
668668
similarity > 0.5,
669-
"Similar errors should have similarity > 0.5, got {}",
670-
similarity
669+
"Similar errors should have similarity > 0.5, got {similarity}"
671670
);
672671
}
673672

@@ -701,8 +700,7 @@ mod tests {
701700
let similarity = e1.cosine_similarity(&e2);
702701
assert!(
703702
similarity < 0.9,
704-
"Different errors should have similarity < 0.9, got {}",
705-
similarity
703+
"Different errors should have similarity < 0.9, got {similarity}"
706704
);
707705
}
708706

src/citl/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,7 @@ mod tests {
10441044
let suggestion = citl.suggest_fix(&diag, "let x: String = 42;");
10451045
// Should find a suggestion (may or may not match well depending on embedding)
10461046
// The key is that it doesn't panic and returns Some when pattern exists
1047-
assert!(suggestion.is_some() || citl.pattern_library.len() > 0);
1047+
assert!(suggestion.is_some() || !citl.pattern_library.is_empty());
10481048
}
10491049

10501050
#[test]
@@ -1285,15 +1285,15 @@ pub fn greet(name: &str) -> String {
12851285
});
12861286

12871287
// Valid code
1288-
let code = r#"
1288+
let code = r"
12891289
pub fn multiply(a: f64, b: f64) -> f64 {
12901290
a * b
12911291
}
12921292
12931293
pub fn is_positive(n: i32) -> bool {
12941294
n > 0
12951295
}
1296-
"#;
1296+
";
12971297

12981298
let result = compiler.compile(code, &CompileOptions::default());
12991299
assert!(result.is_ok());

src/citl/neural.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,8 +1401,7 @@ mod tests {
14011401
let norm: f32 = embedding.iter().map(|x| x * x).sum::<f32>().sqrt();
14021402
assert!(
14031403
(norm - 1.0).abs() < 0.01,
1404-
"Embedding norm should be ~1.0, got {}",
1405-
norm
1404+
"Embedding norm should be ~1.0, got {norm}"
14061405
);
14071406
}
14081407

@@ -1436,9 +1435,7 @@ mod tests {
14361435
// Similar errors should have higher similarity
14371436
assert!(
14381437
sim_12 > sim_13,
1439-
"Similar errors should have higher similarity: sim_12={}, sim_13={}",
1440-
sim_12,
1441-
sim_13
1438+
"Similar errors should have higher similarity: sim_12={sim_12}, sim_13={sim_13}"
14421439
);
14431440
}
14441441

@@ -1457,7 +1454,7 @@ mod tests {
14571454
// Should still be somewhat similar (both are type errors)
14581455
let sim = cosine_sim(&emb_rust, &emb_python);
14591456
// Just verify it's a valid similarity value
1460-
assert!(sim >= -1.0 && sim <= 1.0);
1457+
assert!((-1.0..=1.0).contains(&sim));
14611458
}
14621459

14631460
// ==================== ContrastiveLoss Tests ====================

src/citl/pattern.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1174,7 +1174,7 @@ mod tests {
11741174
#[test]
11751175
fn test_template_borrow_instead_of_move() {
11761176
let template = templates::borrow_instead_of_move();
1177-
assert!(template.pattern.contains("&"));
1177+
assert!(template.pattern.contains('&'));
11781178
assert!(template.applies_to("E0382"));
11791179
assert!(template.confidence > 0.7);
11801180
}

src/ensemble/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ mod tests {
3232
let gating = SoftmaxGating::new(4, 3).with_temperature(0.01);
3333
let input = vec![1.0, 2.0, 3.0, 4.0];
3434
let weights = gating.forward(&input);
35-
let max_weight = weights.iter().cloned().fold(0.0f32, f32::max);
35+
let max_weight = weights.iter().copied().fold(0.0f32, f32::max);
3636
assert!(max_weight > 0.9);
3737
}
3838

@@ -58,7 +58,7 @@ mod tests {
5858
.build()
5959
.expect("build");
6060
let output = moe.predict(&[1.0, 2.0, 3.0, 4.0]);
61-
assert!(output >= 10.0 && output <= 20.0);
61+
assert!((10.0..=20.0).contains(&output));
6262
}
6363

6464
#[test]

src/format/gguf.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ mod tests {
749749
];
750750
for t in types {
751751
assert_eq!(t, t);
752-
assert!(!format!("{:?}", t).is_empty());
752+
assert!(!format!("{t:?}").is_empty());
753753
}
754754
}
755755

@@ -773,7 +773,7 @@ mod tests {
773773
];
774774
for t in types {
775775
assert_eq!(t, t);
776-
assert!(!format!("{:?}", t).is_empty());
776+
assert!(!format!("{t:?}").is_empty());
777777
}
778778
}
779779

@@ -787,7 +787,7 @@ mod tests {
787787
assert_eq!(t, GgufValueType::Uint8);
788788
let cloned = t;
789789
assert_eq!(t, cloned);
790-
assert!(format!("{:?}", t).contains("Uint8"));
790+
assert!(format!("{t:?}").contains("Uint8"));
791791
}
792792

793793
#[test]
@@ -796,14 +796,14 @@ mod tests {
796796
assert_eq!(t, GgmlType::F32);
797797
let cloned = t;
798798
assert_eq!(t, cloned);
799-
assert!(format!("{:?}", t).contains("F32"));
799+
assert!(format!("{t:?}").contains("F32"));
800800
}
801801

802802
#[test]
803803
fn test_gguf_value_clone() {
804804
let v = GgufValue::String("test".to_string());
805805
let cloned = v.clone();
806-
assert!(format!("{:?}", cloned).contains("test"));
806+
assert!(format!("{cloned:?}").contains("test"));
807807
}
808808

809809
#[test]
@@ -816,7 +816,7 @@ mod tests {
816816
let cloned = h.clone();
817817
assert_eq!(cloned.version, 3);
818818
assert_eq!(cloned.tensor_count, 10);
819-
assert!(format!("{:?}", cloned).contains("GgufHeader"));
819+
assert!(format!("{cloned:?}").contains("GgufHeader"));
820820
}
821821
}
822822

0 commit comments

Comments
 (0)