Skip to content
Next Next commit
test(hungarian): pin the fd contract before changing the code
calculate_metrics derives fn and fp as len(list) minus tp, so a pair
that the assignment produced, and that the method returns inside
matched_pairs, is also counted as a false negative when its score sits
below match_threshold. The same pair is reported as matched and as
missing at the same time.

This commit adds the contract as a test, before any code changes. The
96 assertions that the current code violates carry xfail(strict=True),
so the suite fails if one of them starts passing while its marker is
still there. The 52 assertions that must keep the value they have today
carry no marker and pass now. That half is what makes the claim "only
one key changes value" checkable instead of asserted in prose.

The file also pins two things that nothing in the suite checked before.
One is that a caller can recompute precision, recall and f1 from the
counts in the same dict, since the method computes them from list
lengths instead, which is a different route. The other is that the old
fn value stays recoverable as fn plus fd, which is the migration note
for callers.

Suite moves from 1949 passed to 2001 passed and 96 xfailed. No
behaviour changes here.

Refs #231
  • Loading branch information
digalaviz committed Aug 27, 2026
commit 73b45d1a5ccd8eca1d85fa8f94af0b3b0389a9e2
Loading