Skip to content

misc tooling dedup: twin result dict, identical doc getters, hardcoded sched thresholds, redundant ORG_COLORS #1512

@sbryngelson

Description

@sbryngelson

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 casetryfor attempttrywith 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions