Four small, self-contained repetitions in the test toolchain.
1. is_uuid defined twice — toolchain/mfc/test/test.py:59 and :120, byte-identical:
def is_uuid(term):
return len(term) == 8 and all(c in "0123456789abcdefABCDEF" for c in term)
→ hoist to a single module-level _is_uuid.
2. Trace-truncation idiom repeated 5× — test.py:432, 446, 475, 584, 627, each:
trace_display = case.trace if len(case.trace) <= 50 else case.trace[:47] + "..."
→ extract _truncate(trace, width=50).
3. Twin error-classification if/elif ladders — test.py:636-644 and 648-657 walk the same exc_lower keyword set (tolerance/golden/mismatch, timeout, nan, failed to execute) for two outputs (a printed hint vs. the error_type string), and even recompute exc_lower = str(exc).lower() twice (636, 649). → extract _classify_error(exc) -> (error_type, hint) and call once.
4. get_dimensions — 3 near-identical axis branches — toolchain/mfc/test/cases.py:207-227 (z), 230-248 (y), 250-258 (x). Each sets per-patch patch_icpp(1..3)%{axis}_centroid = 0.05/0.45/0.9 and %length_{axis} = 0.1/0.7/0.2. → extract _axis_patches(axis) parameterized on the axis letter.
Why: textbook copy-paste dedup wins; #3 in particular keeps two ladders that must be edited in lockstep.
Behavior preservation: all four are mechanical (same constants, same control flow). No golden-file impact — test verdicts unchanged. Could ship as one small PR (split #4 from #1-3 if preferred).
Filed from a repo-wide code-cleanliness review; verified against master @ 40dde5e.
Code references
Four small, self-contained repetitions in the test toolchain.
1.
is_uuiddefined twice —toolchain/mfc/test/test.py:59and:120, byte-identical:→ hoist to a single module-level
_is_uuid.2. Trace-truncation idiom repeated 5× — test.py:432, 446, 475, 584, 627, each:
→ extract
_truncate(trace, width=50).3. Twin error-classification if/elif ladders — test.py:636-644 and 648-657 walk the same
exc_lowerkeyword set (tolerance/golden/mismatch,timeout,nan,failed to execute) for two outputs (a printed hint vs. theerror_typestring), and even recomputeexc_lower = str(exc).lower()twice (636, 649). → extract_classify_error(exc) -> (error_type, hint)and call once.4.
get_dimensions— 3 near-identical axis branches —toolchain/mfc/test/cases.py:207-227(z),230-248(y),250-258(x). Each sets per-patchpatch_icpp(1..3)%{axis}_centroid= 0.05/0.45/0.9 and%length_{axis}= 0.1/0.7/0.2. → extract_axis_patches(axis)parameterized on the axis letter.Why: textbook copy-paste dedup wins; #3 in particular keeps two ladders that must be edited in lockstep.
Behavior preservation: all four are mechanical (same constants, same control flow). No golden-file impact — test verdicts unchanged. Could ship as one small PR (split #4 from #1-3 if preferred).
Filed from a repo-wide code-cleanliness review; verified against
master@40dde5e.Code references
toolchain/mfc/test/test.py:59— is_uuid Error on READE.md #1toolchain/mfc/test/test.py:120— is_uuid Update m_global_parameters.f90 #2toolchain/mfc/test/test.py:636-657— twin error-classification ladderstoolchain/mfc/test/cases.py:207-258— three near-identical axis branches