Repository navigation
Accept one-cent differences in --check-results and warn on inexact matches - #66
Merged
Merged
Conversation
…tches Losses are written to 2 decimal places, so a loss on a half-cent boundary can round either way when the float summation order changes, e.g. between the CPU types of CI runners. For small losses a one-cent flip exceeds the 1e-4 relative tolerance (22.88 vs 22.87 is 4.4e-4), so no single baseline passes on every runner. A numeric value now passes if it is within the relative tolerance or within one cent. Files that pass within tolerance but are not byte-identical are no longer passed silently: they are reported in a ResultsWithinToleranceWarning, with the number of differing values and the largest difference per column. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve import conflict in tests/conftest.py: keep pytest_plugins from #31 and the numpy import from this branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
This PR has no cross-repo dependency: it changes no baselines and passes against OasisLMF |
sambles
approved these changes
Nov 24, 2026
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.
For OasisLMF/OasisLMF#2244
Problem
--check-resultscompares numeric values with a 1e-4 relative tolerance. Losses are written to 2 decimal places, so a loss that sits on a half-cent boundary can round either way when the float summation order changes. For small losses, that one-cent flip exceeds the tolerance.OasisLMF#2244 hits this in
PiWindPostcode/test_3. CI runners produce two differentil_S1_selt.csvoutputs for the same code, most likely because of different CPU types:The true loss is about 22.875. A and B fail against each other, so no single baseline can pass on every runner: rebaselining would only change which runners fail.
Change
_NUMERIC_ABS_TOL, plus a 1e-9 epsilon because22.88 - 22.87 > 0.01in float64). The byte comparison and the relative tolerance are unchanged. The cent only widens the check for values below about 100, where 1e-4 relative is less than the printed precision.ResultsWithinToleranceWarning, which appears in pytest's warnings summary. It lists each file with the number of differing values and the largest difference per column, e.g.No expected results change, so this PR does not need to merge in step with OasisLMF#2244.
Testing
Ran
apply_results_flagsfrom this branch against thePiWindPostcode/test_3outputs from the OasisLMF#2244 CI artifacts, with the currentexpected_results:End to end: the OasisLMF model-test workflow on OasisLMF#2244 against this branch (run 44325924556) passes on all five Python versions (22 passed, 5 skipped). It raises the warning for 19 of the 22 tests: #2244 renumbers items, so most outputs move within tolerance. Rebaselining after #2244 merges would make them byte-identical again on at least one runner type.
🤖 Generated with Claude Code