MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / batch_distances_correctness

Function batch_distances_correctness

nodedb-vector/src/batch_distance.rs:51–63  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

49
50 #[test]
51 fn batch_distances_correctness() {
52 let query = [1.0, 0.0, 0.0];
53 let c1 = [0.0, 1.0, 0.0];
54 let c2 = [1.0, 0.0, 0.0];
55 let c3 = [0.0, 0.0, 1.0];
56
57 let dists = batch_distances(&query, &[&c1, &c2, &c3], DistanceMetric::L2);
58 assert_eq!(dists.len(), 3);
59 // c2 is identical to query → distance 0.
60 assert_eq!(dists[1], 0.0);
61 // c1 and c3 are equidistant from query.
62 assert_eq!(dists[0], dists[2]);
63 }
64
65 #[test]
66 fn diversity_check() {

Callers

nothing calls this directly

Calls 1

batch_distancesFunction · 0.70

Tested by

no test coverage detected