FAILURE MAP
← Case archive

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

Post-wash swatch gauge: change percentage · case 01

A swatch that grew is reported as shrinking.

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

ROOT CAUSE

The ratio is inverted.

THE FAILURE

The ratio is inverted.

Unsuccessful approach: Dividing by the post-wash width understates growth.

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 = 2 * math.floor(rr / 2 + Fraction(1, 2))
    change = (Fraction(w_pre) / wpo - 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: change percentage', [30, 40, '10.5', '11', '10.2', '10', 50, 30], [136, 120, 4.8]],
  ['repair check: change percentage', [20, 28, '10.5', '10', '10', '10', 50, 45], [100, 126, -4.8]],
  ['generated control 1', [20, 32, '10.5', '10.5', '10.2', '10', 50, 45], [95, 144, 0.0]],
  ['generated control 2', [20, 40, '10', '10.8', '10', '10.4', 50, 60], [93, 230, 8.0]],
  ['generated control 3', [20, 30, '10', '11', '10.2', '9.5', 40, 45], [73, 142, 10.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: change percentage', [24, 32, '10.5', '11', '10', '10', 50, 45], [109, 144, 4.8]],
  ['repair check: change percentage', [24, 30, '10', '10.5', '10.2', '9', 55, 45], [126, 150, 5.0]],
  ['generated control 1', [24, 28, '10', '10.5', '10.2', '9.5', 50, 30], [114, 88, 5.0]],
  ['generated control 2', [30, 40, '10.5', '9.5', '10', '10', 40, 60], [126, 240, -9.5]],
  ['generated control 3', [22, 30, '10', '9.5', '10.2', '10', 55, 60], [127, 180, -5.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: change percentage', [24, 30, '10.5', '10', '10', '10', 50, 60], [120, 180, -4.8]],
  ['repair check: change percentage', [24, 40, '10.5', '10.8', '10', '9', 50, 30], [111, 134, 2.9]],
  ['generated control 1', [20, 28, '10.5', '10.5', '10', '9', 50, 45], [95, 140, 0.0]],
  ['generated control 2', [30, 30, '10', '10.5', '10.2', '10', 55, 45], [157, 136, 5.0]],
  ['generated control 3', [20, 32, '10.5', '10.8', '10', '10', 55, 30], [102, 96, 2.9]]],
 [['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: change percentage', [24, 30, '10', '11', '10.2', '9', 50, 30], [109, 100, 10.0]],
  ['repair check: change percentage', [20, 40, '10.5', '10.8', '10', '10', 50, 30], [93, 120, 2.9]],
  ['generated control 1', [30, 40, '10.5', '9.5', '10.2', '9.5', 40, 45], [126, 190, -9.5]],
  ['generated control 2', [20, 32, '10.5', '11', '10.2', '9.5', 55, 45], [100, 152, 4.8]],
  ['generated control 3', [24, 28, '10.5', '9.5', '10', '9', 40, 60], [101, 186, -9.5]]],
 [['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: change percentage', [22, 28, '10.5', '10', '10.2', '10.4', 55, 60], [121, 162, -4.8]],
  ['repair check: change percentage', [20, 30, '10.5', '10', '10.2', '9', 55, 60], [110, 200, -4.8]],
  ['generated control 1', [30, 30, '10', '10', '10', '9', 50, 30], [150, 100, 0.0]],
  ['generated control 2', [24, 32, '10.5', '10', '10', '10.4', 55, 45], [132, 138, -4.8]],
  ['generated control 3', [22, 40, '10', '10.5', '10', '10.4', 40, 45], [84, 174, 5.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, -9.1][100, 174, 10.0]Failed
shrink[101, 106, 10.5][101, 106, -9.5]Failed
regression: change percentage[136, 120, -4.5][136, 120, 4.8]Failed
repair check: change percentage[100, 126, 5.0][100, 126, -4.8]Failed
generated control 1[95, 144, 0.0][95, 144, 0.0]Passed
generated control 2[93, 230, -7.4][93, 230, 8.0]Failed
generated control 3[73, 142, -9.1][73, 142, 10.0]Failed

SHA-256 / 6bb906d7cdb0bc9581f392173e394f2c5d4a3a7f28f6d2244276e59bee323c6c

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.floor(rr / 2 + Fraction(1, 2))
    change = (wpo - Fraction(w_pre)) / wpo * 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: change percentage', [30, 40, '10.5', '11', '10.2', '10', 50, 30], [136, 120, 4.8]],
  ['repair check: change percentage', [20, 28, '10.5', '10', '10', '10', 50, 45], [100, 126, -4.8]],
  ['generated control 1', [20, 32, '10.5', '10.5', '10.2', '10', 50, 45], [95, 144, 0.0]],
  ['generated control 2', [20, 40, '10', '10.8', '10', '10.4', 50, 60], [93, 230, 8.0]],
  ['generated control 3', [20, 30, '10', '11', '10.2', '9.5', 40, 45], [73, 142, 10.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: change percentage', [24, 32, '10.5', '11', '10', '10', 50, 45], [109, 144, 4.8]],
  ['repair check: change percentage', [24, 30, '10', '10.5', '10.2', '9', 55, 45], [126, 150, 5.0]],
  ['generated control 1', [24, 28, '10', '10.5', '10.2', '9.5', 50, 30], [114, 88, 5.0]],
  ['generated control 2', [30, 40, '10.5', '9.5', '10', '10', 40, 60], [126, 240, -9.5]],
  ['generated control 3', [22, 30, '10', '9.5', '10.2', '10', 55, 60], [127, 180, -5.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: change percentage', [24, 30, '10.5', '10', '10', '10', 50, 60], [120, 180, -4.8]],
  ['repair check: change percentage', [24, 40, '10.5', '10.8', '10', '9', 50, 30], [111, 134, 2.9]],
  ['generated control 1', [20, 28, '10.5', '10.5', '10', '9', 50, 45], [95, 140, 0.0]],
  ['generated control 2', [30, 30, '10', '10.5', '10.2', '10', 55, 45], [157, 136, 5.0]],
  ['generated control 3', [20, 32, '10.5', '10.8', '10', '10', 55, 30], [102, 96, 2.9]]],
 [['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: change percentage', [24, 30, '10', '11', '10.2', '9', 50, 30], [109, 100, 10.0]],
  ['repair check: change percentage', [20, 40, '10.5', '10.8', '10', '10', 50, 30], [93, 120, 2.9]],
  ['generated control 1', [30, 40, '10.5', '9.5', '10.2', '9.5', 40, 45], [126, 190, -9.5]],
  ['generated control 2', [20, 32, '10.5', '11', '10.2', '9.5', 55, 45], [100, 152, 4.8]],
  ['generated control 3', [24, 28, '10.5', '9.5', '10', '9', 40, 60], [101, 186, -9.5]]],
 [['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: change percentage', [22, 28, '10.5', '10', '10.2', '10.4', 55, 60], [121, 162, -4.8]],
  ['repair check: change percentage', [20, 30, '10.5', '10', '10.2', '9', 55, 60], [110, 200, -4.8]],
  ['generated control 1', [30, 30, '10', '10', '10', '9', 50, 30], [150, 100, 0.0]],
  ['generated control 2', [24, 32, '10.5', '10', '10', '10.4', 55, 45], [132, 138, -4.8]],
  ['generated control 3', [22, 40, '10', '10.5', '10', '10.4', 40, 45], [84, 174, 5.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, 9.1][100, 174, 10.0]Failed
shrink[101, 106, -10.5][101, 106, -9.5]Failed
regression: change percentage[136, 120, 4.5][136, 120, 4.8]Failed
repair check: change percentage[100, 126, -5.0][100, 126, -4.8]Failed
generated control 1[95, 144, 0.0][95, 144, 0.0]Passed
generated control 2[93, 230, 7.4][93, 230, 8.0]Failed
generated control 3[73, 142, 9.1][73, 142, 10.0]Failed

SHA-256 / 08979629264c4944ba5c521ffb65ad0c109d58d09cfbcfd3d73ecb323ab5cf1c

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.043832+00:00.

Case digest / ff0d9d78266f2f7e5dffcf09d810451b8c92ce42a2d51556128118c772148efc