mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-05 01:04:22 +01:00
Merge 'skip invalid inputs in cosine distance prop test' from bit-aloo
closes: #1790 Updates test_vector_distance to treat invalid inputs as non-errors, skipping them instead. These cases aren't considered real errors, so no explicit error handling is needed in the test. Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com> Closes #2341
This commit is contained in:
@@ -612,20 +612,13 @@ mod tests {
|
||||
}
|
||||
|
||||
/// Test if the vector distance calculation is correct for a given pair of vectors:
|
||||
/// - The vectors have the same dimensions
|
||||
/// - The vectors have the same type
|
||||
/// - Skips cases with invalid input vectors.
|
||||
/// - Assumes vectors are well-formed (same type and dimension)
|
||||
/// - The distance must be between 0 and 2
|
||||
fn test_vector_distance<const DIMS: usize>(v1: &Vector, v2: &Vector) -> bool {
|
||||
if v1.vector_type != v2.vector_type {
|
||||
// Skip test if types are different
|
||||
return true;
|
||||
}
|
||||
match do_vector_distance_cos(v1, v2) {
|
||||
Ok(distance) => {
|
||||
// Cosine distance is always between 0 and 2
|
||||
(0.0..=2.0).contains(&distance)
|
||||
}
|
||||
Err(_) => false,
|
||||
Ok(distance) => (0.0..=2.0).contains(&distance),
|
||||
Err(_) => true,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user