1use std::num::NonZeroU16;
2
3pub mod abc;
5pub mod distribution;
8
9pub type DNACopy = NonZeroU16;
13
14#[cfg(test)]
15pub mod test_util {
16 use std::{collections::HashMap, num::NonZeroU8};
17
18 use quickcheck::{Arbitrary, Gen};
19
20 use crate::{distribution::EcDNADistribution, DNACopy};
21
22 #[derive(Clone, Debug)]
23 pub struct DNACopySegregatingGreatherThanOne(pub DNACopy);
24
25 impl Arbitrary for DNACopySegregatingGreatherThanOne {
26 fn arbitrary(g: &mut Gen) -> DNACopySegregatingGreatherThanOne {
27 let mut copy = DNACopy::new(NonZeroU8::arbitrary(g).get() as u16).unwrap();
28 if copy == DNACopy::new(1).unwrap() {
29 copy = DNACopy::new(2).unwrap();
30 }
31 DNACopySegregatingGreatherThanOne(copy)
32 }
33 }
34
35 #[derive(Clone, Debug)]
36 pub struct NonEmptyDistribtionWithNPlusCells(pub EcDNADistribution);
37
38 impl Arbitrary for NonEmptyDistribtionWithNPlusCells {
39 fn arbitrary(g: &mut Gen) -> NonEmptyDistribtionWithNPlusCells {
40 const MAX_ENTRIES: usize = 500;
41 let mut distr = HashMap::with_capacity(MAX_ENTRIES);
42 for _ in 0..MAX_ENTRIES {
43 let copy = DNACopySegregatingGreatherThanOne::arbitrary(g);
44 let cells = NonZeroU8::arbitrary(g).get() as u64;
45 distr.insert(u16::from(copy.0), cells);
46 }
47 let cells = NonZeroU8::arbitrary(g).get() as u64;
48 distr.insert(0, cells);
49 let distr = EcDNADistribution::new(distr, 1000);
50 NonEmptyDistribtionWithNPlusCells(distr)
51 }
52 }
53}