Skip to content

hypervolume: fix flaky floating point comparisons tests - #627

Open
jschueller wants to merge 1 commit into
esa:masterfrom
jschueller:issue516
Open

hypervolume: fix flaky floating point comparisons tests#627
jschueller wants to merge 1 commit into
esa:masterfrom
jschueller:issue516

Conversation

@jschueller

Copy link
Copy Markdown
Contributor

Replace equality checks (==) with BOOST_CHECK_SMALL using a 1e-12 tolerance for computed double values throughout the hypervolume test suite, fixing test failures on platforms with differing floating point precision.

Closes #516

@jschueller

Copy link
Copy Markdown
Contributor Author

/cc @darioizzo

@sylvesterkaczmarek sylvesterkaczmarek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertContribs() still compares hv.contributions(ref) to answers with exact vector equality in all three configurations. Those values are computed doubles, so the same platform-dependent rounding this PR is fixing can still fail here. Compare the contribution vectors elementwise with the same tolerance and add a regression that exercises this helper.

jschueller added a commit to jschueller/pagmo2 that referenced this pull request Sep 3, 2026
…d regression

Fix remaining exact vector equality checks for hv.contributions(ref)
identified in review of PR esa#627. Contributions are computed doubles
subject to platform-dependent rounding, so compare elementwise with
BOOST_CHECK_SMALL using 1e-12 tolerance in all three configurations
(copy true/false and set_copy_points false), consistent with the
exclusive checks. Also update remaining exact checks (hv2d, fake algo)
to use tolerance. Add hypervolume_contributions_tolerance_regression_test
that exercises assertContribs with fractional points and a small
perturbation that would fail with exact equality but passes with
tolerance.
Replace equality checks (==) with BOOST_CHECK_SMALL using a 1e-12
tolerance for computed double values throughout the hypervolume test
suite, fixing test failures on platforms with differing floating point
precision.

Closes esa#516
@jschueller

Copy link
Copy Markdown
Contributor Author

@sylvesterkaczmarek done

@sylvesterkaczmarek sylvesterkaczmarek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertContribs() now compares every contribution/exclusive value elementwise with tolerance in all copy/no-copy configurations instead of relying on exact vector equality. That addresses the platform-rounding failure I raised.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Comparing floating point numbers in tests : comparing difference instead of using ==

2 participants