Skip to content

Extract a shared drift/all-close helper in compiler_while_test.exs #173

Description

@ausimian

Surfaced by the CM14 fused-while review (follow-up to #163).

The max-abs-difference "drift" computation is copy-pasted across two of the new fused-while tests:

# test/emily/compiler_while_test.exs:110-111  and  :125-126
Enum.zip(Nx.to_flat_list(fused), Nx.to_flat_list(eval))
|> Enum.reduce(0.0, fn {a, b}, acc -> max(acc, abs(a - b)) end)

with only the tolerance varying. Extract a single helper — e.g. drift(a, b) returning the max abs difference, or assert_all_close(a, b, tol) — so the tests read assert drift(fused, eval) <= 1.0e-5. It's also a near-duplicate of the bit-identical check in equiv/2 (test/emily/compiler_while_test.exs:31), which could share the same helper.

Severity: trivial (test cleanup).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions