FAILURE MAP
← Case archive

FA-97726 / Knitting and sewing pattern grading / Open access

Post-wash swatch gauge: even row rounding · case 01

The body ends on a right-side row.

Verified by executionVariant 1 · 8 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

Rows are rounded to any integer instead of the nearest even count.

THE FAILURE

Rows are rounded to any integer instead of the nearest even count.

Unsuccessful approach: Always rounding up to even adds rows.

Case contract

A swatch of sts x rows measured before and after washing. Use post-wash dimensions: cast on = half-up target_w*sts/w_post; rows = target_h*rows/h_post rounded to the nearest even number (ties up); width change % = (w_post/w_pre - 1)*100 half-up to 0.1. Return [cast_on, rows, width_change].

Why this case matters

Knitters block swatches because many fibres grow or shrink after washing.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(sts, rows, w_pre, w_post, h_pre, h_post, target_w, target_h):
    wpo = Fraction(w_post)
    hpo = Fraction(h_post)
    cast = math.floor(target_w * sts / wpo + Fraction(1, 2))
    rr = target_h * rows / hpo
    row_count = math.floor(rr + Fraction(1, 2))
    change = (wpo / Fraction(w_pre) - 1) * 100
    return [cast, row_count, math.floor(change * 10 + Fraction(1, 2)) / 10]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['no change', [20, 28, '10', '10', '10', '10', 50, 45], [100, 126, 0.0]],
  ['growth', [22, 30, '10', '11', '10', '10.4', 50, 60], [100, 174, 10.0]],
  ['shrink', [24, 32, '10.5', '9.5', '10.2', '9', 40, 30], [101, 106, -9.5]],
  ['regression: even row rounding', [20, 30, '10', '10.5', '10.2', '10.4', 50, 30], [95, 86, 5.0]],
  ['repair check: even row rounding', [20, 40, '10', '11', '10', '9.5', 50, 60], [91, 252, 10.0]],
  ['generated control 1', [30, 28, '10', '10.8', '10.2', '10', 40, 30], [111, 84, 8.0]],
  ['generated control 2', [20, 28, '10', '11', '10', '9', 40, 45], [73, 140, 10.0]],
  ['generated control 3', [30, 28, '10.5', '10.5', '10', '10', 40, 60], [114, 168, 0.0]]],
 [['growth', [22, 30, '10', '11', '10', '10.4', 50, 60], [100, 174, 10.0]],
  ['shrink', [24, 32, '10.5', '9.5', '10.2', '9', 40, 30], [101, 106, -9.5]],
  ['no change', [20, 28, '10', '10', '10', '10', 50, 45], [100, 126, 0.0]],
  ['regression: even row rounding', [30, 28, '10', '10.5', '10', '10.4', 55, 45], [157, 122, 5.0]],
  ['repair check: even row rounding', [30, 28, '10.5', '10.8', '10', '9.5', 50, 45], [139, 132, 2.9]],
  ['generated control 1', [20, 30, '10', '11', '10.2', '10.4', 55, 45], [100, 130, 10.0]],
  ['generated control 2', [22, 40, '10.5', '11', '10.2', '9', 50, 60], [100, 266, 4.8]],
  ['generated control 3', [20, 30, '10', '10.8', '10.2', '10', 55, 45], [102, 136, 8.0]]],
 [['shrink', [24, 32, '10.5', '9.5', '10.2', '9', 40, 30], [101, 106, -9.5]],
  ['no change', [20, 28, '10', '10', '10', '10', 50, 45], [100, 126, 0.0]],
  ['growth', [22, 30, '10', '11', '10', '10.4', 50, 60], [100, 174, 10.0]],
  ['regression: even row rounding', [22, 32, '10', '10.5', '10', '9.5', 50, 30], [105, 102, 5.0]],
  ['repair check: even row rounding', [22, 30, '10', '10', '10', '9.5', 40, 30], [88, 94, 0.0]],
  ['generated control 1', [20, 40, '10.5', '10.8', '10', '10', 40, 60], [74, 240, 2.9]],
  ['generated control 2', [20, 32, '10', '10.8', '10.2', '9', 55, 45], [102, 160, 8.0]],
  ['generated control 3', [22, 28, '10', '9.5', '10', '10', 40, 60], [93, 168, -5.0]]],
 [['no change', [20, 28, '10', '10', '10', '10', 50, 45], [100, 126, 0.0]],
  ['growth', [22, 30, '10', '11', '10', '10.4', 50, 60], [100, 174, 10.0]],
  ['shrink', [24, 32, '10.5', '9.5', '10.2', '9', 40, 30], [101, 106, -9.5]],
  ['regression: even row rounding', [30, 30, '10', '11', '10', '9.5', 40, 60], [109, 190, 10.0]],
  ['repair check: even row rounding', [22, 32, '10', '10.8', '10', '9.5', 40, 60], [81, 202, 8.0]],
  ['generated control 1', [24, 30, '10', '10', '10', '9', 55, 60], [132, 200, 0.0]],
  ['generated control 2', [24, 40, '10.5', '10.8', '10.2', '10', 50, 30], [111, 120, 2.9]],
  ['generated control 3', [30, 30, '10', '10.5', '10.2', '9', 40, 60], [114, 200, 5.0]]],
 [['growth', [22, 30, '10', '11', '10', '10.4', 50, 60], [100, 174, 10.0]],
  ['shrink', [24, 32, '10.5', '9.5', '10.2', '9', 40, 30], [101, 106, -9.5]],
  ['no change', [20, 28, '10', '10', '10', '10', 50, 45], [100, 126, 0.0]],
  ['regression: even row rounding', [22, 30, '10', '10.8', '10', '10', 40, 45], [81, 136, 8.0]],
  ['repair check: even row rounding', [20, 40, '10.5', '10.5', '10.2', '9.5', 50, 30], [95, 126, 0.0]],
  ['generated control 1', [20, 30, '10', '11', '10', '10', 50, 60], [91, 180, 10.0]],
  ['generated control 2', [24, 30, '10', '10.8', '10', '9', 40, 45], [89, 150, 8.0]],
  ['generated control 3', [24, 30, '10.5', '10.5', '10.2', '10.4', 40, 60], [91, 174, 0.0]]]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
