Skip to content

fix(eval): sign-flip interval ends, mean and mde of tiny deltas keep 2 significant digits - #1227

Merged
antonwolfy merged 2 commits into
intel:mainfrom
antonwolfy:fix/tiny-interval-ends
Nov 25, 2026
Merged

antonwolfy merged 2 commits into
intel:mainfrom
antonwolfy:fix/tiny-interval-ends

Conversation

@antonwolfy

@antonwolfy antonwolfy commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A sign-flip row whose deltas are below 5e-5 prints its interval ends and its mean as 0.0001, and repo compare prints its mde as 0.0, so the printed interval is a point that does not hold the true mean. On main:

input printed on main exact
paired_test([2e-12, 4e-12, 3e-12, 5e-12, 6e-12, 9e-12, 7e-12, 8e-12], [1e-12] * 8) (p 0.0078) delta_mean 0.0001, ci_lo 0.0001, ci_hi 0.0001 4.5e-12, 2.33e-12, 6.67e-12
repo compare row, baseline 1e-12, deltas 1e-12 to 6e-12 (p 0.007812) delta {'mean': 0.0001, 'lo': 0.0001, 'hi': 0.0001}, mde 0.0
baseline 0.0, deltas [4e-5] * 6 delta mean, lo and hi 0.0001
baseline 0.0, deltas [4e-5] * 5 + [-1e-5] delta mean 0.0, lo -0.0001, hi 0.0001

The cause is sign_flip._rounded, which rounds an end to 4 places and moves one that lands on 0 to ±1e-4; delta.mean of repo compare is held inside those ends, and compare._round keeps 6 places for mde.

The issue offers two fixes; this takes the first: a value that 4 places (6 for mde) would put at 0 keeps 2 significant digits instead, as round_mean already does for the arms mean. It keeps the field a plain JSON float, where printing the unrounded value in scientific notation would change the form of the field for every reader, and it keeps the end on its side of 0 (2 significant digits of a non-zero finite float are never 0).

Closes #817

