Skip to content

fix(repo): tiny per-task values, arm means, delta_std and the mde note keep 2 significant digits, not 0.0 - #1259

Merged
antonwolfy merged 3 commits into
intel:mainfrom
antonwolfy:fix/tiny-value-rounding
Nov 26, 2026
Merged

antonwolfy merged 3 commits into
intel:mainfrom
antonwolfy:fix/tiny-value-rounding

Conversation

@antonwolfy

Copy link
Copy Markdown
Contributor

Summary

Three leftovers of #817 (fixed by #1227), where a tiny value prints as 0.0. #1227 gave the interval ends, delta.mean and mde 2 significant digits through round_off_zero; these sites were left. On main:

Issue Input Prints on main
#1224 repo compare, eight pairs with baseline 1e-12 and deltas 1e-12 to 6e-12 (sign_flip_summary) tasks[0] is {'task': 't0', 'baseline': 0.0, 'treatment': 0.0, 'delta': 0.0}, baseline_mean and treatment_mean are 0.0, beside delta.mean 3.4e-12 and p 0.007812
#1225 stats.paired_test([2e-12, 4e-12, 3e-12, 5e-12, 6e-12, 9e-12, 7e-12, 8e-12], [1e-12] * 8) delta_std 0.0 (the sd is about 2.4e-12), beside delta_mean 4.5e-12 and cohens_d 1.837
#1226 eight pairs with baseline 1e-12 and deltas [3e-12, -2e-12, 1e-12, -1e-12, 2e-12, -3e-12, 1.5e-12, -2.5e-12], mde 2.6e-12 the inconclusive note reads at about ±0.000 (8 tasks)

Options taken. #1224: _round goes through round_off_zero(value, 6), the way #1227 fixed mde, so one rounding serves every field of the row (mde used a second wrapper, _round_off_zero, which is now removed). #1225: round_off_zero(d_sd, 2), the helper round_mean is built on. #1226: of the two options (scientific notation or fmt_small), scientific notation: fmt_small(2.6e-12) is +0.0000000000026, a 13-decimal string that is unreadable in the middle of a sentence, and it is signed where the note prints ±. A non-zero mde below 0.0005 prints as .1e (2.6e-12: 2 significant digits, the precision the field carries); 0.0005 and above keeps .3f, and 1e6 and above .3e.

The same cause in the text tables of repo compare and the rule ledger (a tiny mean prints as 0.000) is tracked in #1258.

Closes #1224
Closes #1225
Closes #1226

Changes

  • dokimi/dokimi/repos/compare.py: _round keeps 2 significant digits where 6 places give 0 (a zero stays 0.0, never -0.0; a negative keeps its sign; a non-finite value stays None); it feeds baseline_mean, treatment_mean, the per-task baseline, treatment, delta and now mde, and _round_off_zero is removed. The changed: line of format_compare read the rounded task deltas to leave out noise: it now tests round(delta, 6), so it lists the same tasks as before (a delta of 4e-7 is still left out).
  • dokimi/dokimi/eval/stats.py: delta_std is round_off_zero(d_sd, 2). The import follows the layers (stats.py already imports from eval.sign_flip); a non-finite spread is still refused before this line.
  • dokimi/dokimi/repos/compare.py: _mde_text formats the mde of the inconclusive note.
  • Tests in dokimi/tests/test_repo_compare_reading.py and dokimi/tests/test_stats.py; the contract (dokimi/docs/repo-evaluation-contract.md) names the rounding of these fields and the note's formats. No existing test pinned 0.0 for a tiny value.
  • Three commits, one per issue, each with its test, doc line and changelog fragment (Fixed).

Risk

Output only, no schema change (same keys and types). Values of 5e-7 and above, a delta_std of 0.005 and above, and an mde of 0.0005 and above print as before. A stored repo compare JSON differs from a new one on every per-task value and arm mean below 5e-7; a stored arms result differs on a delta_std below 0.005; the note's text differs for a non-zero mde below 0.0005. A reader that treated 0.0 in those fields as "no change" now sees the small value. Open PRs that change the contract doc (#1252, #1243, #1201, #1199, #1194, #1192) edit other paragraphs than the two lines changed here, and #1199's change to compare.py is a warning message in _arm_warnings: a merge with any of them meets no conflict.

Testing

On Linux, at 75b35980581c3f2dfcfd97ac3b6bb3f044fd9f33 (on main 4abc47d):

  • make ci-local: 38 passed, 0 failed, 15 skipped (the Docker and network catalog smoke, the pinned Claude Code install, the jobs that do not run on a PR, the CLI-surface packaging, conda-forge, fuzz, the intel-ci matrix, the pip-audit report, semgrep). 29688 tests passed, 23 skipped; changed-line coverage 100%.
  • On main's code, test_repo_compare_reading.py fails 8 of its 34 tests (first: _round(-0.0) is -0.0; then tasks[0] is {'baseline': 0.0, 'delta': 0.0, 'treatment': 0.0} against 1e-12, and the note reads ±0.000 against ±2.6e-12) and test_stats.py fails the new test (assert (0.0 == 2.4e-12)); all of them pass here.
  • Mutants, each failing the test that pins it: _round back to 6 places, _round dropping the sign, round_off_zero keeping -0.0, the changed: line back to the EPS filter (that test passes on main too: it guards this change), the note's tiny branch removed, cut at <= 0.0005, cut at 0.005, .2e instead of .1e, delta_std back to round(d_sd, 2) and at 3 places.
  • Not run: the matrix legs on Python 3.11, 3.12 and 3.14.

