Repository navigation
Conversation
arm_summary.mean_in_range and stats._mean had the same body: the plain mean, or the exact statistics.mean when the sum of finite values leaves the float range. Keep the public mean_in_range in eval/stats.py; arm_summary and report/eval_report import it from there, and context/consistency keeps its stats_mean alias. Behaviour is unchanged (empty input still raises ZeroDivisionError, NaN and inf propagate as before). Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
There was a problem hiding this comment.
🟢 Approval recommended
No actionable issues were found in the reviewed changes.
No open issues 🎉
What changed in this PR
0 new findings; nothing to fix.
This refactor consolidates dokimi’s overflow-safe mean calculation in eval.stats.mean_in_range, preserving existing behavior.
Changes:
- Removes the duplicate helper and updates callers while preserving existing aliases.
- Updates numerical regression tests to use the public name.
- Adds a changelog fragment documenting the private-name migration.
| File | Description |
|---|---|
dokimi/tests/test_stats.py |
Updates overflow tests to call mean_in_range. |
dokimi/dokimi/report/eval_report.py |
Imports the helper directly from stats. |
dokimi/dokimi/eval/stats.py |
Defines the shared helper and updates internal calls. |
dokimi/dokimi/eval/arm_summary.py |
Replaces the duplicate implementation with an import. |
dokimi/dokimi/context/consistency.py |
Preserves stats_mean using the renamed helper. |
dokimi/changelog.d/20261205_050000_napetrov_r12-6-mean-in-range.md |
Documents consolidation and migration from _mean. |
Review effort: Balanced
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 7 selected item(s). CI at Review details
|
Mutation of changed linesAt 0aa5973: 28 caught · 2 missed Each row is a small deliberate break (a mutant) of a line this PR changes that every test reaching that line still passes. Add a test that fails on it or, if it cannot change behaviour, put
Not checked:
Warning only: a missed break does not fail the job. Updated on every push; the full report is in the ci run summary. |
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1642 +/- ##
==========================================
- Coverage 96.45% 96.44% -0.01%
==========================================
Files 575 575
Lines 75872 75866 -6
Branches 13076 13075 -1
==========================================
- Hits 73179 73166 -13
- Misses 1644 1646 +2
- Partials 1049 1054 +5
🚀 New features to boost your workflow:
|
antonwolfy
left a comment
There was a problem hiding this comment.
Review at f1a6fb7. The change itself reads right: the two bodies were identical, the merge into eval/stats.py is clean, and no caller or doc still names _mean. One possible issue for the author to check before merge, which I could not settle.
Possible issue: tests fail with this PR merged into main. I merged the PR into today's main (4deffc0) on a Linux review host and ran the tests. These failed there, and I did not see them fail on main alone:
tests/test_check_test_timing.py::test_the_repo_tree_holds_its_own_baselinetests/test_novelty_routing_all_vs_all.py::test_an_unreadable_queries_file_is_a_message_not_a_traceback[missing]tests/test_repo_runner.py::test_run_refuses_a_budget_that_caps_nothing[inf]tests/test_repo_typecheck_grader.py::test_the_subjects_mypy_ini_cannot_suppress_a_listed_file- two more with a 60s timeout or a gc-callback warning
Most of these look like load on a small host and unrelated to a rename. The first one may be real: removing the duplicate _mean can shrink a recorded baseline, and the repo asks for python scripts/check_growth.py --update after a shrink. Please run these tests on the merge and lower the baseline if it is that.
What I ran, on a Linux review host at f1a6fb7:
make ci-local: 36 passed, 2 failed.Run testshad 35,859 passed and 4 failed (timeouts and gc-callback warnings intest_cli_model_ref.pyandtest_fuzz_targets.py, which pass when rerun alone).pip-auditfailed on a read timeout reaching pypi.org, not on an advisory.- Imported
arm_summarythenstatsin a fresh interpreter: no import cycle, andarm_summary.mean_in_range is stats.mean_in_range.
Checked, no issues
- Callers: a grep finds no remaining
stats._meanorarm_summary.mean_in_rangeuse. - Behaviour: the moved body is the old
stats._meanwith the parameter renamed. - Process: both commits carry
Signed-off-by, andskip-changelogis on the PR.
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
|
vchamarthi
left a comment
There was a problem hiding this comment.
@napetrov, could you fix the problem I found (in the line comments)? Then push and I'll take another look.
Optional, non-blocking (1)
dokimi/dokimi/eval/stats.py:188: With an infinity invalues, an overflowing resample givesinfateval/stats.py:188, and using the exact mean there still passestests/test_stats.py.
What I checked on 85fbe48:
- When I changed the code on purpose, the tests still passed for 1 of 6 changes, and no test pins this one down yet (non-blocking):
dokimi/dokimi/eval/stats.py:531(it returns None). - The 92 changed tests pass, and pass on main too.
- The full test suite passes with main merged in (37,836 tests), apart from failures main has too.
- It merges cleanly onto main.
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g87AMogM Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRR_kwDOVBg7g88AAAABcfGTxQ.a Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
|
|
The ordinary-mean regression test now catches the |
Summary
mean_in_range(arm_summary) and_mean(stats) carried the same body: the plain mean, orstatistics.meanwhen the sum of finite values leaves the float range. One publicmean_in_rangenow lives ineval/stats.py;arm_summaryandreport/eval_reportimport it from there;context/consistencykeeps itsstats_meanalias.Evidence
stats.mean_in_range,arm_summaryname and the consistency alias: 0 diffs. Empty still raisesZeroDivisionError; NaN and inf propagate; overflow falls back tostatistics.mean.pytest tests/: 35857 passed, 4 failed. One failure needs themcppackage, absent in the local venv. Three CLI timeouts under box load pass when rerun alone.Merge Danger
stats._meanis gone; onlytests/test_stats.pyused it, now updated. No public name is removed (arm_summary.mean_in_rangestill resolves via the import).arm_summarynow importsstats.statsno longer importsarm_summary. Import cycle check passes.skip-changelog. A second commit adds a short fragment only because the local pre-push gate cannot see labels; drop it if the label is enough for CI.🤖 Generated with Claude Code