no change[100, 126, 0.0][100, 126, 0.0]Passed
growth[100, 173, 10.0][100, 174, 10.0]Failed
shrink[101, 107, -9.5][101, 106, -9.5]Failed
regression: even row rounding[95, 87, 5.0][95, 86, 5.0]Failed
repair check: even row rounding[91, 253, 10.0][91, 252, 10.0]Failed
generated control 1[111, 84, 8.0][111, 84, 8.0]Passed
generated control 2[73, 140, 10.0][73, 140, 10.0]Passed
generated control 3[114, 168, 0.0][114, 168, 0.0]Passed

SHA-256 / f7e36c84dd511a04ee423b3b7441fad14bf7218de61218a285489d20bd0c18d2

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(sts, rows, w_pre, w_post, h_pre, h_post, target_w, target_h):
    wpo = Fraction(w_post)
    hpo = Fraction(h_post)
    cast = math.floor(target_w * sts / wpo + Fraction(1, 2))
    rr = target_h * rows / hpo
    row_count = 2 * math.ceil(rr / 2)
    change = (wpo / Fraction(w_pre) - 1) * 100
    return [cast, row_count, math.floor(change * 10 + Fraction(1, 2)) / 10]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['no change', [20, 28, '10', '10', '10', '10', 50, 45], [100, 126, 0.0]],
  ['growth', [22, 30, '10', '11', '10', '10.4', 50, 60], [100, 174, 10.0]],
  ['shrink', [24, 32, '10.5', '9.5', '10.2', '9', 40, 30], [101, 106, -9.5]],
  ['regression: even row rounding', [20, 30, '10', '10.5', '10.2', '10.4', 50, 30], [95, 86, 5.0]],
  ['repair check: even row rounding', [20, 40, '10', '11', '10', '9.5', 50, 60], [91, 252, 10.0]],
  ['generated control 1', [30, 28, '10', '10.8', '10.2', '10', 40, 30], [111, 84, 8.0]],
  ['generated control 2', [20, 28, '10', '11', '10', '9', 40, 45], [73, 140, 10.0]],
  ['generated control 3', [30, 28, '10.5', '10.5', '10', '10', 40, 60], [114, 168, 0.0]]],
 [['growth', [22, 30, '10', '11', '10', '10.4', 50, 60], [100, 174, 10.0]],
  ['shrink', [24, 32, '10.5', '9.5', '10.2', '9', 40, 30], [101, 106, -9.5]],
  ['no change', [20, 28, '10', '10', '10', '10', 50, 45], [100, 126, 0.0]],
  ['regression: even row rounding', [30, 28, '10', '10.5', '10', '10.4', 55, 45], [157, 122, 5.0]],
  ['repair check: even row rounding', [30, 28, '10.5', '10.8', '10', '9.5', 50, 45], [139, 132, 2.9]],
  ['generated control 1', [20, 30, '10', '11', '10.2', '10.4', 55, 45], [100, 130, 10.0]],
  ['generated control 2', [22, 40, '10.5', '11', '10.2', '9', 50, 60], [100, 266, 4.8]],
  ['generated control 3', [20, 30, '10', '10.8', '10.2', '10', 55, 45], [102, 136, 8.0]]],
 [['shrink', [24, 32, '10.5', '9.5', '10.2', '9', 40, 30], [101, 106, -9.5]],
  ['no change', [20, 28, '10', '10', '10', '10', 50, 45], [100, 126, 0.0]],
  ['growth', [22, 30, '10', '11', '10', '10.4', 50, 60], [100, 174, 10.0]],
  ['regression: even row rounding', [22, 32, '10', '10.5', '10', '9.5', 50, 30], [105, 102, 5.0]],
  ['repair check: even row rounding', [22, 30, '10', '10', '10', '9.5', 40, 30], [88, 94, 0.0]],
  ['generated control 1', [20, 40, '10.5', '10.8', '10', '10', 40, 60], [74, 240, 2.9]],
  ['generated control 2', [20, 32, '10', '10.8', '10.2', '9', 55, 45], [102, 160, 8.0]],
  ['generated control 3', [22, 28, '10', '9.5', '10', '10', 40, 60], [93, 168, -5.0]]],
 [['no change', [20, 28, '10', '10', '10', '10', 50, 45], [100, 126, 0.0]],
  ['growth', [22, 30, '10', '11', '10', '10.4', 50, 60], [100, 174, 10.0]],
  ['shrink', [24, 32, '10.5', '9.5', '10.2', '9', 40, 30], [101, 106, -9.5]],
  ['regression: even row rounding', [30, 30, '10', '11', '10', '9.5', 40, 60], [109, 190, 10.0]],
  ['repair check: even row rounding', [22, 32, '10', '10.8', '10', '9.5', 40, 60], [81, 202, 8.0]],
  ['generated control 1', [24, 30, '10', '10', '10', '9', 55, 60], [132, 200, 0.0]],
  ['generated control 2', [24, 40, '10.5', '10.8', '10.2', '10', 50, 30], [111, 120, 2.9]],
  ['generated control 3', [30, 30, '10', '10.5', '10.2', '9', 40, 60], [114, 200, 5.0]]],
 [['growth', [22, 30, '10', '11', '10', '10.4', 50, 60], [100, 174, 10.0]],
  ['shrink', [24, 32, '10.5', '9.5', '10.2', '9', 40, 30], [101, 106, -9.5]],
  ['no change', [20, 28, '10', '10', '10', '10', 50, 45], [100, 126, 0.0]],
  ['regression: even row rounding', [22, 30, '10', '10.8', '10', '10', 40, 45], [81, 136, 8.0]],
  ['repair check: even row rounding', [20, 40, '10.5', '10.5', '10.2', '9.5', 50, 30], [95, 126, 0.0]],
  ['generated control 1', [20, 30, '10', '11', '10', '10', 50, 60], [91, 180, 10.0]],
  ['generated control 2', [24, 30, '10', '10.8', '10', '9', 40, 45], [89, 150, 8.0]],
  ['generated control 3', [24, 30, '10.5', '10.5', '10.2', '10.4', 40, 60], [91, 174, 0.0]]]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
no change[100, 126, 0.0][100, 126, 0.0]Passed
growth[100, 174, 10.0][100, 174, 10.0]Passed
shrink[101, 108, -9.5][101, 106, -9.5]Failed
regression: even row rounding[95, 88, 5.0][95, 86, 5.0]Failed
repair check: even row rounding[91, 254, 10.0][91, 252, 10.0]Failed
generated control 1[111, 84, 8.0][111, 84, 8.0]Passed
generated control 2[73, 140, 10.0][73, 140, 10.0]Passed
generated control 3[114, 168, 0.0][114, 168, 0.0]Passed

SHA-256 / 5f6a71852e2ee42569f84c180f3bd075f6121a2c12d79ef07f321281a26461e4

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

Verification & scope

A deterministic toy contract stated in full here; it is a bounded teaching model, not an authoritative reference or standards implementation. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:52:35.043807+00:00.

Case digest / f074de62db0d5708299b58ac32aee817cdd8fbec5d5a1134ba16b4a338f97f20