register_real_images test working

This commit is contained in:
Wim Pomp committed 2026-07-29 16:27:21 +02:00
1 parent 0f315e66ca
commit e677e7400b
6 files changed
+124 -70

No files matched your search

+13 -7
View File
@@ -167,13 +167,19 @@ impl Sampling {
fn index(&self) -> Vec<Vec<f64>> {
match self {
Self::Fixed(index) => index.clone(),
Self::Random((n_samples, shape, _cached)) => rand::rng()
.random_iter::<f64>()
.take(n_samples * shape.len())
.chunks(shape.len())
.into_iter()
.map(|c| c.zip_eq(shape.iter()).map(|(i, s)| i * s - 0.5).collect())
.collect(),
Self::Random((n_samples, shape, cached)) => {
let mut cache = cached.borrow_mut();
if cache.is_empty() {
*cache = rand::rng()
.random_iter::<f64>()
.take(n_samples * shape.len())
.chunks(shape.len())
.into_iter()
.map(|c| c.zip_eq(shape.iter()).map(|(i, s)| i * s - 0.5).collect())
.collect();
}
cache.clone()
}
}
}
}