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

Function deterministic_with_seed

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

Source from the content-addressed store, hash-verified

248
249 #[test]
250 fn deterministic_with_seed() {
251 let weights = vec![1.0, 2.0, 3.0, 4.0];
252 let table = AliasTable::new(&weights).unwrap();
253
254 let mut rng1 = SeedableRng::from_seed_str("deterministic");
255 let mut rng2 = SeedableRng::from_seed_str("deterministic");
256
257 let seq1: Vec<usize> = (0..20).map(|_| table.sample(&mut rng1)).collect();
258 let seq2: Vec<usize> = (0..20).map(|_| table.sample(&mut rng2)).collect();
259
260 assert_eq!(seq1, seq2);
261 }
262}

Callers

nothing calls this directly

Calls 2

collectMethod · 0.80
sampleMethod · 0.80

Tested by

no test coverage detected