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

Function constant_dimension_handled

nodedb-vector/src/quantize/sq8.rs:344–353  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

342
343 #[test]
344 fn constant_dimension_handled() {
345 // All vectors have the same value in dimension 0.
346 let vecs: Vec<Vec<f32>> = (0..10).map(|i| vec![5.0, i as f32]).collect();
347 let refs: Vec<&[f32]> = vecs.iter().map(|v| v.as_slice()).collect();
348 let codec = Sq8Codec::calibrate(&refs, 2);
349
350 // Constant dimension should quantize to 0 without NaN/inf.
351 let q = codec.quantize(&[5.0, 3.0]);
352 assert_eq!(q[0], 0); // constant dim
353 }
354}

Callers

nothing calls this directly

Calls 4

collectMethod · 0.80
quantizeMethod · 0.80
iterMethod · 0.45
as_sliceMethod · 0.45

Tested by

no test coverage detected