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

Function train_then_encode_roundtrip

nodedb-vector/src/rerank/codecs/pq.rs:249–259  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

247
248 #[test]
249 fn train_then_encode_roundtrip() {
250 let codec = trained();
251 let v = det_vec(0, DIM);
252 let enc = codec.encode(&v).expect("encode");
253 let prep = codec.prepare_query(&v).expect("prepare_query");
254 let dist = codec.distance_prepared(&prep, &enc).expect("distance");
255 assert!(dist.is_finite(), "distance must be finite, got {dist}");
256 assert!(dist >= 0.0, "distance must be non-negative, got {dist}");
257 // Self-distance should be small for ADC on identical vector.
258 assert!(dist < 1.0, "self-distance too large: {dist}");
259 }
260
261 #[test]
262 fn encode_before_train_returns_not_trained() {

Callers

nothing calls this directly

Calls 6

trainedFunction · 0.70
det_vecFunction · 0.70
expectMethod · 0.45
encodeMethod · 0.45
prepare_queryMethod · 0.45
distance_preparedMethod · 0.45

Tested by

no test coverage detected