MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / zero_weight_never_selected

Function zero_weight_never_selected

nodedb/src/engine/random/alias.rs:197–206  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

195
196 #[test]
197 fn zero_weight_never_selected() {
198 let weights = vec![0.0, 1.0, 0.0, 1.0];
199 let table = AliasTable::new(&weights).unwrap();
200
201 let mut rng = SeedableRng::from_seed_str("zero-test");
202 for _ in 0..1000 {
203 let idx = table.sample(&mut rng);
204 assert!(idx == 1 || idx == 3, "got zero-weight index {idx}");
205 }
206 }
207
208 #[test]
209 fn all_zero_returns_none() {

Callers

nothing calls this directly

Calls 1

sampleMethod · 0.80

Tested by

no test coverage detected