Skip to content

Commit 592ace2

Browse files
committed
Fix spurious cholesky_det test failures
Before, the `cholesky_det` test would (infrequently) fail randomly due to small numerical errors. This commit adjusts the precision of the test and changes to an absolute (instead of relative) comparison to prevent those spurious failures.
1 parent a30d24f commit 592ace2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

tests/cholesky.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,19 @@ fn cholesky_inverse() {
101101
#[test]
102102
fn cholesky_det() {
103103
macro_rules! cholesky_det {
104-
($elem:ty, $rtol:expr) => {
104+
($elem:ty, $atol:expr) => {
105105
let a: Array2<$elem> = random_hpd(3);
106106
println!("a = \n{:?}", a);
107107
let det = a.eigvalsh(UPLO::Upper).unwrap().mapv(|elem| elem.ln()).scalar_sum().exp();
108-
assert_rclose!(a.detc().unwrap(), det, $rtol);
109-
assert_rclose!(a.factorizec(UPLO::Upper).unwrap().detc(), det, $rtol);
110-
assert_rclose!(a.factorizec(UPLO::Lower).unwrap().detc(), det, $rtol);
108+
assert_aclose!(a.detc().unwrap(), det, $atol);
109+
assert_aclose!(a.factorizec(UPLO::Upper).unwrap().detc(), det, $atol);
110+
assert_aclose!(a.factorizec(UPLO::Lower).unwrap().detc(), det, $atol);
111111
}
112112
}
113113
cholesky_det!(f64, 1e-9);
114-
cholesky_det!(f32, 1e-4);
114+
cholesky_det!(f32, 1e-3);
115115
cholesky_det!(c64, 1e-9);
116-
cholesky_det!(c32, 1e-4);
116+
cholesky_det!(c32, 1e-3);
117117
}
118118

119119
#[test]

0 commit comments

Comments
 (0)