Three places of the same class are not fixed here: the per-task values and arm means of repo compare below 5e-7 print as 0.0 (#1224), delta_std of the arms track below 0.005 prints as 0.0 (#1225), and the inconclusive note prints a tiny mde as ±0.000 (#1226).

Changes

  • dokimi/dokimi/eval/sign_flip.py: new round_off_zero(value, places) (the value at places, or at 2 significant digits where that would be 0.0, no -0.0); _rounded uses it, so ci_lo/ci_hi of the arms track (sign_flip_row) and the lo/hi of repo compare get the new rule. The within and sign_flip_interval docstrings say it.
  • dokimi/dokimi/repos/compare.py: sign_flip_summary rounds delta.mean (when not exact) through the same helper, still held inside the ends by within, and mde through _round_off_zero (6 places, or 2 significant digits where that would be 0). _round itself is unchanged.
  • dokimi/dokimi/eval/stats.py: _describe_deltas docstring.
  • dokimi/docs/repo-evaluation-contract.md: the rule for the ends, delta.mean and mde.
  • Tests: tests/test_repo_compare_interval.py and tests/test_arms_sign_flip.py pin the issue's two repros, a negative tiny end, an end between 5e-5 and 1e-4 and above (4 places, the same as on the merge base), and a 6-place mde. Existing tests that pinned the old values are changed: test_rounding_keeps_an_end_on_its_side_of_zero now asserts _rounded(±3e-5) == ±3e-5; test_a_tiny_mean_stays_inside_its_interval_kept_off_zero asserts (±4e-5,) * 3 for six deltas of ±4e-5, and lo, mean, hi (-1e-5, 3.2e-5, 4e-5) for [4e-5] * 5 + [-1e-5] (the mean was 0.0 between ends of ±0.0001); test_a_mean_rounded_to_zero_is_zero_not_negative_zero asserts the mean of [-1e-5, 0, 0] is -3.3e-6 (it was 0.0) and keeps its -0.0 check on [1e-5, -1e-5, 0.0], whose mean is 0.0.
  • Changelog fragment (Fixed): says that exact keeps the unrounded arms record and the full-precision mean and p, while sign_flip_summary(..., exact=True) still rounds the interval ends and mde, so those change for tiny deltas too.

Risk

Rows whose end, delta.mean or mde is below 5e-5 (below 5e-7 for mde) print other numbers than before: a stored repo compare JSON or arms result read side by side with a new one differs on those rows. Every value whose 4-place (6-place for mde) rounding is not 0 prints with the same 4 places (6 for mde) as on the merge base, exact output keeps the unrounded arms record and the full-precision mean and p, an open end stays null, and interval_p_disagree and includes_zero verdicts do not change. No schema changes: the fields stay floats.

Open PRs on the same files change other parts of them: #1199 changes _arm_warnings in compare.py, and it and #1138, #1155, #1192, #1195, #1201 and #1223 edit other sections of repo-evaluation-contract.md, none at the delta.mean paragraph this PR rewrites, so a merge with any of them meets no conflict.

Testing

On a Linux review host, at e2fd9442 (on main 602de14):

  • make ci-local: 38 passed, 0 failed, 15 skipped (docker, conda-forge, semgrep, fuzz, the jobs that do not run on a PR, the Claude Code pin, the other Python versions). 28384 tests passed, 23 skipped; changed-line coverage 100%; the mutation run of the changed lines has no survivor.
  • The two repros above fail on main's code (test_repo_compare_interval.py: 6 failed, 14 passed; test_arms_sign_flip.py: 2 failed, 28 passed) and pass here.
  • Mutants: each new assertion block fails on the change it pins: the old _rounded, the old delta.mean rounding, mde through _round, no + 0.0, 2 significant digits everywhere, and 7 places for mde.
  • Not run: the other Python versions.

Open questions

None. The issue calls the choice between its two fixes a decision for the maintainers; this takes the first by the precedent of round_mean.

Revert

A plain revert restores the ±0.0001 and 0.0 printing of tiny rows. Nothing is stored.

Checklist

  • Tests added/updated and pytest passes
  • ruff, mypy, and schema checks pass
  • Docs updated (or N/A) — see the docs-drift checklist in CONTRIBUTING.md
  • Self-reviewed per "Before opening a PR" in AGENTS.md
  • Each new raise/exit and test names the doc, contract or issue it traces to
  • No ad-hoc run artifacts committed
  • New files carry the SPDX license header (or are exempt in .github/.licenserc.yaml)

…2 significant digits (intel#817)

A sign-flip row whose deltas are below 5e-5 printed both interval ends and `delta.mean` as 0.0001 (`_rounded` rounded to 4 places and moved an end that landed on 0 to ±0.0001), so the interval was a point that did not hold the true mean, and `mde` was 0.0 because `compare._round` keeps 6 places. Deltas of 2e-12 to 9e-12 printed `[0.0001, 0.0001]` around a mean of 0.0001 for a row whose p is 0.0078.

An end, `delta.mean` of `repo compare` (still held inside the ends by `within`) and `mde` that their 4 places (6 for `mde`) would put at 0 now keep 2 significant digits, as `round_mean` does for the arms mean, through one shared helper `round_off_zero`. A non-zero end keeps its side of 0, no `-0.0` is printed, and every value whose rounding is not 0 prints as before; `exact` output and the `includes_zero` verdicts are unchanged. The tests that pinned ±0.0001 and a mean of 0.0 now pin the 2-digit values, and the docs and docstrings state the new rule.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@exai-bot

exai-bot commented Nov 25, 2026 •

Copy link
Copy Markdown

✅ OpenCodeReview: Review complete: 0 finding(s) across 7 selected item(s).

CI at e2fd944: 25 passing, 4 skipped.

Review details
  • Commit reviewed: e2fd944 against merge base 602de14
  • Coverage: 7 files in 1 groups
  • Engine: OpenCodeReview v1.13.5-exai.4.8f73eada, us.openai.gpt-6.1-sol
  • Usage: 84k tokens (48k from cache), 16s
  • Tool calls: 9 (8 file_read, 1 local_check_results)
  • Sign-flip interval bounds and repository comparison contract: 7 files

@codecov-commenter

codecov-commenter commented Nov 25, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.07%. Comparing base (602de14) to head (e2fd944).
⚠️ Report is 13 commits behind head on main.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1227      +/-   ##
==========================================
- Coverage   96.07%   96.07%   -0.01%     
==========================================
  Files         496      495       -1     
  Lines       65209    65353     +144     
  Branches    11317    11327      +10     
==========================================
+ Hits        62652    62789     +137     
- Misses       1583     1584       +1     
- Partials      974      980       +6     
Files with missing lines Coverage Δ
dokimi/dokimi/eval/sign_flip.py 98.97% <100.00%> (-0.01%) ⬇️
dokimi/dokimi/eval/stats.py 97.90% <ø> (ø)
dokimi/dokimi/repos/compare.py 99.53% <100.00%> (+<0.01%) ⬆️

... and 40 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@napetrov napetrov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Change class: CONTRACT (head 008b2f2)

  • Contract: changed (count signal only, no file:line)
  • Responsibility: none
  • Dependency: none
  • Review depth: check the changed surface: callers, docs, tests pin new behaviour
  • Coverage gaps: none

The tiny example from #817 now returns a mean of 4.5e-12 inside the interval [2.3e-12, 6.7e-12]. The 50 focused comparison and sign-flip tests passed, and CI is green. One release-note clarification is inline.

…gment

Settles the review note on the fragment: `exact` keeps the unrounded arms record and the full-precision mean and p, but `sign_flip_summary(..., exact=True)` still rounds the interval ends and `mde`, so those change for tiny deltas as well.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@antonwolfy

Copy link
Copy Markdown
Contributor Author

(approved) ### Change class: CONTRACT (head 008b2f2)

@napetrov (#1227 (review)): Approval with a recap of its checks; its one inline point is thread 4699605618, answered above.

@antonwolfy
antonwolfy merged commit 78ad03b into intel:main Nov 25, 2026
29 checks passed
@antonwolfy
antonwolfy deleted the fix/tiny-interval-ends branch November 25, 2026 21:08
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.

sign-flip rows round the mean and the interval of deltas below 5e-5 to 0.0001

4 participants