From 6345393a638fd562a6b732ae1bdfe116d1d6cc57 Mon Sep 17 00:00:00 2001 From: Luochenghuang Date: Fri, 26 Jun 2026 11:19:55 -0700 Subject: [PATCH 1/2] test-prism: use combined rel+abs tolerance for line-segment test The line-segment unit test compared a prism against an equivalent block using a pure relative tolerance. When a random segment merely grazes the shared boundary, both intersection lengths are tiny and the relative test becomes hypersensitive to the prism's internal boundary tolerance (~1e-5), producing intermittent CI failures. Add an absolute floor so boundary- ambiguous samples are absorbed while genuine divergence is still caught. --- utils/test-prism.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/utils/test-prism.c b/utils/test-prism.c index 33f680a..6ece1c6 100644 --- a/utils/test-prism.c +++ b/utils/test-prism.c @@ -375,10 +375,16 @@ int test_line_segment_intersection(geometric_object the_block, geometric_object double sblock = intersect_line_segment_with_object(p, d, the_block, a, b); double sprism = intersect_line_segment_with_object(p, d, the_prism, a, b); - if (fabs(sblock - sprism) > 1.0e-6 * fmax(fabs(sblock), fabs(sprism))) num_failed++; + // Relative tolerance plus a floor proportional to the object's size, rather + // than a hard-coded length, so a segment that merely grazes the shared + // boundary (both intersection lengths ~0) isn't flagged as a spurious fail. + double diff = fabs(sblock - sprism); + double scale = fmax(fabs(sblock), fabs(sprism)); + double tol = 1.0e-6 * scale + 1.0e-5 * vector3_norm(size); + if (diff > tol) num_failed++; if (f) { - int success = fabs(sblock - sprism) <= 1.0e-6 * fmax(fabs(sblock), fabs(sprism)); + int success = diff <= tol; #pragma omp critical(test_prism_log) { fprintf(f, " %e %e %s\n", sblock, sprism, success ? "success" : "fail"); From ff6d3faa825e8054ee03dcc2180cea29884b0556 Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Fri, 26 Jun 2026 16:16:22 -0400 Subject: [PATCH 2/2] Apply suggestion from @stevengj --- utils/test-prism.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/utils/test-prism.c b/utils/test-prism.c index 6ece1c6..9624b2c 100644 --- a/utils/test-prism.c +++ b/utils/test-prism.c @@ -375,12 +375,8 @@ int test_line_segment_intersection(geometric_object the_block, geometric_object double sblock = intersect_line_segment_with_object(p, d, the_block, a, b); double sprism = intersect_line_segment_with_object(p, d, the_prism, a, b); - // Relative tolerance plus a floor proportional to the object's size, rather - // than a hard-coded length, so a segment that merely grazes the shared - // boundary (both intersection lengths ~0) isn't flagged as a spurious fail. double diff = fabs(sblock - sprism); - double scale = fmax(fabs(sblock), fabs(sprism)); - double tol = 1.0e-6 * scale + 1.0e-5 * vector3_norm(size); + double tol = 1.0e-5 * vector3_norm(size); if (diff > tol) num_failed++; if (f) {