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

Function assert_weights

crates/openquant/tests/hrp.rs:52–57  ·  view source on GitHub ↗
(weights: &[f64], n_assets: usize)

Source from the content-addressed store, hash-verified

50}
51
52fn assert_weights(weights: &[f64], n_assets: usize) {
53 assert_eq!(weights.len(), n_assets);
54 assert!(weights.iter().all(|w| *w >= 0.0));
55 let sum: f64 = weights.iter().sum();
56 assert!((sum - 1.0).abs() < 1e-6, "sum={sum}");
57}
58
59#[test]
60fn test_hrp() {

Callers 5

test_hrpFunction · 0.85
test_hrp_with_shrinkageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected