Skip to content

Commit 3ef2d00

Browse files
committed
Revise assertion output
1 parent bbc69f6 commit 3ef2d00

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/assert.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,25 @@ use std::fmt::Debug;
66
use super::norm::*;
77
use super::types::*;
88

9-
/// check two values are close in terms of the relative torrence
9+
/// check two values are close in terms of the relative tolerance
1010
pub fn rclose<A: Scalar>(test: A, truth: A, rtol: A::Real) {
1111
let dev = (test - truth).abs() / truth.abs();
1212
if dev > rtol {
13+
eprintln!("==== Assetion Failed ====");
1314
eprintln!("Expected = {}", truth);
1415
eprintln!("Actual = {}", test);
15-
panic!("Too large deviation in relative torrence: {}", dev);
16+
panic!("Too large deviation in relative tolerance: {}", dev);
1617
}
1718
}
1819

19-
/// check two values are close in terms of the absolute torrence
20+
/// check two values are close in terms of the absolute tolerance
2021
pub fn aclose<A: Scalar>(test: A, truth: A, atol: A::Real) {
2122
let dev = (test - truth).abs();
2223
if dev > atol {
24+
eprintln!("==== Assetion Failed ====");
2325
eprintln!("Expected = {}", truth);
2426
eprintln!("Actual = {}", test);
25-
panic!("Too large deviation in absolute torrence: {}", dev);
27+
panic!("Too large deviation in absolute tolerance: {}", dev);
2628
}
2729
}
2830

@@ -38,9 +40,10 @@ where
3840
assert_eq!(test.dim(), truth.dim());
3941
let tol = (test - truth).norm_max();
4042
if tol > atol {
43+
eprintln!("==== Assetion Failed ====");
4144
eprintln!("Expected:\n{}", truth);
4245
eprintln!("Actual:\n{}", test);
43-
panic!("Too large deviation in maximum norm: {}", tol);
46+
panic!("Too large deviation in maximum norm: {} > {}", tol, atol);
4447
}
4548
}
4649

@@ -56,9 +59,10 @@ where
5659
assert_eq!(test.dim(), truth.dim());
5760
let tol = (test - truth).norm_l1() / truth.norm_l1();
5861
if tol > rtol {
62+
eprintln!("==== Assetion Failed ====");
5963
eprintln!("Expected:\n{}", truth);
6064
eprintln!("Actual:\n{}", test);
61-
panic!("Too large deviation in L1-norm: {}", tol);
65+
panic!("Too large deviation in L1-norm: {} > {}", tol, rtol);
6266
}
6367
}
6468

@@ -74,9 +78,10 @@ where
7478
assert_eq!(test.dim(), truth.dim());
7579
let tol = (test - truth).norm_l2() / truth.norm_l2();
7680
if tol > rtol {
81+
eprintln!("==== Assetion Failed ====");
7782
eprintln!("Expected:\n{}", truth);
7883
eprintln!("Actual:\n{}", test);
79-
panic!("Too large deviation in L2-norm: {}", tol);
84+
panic!("Too large deviation in L2-norm: {} > {} ", tol, rtol);
8085
}
8186
}
8287

0 commit comments

Comments
 (0)