Fix FP-tolerant metric tests on Python 3.8#117
Closed
kencan7749 wants to merge 1 commit into
Closed
Conversation
profile_correlation and pattern_correlation outputs differ from the pickled expected values by ~1 ULP (1.1e-16 to 2.2e-16) on the base environment (Python 3.8.5), causing np.array_equal to fail. The algorithm output is unchanged (allclose=True); only the final-bit rounding differs due to numpy/BLAS version drift since the fixtures were created. Replace 5 assertions in test_2d and test_2d_nan with np.testing.assert_allclose(rtol=1e-12, atol=0). The tolerance absorbs 1 ULP drift while still flagging any genuine implementation change. pairwise_identification results are bit-exact (rational counts / n-1) but use the same assertion form for consistency. No change to bdpy/evals/metrics.py or the pickle fixtures. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
Contributor
|
I think this is fixed in #112 now |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a failure in
tests/evals/test_metrics.pyon the base environment using Python 3.8.The failure was caused by exact equality checks on floating-point arrays. The pickled expected values differ from the current NumPy/BLAS output by only around 1 ULP (
1.1e-16–2.2e-16), andnp.allclosealready passes. This indicates floating-point rounding/version drift rather than an algorithmic change.Changes
Replaced 5
self.assertTrue(np.array_equal(...))checks withnp.testing.assert_allclose(...)Updated
test_2dandtest_2d_nanUsed strict tolerances:
rtol=1e-12, atol=0No implementation code or pickle fixtures were changed.