Open questions

None.

Revert

A plain revert restores the old printing (0.0 for a tiny per-task value, arm mean or delta_std; ±0.000 in the note). Nothing is stored: a JSON written meanwhile keeps its small values, and the schemas are unchanged.

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)

… and arm means below 5e-7 (intel#1224)

compare._round kept 6 places, so every per-task baseline, treatment and delta and the arm means baseline_mean and treatment_mean below 5e-7 printed as 0.0 beside a non-zero delta, interval and p.

_round now goes through round_off_zero(value, 6): a value that 6 places would put at 0 keeps 2 significant digits and its sign, a zero stays 0.0, and a non-finite value is still None. Values of 5e-7 and above print as before. mde, the one field that used the separate _round_off_zero wrapper, now uses _round, and the wrapper is removed.

The "changed:" line of format_compare read the rounded task deltas to leave out noise, so a delta of 4e-7 would now have been listed as +0.00. It tests round(delta, 6) instead, which lists the same tasks as before.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
…el#1225)

_describe_deltas printed delta_std as round(d_sd, 2), so a spread under 0.005 was 0.0 beside a non-zero delta_mean, cohens_d and interval.

delta_std now goes through round_off_zero(d_sd, 2), the helper round_mean is built on: a spread that 2 places would put at 0 keeps 2 significant digits, an exact 0 stays 0.0, and a spread of 0.005 and above prints as before. A non-finite spread is still refused before this line.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
… scientific notation (intel#1226)

_inconclusive_note formatted mde as :.3f below 1e6, so a row whose mde field is 2.6e-12 read "about ±0.000" in the note.

A non-zero mde below 0.0005 now prints as :.1e (2 significant digits, the precision the field carries): "about ±2.6e-12". fmt_small was tried and gives a 13-decimal string for this value, unreadable in a sentence. An mde of 0.0005 and above keeps :.3f, and 1e6 and above :.3e. The text is pinned in test_repo_compare_reading.py.

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

exai-bot commented Nov 26, 2026 •

Copy link
Copy Markdown

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

CI at 75b3598: 25 passing, 4 skipped.

Test notes (2)
  • dokimi/dokimi/repos/compare.py:621: With "mde": _round(min_detectable(sd, len(deltas))) if sd > EPS * tie_scale(changed) and reachable else None, changed to "mde": _round(min_detectable(sd, len(deltas))) if sd >= EPS * tie_scale(changed) and reachable else None,, the tests still pass: dokimi/tests/test_repo_compare_reading.py, dokimi/tests/test_stats.py. A value exactly at the boundary gives the same result either way here, so no test says which one is meant.
  • dokimi/dokimi/repos/compare.py:691: With if 0 < mde < 0.0005: changed to if 0 <= mde < 0.0005:, the tests still pass: dokimi/tests/test_repo_compare_reading.py, dokimi/tests/test_stats.py. A value exactly at the boundary gives the same result either way here, so no test says which one is meant.
Review details
  • Commit reviewed: 75b3598 against merge base 4abc47d
  • Coverage: 8 files in 2 groups
  • Engine: OpenCodeReview v1.13.5-exai.4.8f73eada, us.openai.gpt-6.1-sol
  • Usage: 138k tokens (83k from cache), 12s
  • Tool calls: 12 (9 file_read, 3 code_search)
  • Tiny-value repository comparison and MDE documentation: 5 files
  • Tiny-delta standard deviation statistics: 3 files

@codecov-commenter

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.13%. Comparing base (4abc47d) to head (75b3598).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1259      +/-   ##
==========================================
- Coverage   96.14%   96.13%   -0.02%     
==========================================
  Files         498      498              
  Lines       66004    66005       +1     
  Branches    11461    11462       +1     
==========================================
- Hits        63460    63454       -6     
- Misses       1573     1576       +3     
- Partials      971      975       +4     
Files with missing lines Coverage Δ
dokimi/dokimi/eval/stats.py 97.90% <ø> (ø)
dokimi/dokimi/repos/compare.py 99.53% <100.00%> (+<0.01%) ⬆️

... and 6 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 75b3598)

  • 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

Checked the output rounding for per-task values, arm means, standard deviation and the minimum detectable effect. The sign-flip calculation still consumes the full-precision inputs. The statistics and repo comparison suites passed locally (425 tests), and CI is green.

@antonwolfy
antonwolfy merged commit 78f698e into intel:main Nov 26, 2026
29 checks passed
@antonwolfy
antonwolfy deleted the fix/tiny-value-rounding branch November 26, 2026 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants