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

Function nanmean

crates/openquant/tests/volatility_features.rs:33–43  ·  view source on GitHub ↗
(values: &[f64])

Source from the content-addressed store, hash-verified

31 (open, high, low, close)
32}
33
34/// Expected values from tests/fixtures/volatility/generate_range.py (Parkinson 1980,
35/// Garman & Klass 1980, Yang & Zhang 2000, computed in pandas independently of this crate).
36fn reference() -> Value {
37 let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
38 .join("../../tests/fixtures/volatility/range_reference.json");
39 serde_json::from_str(&std::fs::read_to_string(path).unwrap()).unwrap()
40}
41
42/// Compare an estimator's output with one entry of the reference: the NaN warm-up count,
43/// the mean of the non-NaN values and the sampled positions.
44fn assert_matches(actual: &[f64], expected: &Value) {
45 let n_nan = actual.iter().filter(|v| v.is_nan()).count() as u64;
46 assert_eq!(n_nan, expected["n_nan"].as_u64().unwrap());

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected