MCPcopy Create free account
hub / github.com/Open-Quant/openquant / find_nearest

Function find_nearest

crates/openquant/src/microstructural_features.rs:480–491  ·  view source on GitHub ↗
(enc: &[(f64, char)], value: f64)

Source from the content-addressed store, hash-verified

478}
479
480fn find_nearest(enc: &[(f64, char)], value: f64) -> Option<char> {
481 let mut best = None;
482 let mut dist = f64::INFINITY;
483 for (k, c) in enc {
484 let d = (k - value).abs();
485 if d < dist {
486 dist = d;
487 best = Some(*c);
488 }
489 }
490 best
491}
492
493pub fn encode_array(array: &[f64], encoding: &[(f64, char)]) -> String {
494 let mut s = String::new();

Callers 1

encode_arrayFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected