Skip to content

Commit 4d6f94f

Browse files
committed
fixup: Unconditionally run filter() during resampling
1 parent 0cdf93d commit 4d6f94f

File tree

1 file changed

+15
-24
lines changed

1 file changed

+15
-24
lines changed

src/sampling.rs

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -101,32 +101,23 @@ impl<F> Sampler<F> {
101101
.collect::<Vec<_>>();
102102
let transform = |zk| state.cov_transform() * zk;
103103

104-
match constraints {
104+
let ok_constraints = |yk: &DVector<f64>| match constraints {
105105
Some(constraints) => {
106-
let ok_constraints = |yk: &DVector<f64>| {
107-
let point = to_point(&yk, state.mean(), state.sigma());
108-
constraints.meets_constraints(&point)
109-
};
110-
111-
if parallel_update {
112-
z.into_par_iter()
113-
.map(transform)
114-
.filter(ok_constraints)
115-
.collect()
116-
} else {
117-
z.into_iter()
118-
.map(transform)
119-
.filter(ok_constraints)
120-
.collect()
121-
}
122-
}
123-
None => {
124-
if parallel_update {
125-
z.into_par_iter().map(transform).collect()
126-
} else {
127-
z.into_iter().map(transform).collect()
128-
}
106+
constraints.meets_constraints(&to_point(&yk, state.mean(), state.sigma()))
129107
}
108+
None => true,
109+
};
110+
111+
if parallel_update {
112+
z.into_par_iter()
113+
.map(transform)
114+
.filter(ok_constraints)
115+
.collect()
116+
} else {
117+
z.into_iter()
118+
.map(transform)
119+
.filter(ok_constraints)
120+
.collect()
130121
}
131122
};
132123

0 commit comments

Comments
 (0)