Skip to content

test toolchain dedup: duplicate is_uuid, repeated trace-truncation, twin error ladders, 3 axis branches #1510

@sbryngelson

Description

@sbryngelson

Four small, self-contained repetitions in the test toolchain.

1. is_uuid defined twicetoolchain/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 branchestoolchain/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

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