mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-18 14:35:14 +01:00
skip invalid inputs in cosine distance prop test
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