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

Function assert_basic_weights

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

Source from the content-addressed store, hash-verified

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

Calls

no outgoing calls

Tested by

no test coverage detected