Can we get a value of Pi that applies to all of the samples in the multi population objects? That would be useful.
One way would be to provide an iterator that groups the SiteCounts over populations, kinda like:
struct Thing {
data: Vec<i32>,
lengths: Vec<usize>,
}
struct GroupedIter<'t> {
data: &'t [i32],
lengths: &'t [usize],
}
impl<'t> Iterator for GroupedIter<'t> {
type Item = i32;
fn next(&mut self) -> Option<Self::Item> {
if let Some(&first) = self.lengths.split_off_first() {
let (rv, remainder) = self.data.split_at(first);
self.data = remainder;
Some(rv.iter().sum::<i32>())
} else {
None
}
}
}
impl Thing {
fn iter_grouped(&self) -> impl Iterator<Item = i32> {
GroupedIter {
data: &self.data,
lengths: &self.lengths,
}
}
}
fn main() {
let t = Thing {
data: vec![1, 2, 3, 4],
lengths: vec![2, 2],
};
let groups = t.iter_grouped().collect::<Vec<_>>();
assert_eq!(groups, [3, 7])
}
Can we get a value of Pi that applies to all of the samples in the multi population objects? That would be useful.
One way would be to provide an iterator that groups the SiteCounts over populations, kinda like: