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

Function test_num_concurrent_events

crates/openquant/tests/sampling.rs:27–43  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

25
26#[test]
27fn test_num_concurrent_events() {
28 let (price_bars, t1) = setup_labels();
29 let t_events: Vec<usize> = vec![1, 2, 5, 7, 10, 11, 12, 20];
30 let num = num_concurrent_events(price_bars.len(), &t1, &t_events);
31 let start = *t_events.first().unwrap();
32 let end = t1.iter().map(|(_, e)| *e).max().unwrap();
33 let slice = &num[start..=end];
34 // value counts: 0 ->5, 1 ->11, 2 ->5, 3 ->1 (from Python test)
35 let mut counts = std::collections::HashMap::new();
36 for v in slice {
37 *counts.entry(v).or_insert(0) += 1;
38 }
39 assert_eq!(*counts.get(&0).unwrap(), 5);
40 assert_eq!(*counts.get(&1).unwrap(), 11);
41 assert_eq!(*counts.get(&2).unwrap(), 5);
42 assert_eq!(*counts.get(&3).unwrap(), 1);
43}
44
45#[test]
46fn test_get_av_uniqueness() {

Callers

nothing calls this directly

Calls 3

setup_labelsFunction · 0.85
lenMethod · 0.80
num_concurrent_eventsFunction · 0.50

Tested by

no test coverage detected