Skip to content

Commit 552a675

Browse files
committed
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.
1 parent 66458f1 commit 552a675

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

utils/test-prism.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,10 +375,17 @@ int test_line_segment_intersection(geometric_object the_block, geometric_object
375375

376376
double sblock = intersect_line_segment_with_object(p, d, the_block, a, b);
377377
double sprism = intersect_line_segment_with_object(p, d, the_prism, a, b);
378-
if (fabs(sblock - sprism) > 1.0e-6 * fmax(fabs(sblock), fabs(sprism))) num_failed++;
378+
// Combined relative + absolute tolerance. When a segment merely grazes the
379+
// boundary shared by the block and the equivalent prism, both intersection
380+
// lengths are tiny and a pure relative test is hypersensitive to the
381+
// prism's internal boundary tolerance (~1e-5). The absolute floor absorbs
382+
// those boundary-ambiguous samples while still catching real divergence.
383+
double diff = fabs(sblock - sprism);
384+
double scale = fmax(fabs(sblock), fabs(sprism));
385+
if (diff > 1.0e-6 * scale + 1.0e-5) num_failed++;
379386

380387
if (f) {
381-
int success = fabs(sblock - sprism) <= 1.0e-6 * fmax(fabs(sblock), fabs(sprism));
388+
int success = diff <= 1.0e-6 * scale + 1.0e-5;
382389
#pragma omp critical(test_prism_log)
383390
{
384391
fprintf(f, " %e %e %s\n", sblock, sprism, success ? "success" : "fail");

0 commit comments

Comments
 (0)