Skip to content

Commit 0ce557f

Browse files
committed
style: apply clippy suggestions for code quality improvements
- Replace raw string literal `r#"[1, 2, 3]"#` with simpler `r"[1, 2, 3]"` in extract_json_direct_array test - Remove redundant `chrono::` prefix from `Utc::now()` call in metadata_filter_not_empty_with_timestamp test - Replace manual dot product calculation with `mul_add` for better numerical precision in cosine_similarity_arbitrary test
1 parent 6bfe774 commit 0ce557f

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

meme/src/llm/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ mod tests {
352352

353353
#[test]
354354
fn extract_json_direct_array() {
355-
let v = extract_json_from_text(r#"[1, 2, 3]"#).unwrap();
355+
let v = extract_json_from_text(r"[1, 2, 3]").unwrap();
356356
assert_eq!(v.as_array().unwrap().len(), 3);
357357
}
358358

meme/src/model/entry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ mod tests {
131131

132132
#[test]
133133
fn metadata_filter_not_empty_with_timestamp() {
134-
let now = chrono::Utc::now();
134+
let now = Utc::now();
135135
let f = MetadataFilter {
136136
timestamp_range: Some((now, now)),
137137
..Default::default()

meme/src/store/vector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ mod tests {
846846
fn cosine_similarity_arbitrary() {
847847
let a = vec![1.0, 2.0, 3.0];
848848
let b = vec![4.0, 5.0, 6.0];
849-
let dot = 1.0 * 4.0 + 2.0 * 5.0 + 3.0 * 6.0;
849+
let dot = 3.0f64.mul_add(6.0, 2.0f64.mul_add(5.0, 1.0 * 4.0));
850850
let mag_a = (1.0_f64 + 4.0 + 9.0).sqrt();
851851
let mag_b = (16.0_f64 + 25.0 + 36.0).sqrt();
852852
let expected = dot / (mag_a * mag_b);

0 commit comments

Comments
 (0)