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

Function happy_path_top2

nodedb-vector/src/rerank/pipeline.rs:274–298  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

272
273 #[test]
274 fn happy_path_top2() {
275 let s = store(&[
276 (1, vec![1.0, 0.0]),
277 (2, vec![0.1, 0.0]),
278 (3, vec![0.5, 0.0]),
279 (4, vec![2.0, 0.0]),
280 (5, vec![0.3, 0.0]),
281 ]);
282 let candidates = vec![make(1), make(2), make(3), make(4), make(5)];
283 let query = [0.0, 0.0];
284 let result = rerank(
285 candidates,
286 &query,
287 DistanceMetric::L2,
288 2,
289 &opts(),
290 None,
291 fetch(&s),
292 )
293 .unwrap();
294 assert_eq!(result.len(), 2);
295 // closest: id=2 (0.01), then id=5 (0.09)
296 assert_eq!(result[0].id, 2);
297 assert_eq!(result[1].id, 5);
298 }
299
300 #[test]
301 fn empty_candidates_returns_empty() {

Callers

nothing calls this directly

Calls 4

fetchFunction · 0.85
storeFunction · 0.70
rerankFunction · 0.70
optsFunction · 0.70

Tested by

no test coverage detected