A grab-bag of small cleanups across five tooling files. Four are clean good-first-issue dedups; (b) is a larger refactor that should be scoped separately.
(a) fp_stability.py — 13-key result dict duplicated. The identical default-result dict (name, passed, max_dev, threshold, float_proxy, vprec, dd_sym_syms, dd_line_locs, cancellation_locs, mca_dev, mca_sigbits, float_max_locs) appears at toolchain/mfc/fp_stability.py:970-983 and again at :1322-1335, differing only in where name/threshold come from. → extract _empty_result(name, threshold) -> dict.
(c) gen_case_constraints_docs.py — three identical getters + duplicated emoji map. get_model_name (133), get_riemann_solver_name (140), get_time_stepper_name (147) have byte-identical bodies modulo the schema key string. Also the level→emoji map {"Beginner": "🟢", "Intermediate": "🟡", "Advanced": "🔴"} is duplicated at lines 159 and 267. → collapse to one _named(param, value) helper and hoist the emoji map to a module constant.
(d) sched.py — HEADLESS_THRESHOLDS table is not used for its numbers. The table at sched.py:21-25 stores (2*60, msg), (10*60, msg), (30*60, msg), but the consumer (143/148/153) re-hardcodes elapsed >= 2 * 60 etc. and only indexes the table for the message text. → drive the comparisons from HEADLESS_THRESHOLDS[i][0] so the seconds live in one place.
(e) user_guide.py — ORG_COLORS is entirely redundant. All 8 entries (lines 56-65) map to "yellow", the lookup uses ORG_COLORS.get(org, "yellow") (line 145), and "CSCS" (in ORG_ORDER) is missing from the dict. Net effect: every org renders yellow regardless. The missing CSCS key is harmless (falls back to "yellow"), so this is dead config, not a bug. → delete ORG_COLORS and inline "yellow", or give orgs distinct colors if intended.
(b) bench.py — bench() is a ~140-line god-function — REAL but larger. toolchain/mfc/bench.py:26-168 nests for case → try → for attempt → try → with open(...) → multiple ifs, reaching 6+ indent levels. The per-case retry body is the natural extraction into _bench_one_case(case, targets, ...) -> summary | None. This is a structural refactor, not a trivial dedup.
Scope recommendation: file (a), (c), (d), (e) together as one "tooling dedup" good-first-issue PR (all mechanical, behavior-preserving). File (b) separately as its own refactor (not good-first) with manual ./mfc.sh bench verification.
Filed from a repo-wide code-cleanliness review; verified against master @ 40dde5e.
Code references
A grab-bag of small cleanups across five tooling files. Four are clean good-first-issue dedups; (b) is a larger refactor that should be scoped separately.
(a) fp_stability.py — 13-key result dict duplicated. The identical default-result dict (
name, passed, max_dev, threshold, float_proxy, vprec, dd_sym_syms, dd_line_locs, cancellation_locs, mca_dev, mca_sigbits, float_max_locs) appears attoolchain/mfc/fp_stability.py:970-983and again at:1322-1335, differing only in wherename/thresholdcome from. → extract_empty_result(name, threshold) -> dict.(c) gen_case_constraints_docs.py — three identical getters + duplicated emoji map.
get_model_name(133),get_riemann_solver_name(140),get_time_stepper_name(147) have byte-identical bodies modulo the schema key string. Also the level→emoji map{"Beginner": "🟢", "Intermediate": "🟡", "Advanced": "🔴"}is duplicated at lines 159 and 267. → collapse to one_named(param, value)helper and hoist the emoji map to a module constant.(d) sched.py —
HEADLESS_THRESHOLDStable is not used for its numbers. The table atsched.py:21-25stores(2*60, msg), (10*60, msg), (30*60, msg), but the consumer (143/148/153) re-hardcodeselapsed >= 2 * 60etc. and only indexes the table for the message text. → drive the comparisons fromHEADLESS_THRESHOLDS[i][0]so the seconds live in one place.(e) user_guide.py —
ORG_COLORSis entirely redundant. All 8 entries (lines 56-65) map to"yellow", the lookup usesORG_COLORS.get(org, "yellow")(line 145), and"CSCS"(inORG_ORDER) is missing from the dict. Net effect: every org renders yellow regardless. The missing CSCS key is harmless (falls back to "yellow"), so this is dead config, not a bug. → deleteORG_COLORSand inline"yellow", or give orgs distinct colors if intended.(b) bench.py —
bench()is a ~140-line god-function — REAL but larger.toolchain/mfc/bench.py:26-168nestsfor case→try→for attempt→try→with open(...)→ multipleifs, reaching 6+ indent levels. The per-case retry body is the natural extraction into_bench_one_case(case, targets, ...) -> summary | None. This is a structural refactor, not a trivial dedup.Scope recommendation: file (a), (c), (d), (e) together as one "tooling dedup" good-first-issue PR (all mechanical, behavior-preserving). File (b) separately as its own refactor (not good-first) with manual
./mfc.sh benchverification.Filed from a repo-wide code-cleanliness review; verified against
master@40dde5e.Code references
toolchain/mfc/fp_stability.py:970-983— empty result dict Error on READE.md #1toolchain/mfc/fp_stability.py:1322-1335— empty result dict Update m_global_parameters.f90 #2toolchain/mfc/gen_case_constraints_docs.py:133-151— 3 identical getterstoolchain/mfc/sched.py:21-25— HEADLESS_THRESHOLDS tabletoolchain/mfc/user_guide.py:56-65— all-yellow ORG_COLORStoolchain/mfc/bench.py:26-168— bench() god-function