FAILURE MAP
← Case archive

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

Gauge-based cast-on calculator: gauge per 10 cm · case 01

A 50 cm panel at 20 stitches per 10 cm asks for 1000 stitches.

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

ROOT CAUSE

The per-10 cm gauge is used as a per-centimetre gauge.

VERIFIED REPAIR

Multiply width by gauge and divide by 10.

Unsuccessful approach: Dividing width by gauge inverts the relationship and gives centimetres per stitch.

Case contract

Target width = width + ease (ease may be negative). Raw stitches = target * gauge / 10 (gauge per 10 cm). Body stitches = nearest multiple of repeat, half-up in repeat units, at least one repeat. Cast on = body + 2*edge (selvedge each side). Actual body width = body*10/gauge, half-up to 0.1 cm. Non-positive target, gauge or repeat returns an error string.

Why this case matters

Knitting patterns and calculators convert a finished measurement and gauge into a stitch count that fits the stitch pattern repeat.

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(width_cm, sts_per_10cm, repeat, edge, ease_cm):
    w = Fraction(str(width_cm)) + Fraction(str(ease_cm))
    g = Fraction(str(sts_per_10cm))
    if w <= 0 or g <= 0 or repeat < 1:
        return 'error: bad measurements'
    raw = w * g
    body = repeat * math.floor(raw / repeat + Fraction(1, 2))
    body = max(repeat, body)
    total = body + 2 * edge
    actual = body * 10 / g
    return [total, math.floor(actual * 10 + Fraction(1, 2)) / 10]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['plain stockinette', [50, '20', 1, 0, 0], [100, 50.0]],
  ['rib with selvedges', [45, '22', 4, 1, 5], [114, 50.9]],
  ['narrow strap one repeat', [3, '16', 8, 2, 0], [12, 5.0]],
  ['regression: gauge per 10 cm', [40, '18', 1, 3, 7.5], [92, 47.8]],
  ['repair check: gauge per 10 cm', [3, '22', 4, 0, 5], [16, 7.3]],
  ['generated control 1', [8, '22', 12, 0, -5], [12, 5.5]],
  ['generated control 2', [3, '16', 12, 0, -2], [12, 7.5]],
  ['generated control 3', [45, '24', 2, 0, -5], [96, 40.0]]],
 [['rib with selvedges', [45, '22', 4, 1, 5], [114, 50.9]],
  ['narrow strap one repeat', [3, '16', 8, 2, 0], [12, 5.0]],
  ['negative ease', [40, '24', 2, 1, -5], [86, 35.0]],
  ['regression: gauge per 10 cm', [30, '27.5', 8, 1, 7.5], [106, 37.8]],
  ['repair check: gauge per 10 cm', [52.5, '16', 8, 0, -5], [80, 50.0]],
  ['generated control 1', [50, '22', 2, 0, -2], [106, 48.2]],
  ['generated control 2', [30, '22', 6, 2, 5], [82, 35.5]],
  ['generated control 3', [40, '20', 4, 0, -5], [72, 36.0]]],
 [['narrow strap one repeat', [3, '16', 8, 2, 0], [12, 5.0]],
  ['negative ease', [40, '24', 2, 1, -5], [86, 35.0]],
  ['invalid width', [3, '20', 2, 0, -5], 'error: bad measurements'],
  ['regression: gauge per 10 cm', [3, '24', 4, 3, 0], [14, 3.3]],
  ['repair check: gauge per 10 cm', [45, '27.5', 1, 2, 10], [155, 54.9]],
  ['generated control 1', [40, '18', 6, 2, -5], [70, 36.7]],
  ['generated control 2', [45, '24', 6, 0, 10], [132, 55.0]],
  ['generated control 3', [52.5, '16', 1, 1, 7.5], [98, 60.0]]],
 [['negative ease', [40, '24', 2, 1, -5], [86, 35.0]],
  ['invalid width', [3, '20', 2, 0, -5], 'error: bad measurements'],
  ['plain stockinette', [50, '20', 1, 0, 0], [100, 50.0]],
  ['regression: gauge per 10 cm', [52.5, '22', 6, 2, 7.5], [136, 60.0]],
  ['repair check: gauge per 10 cm', [45, '16', 12, 3, -2], [78, 45.0]],
  ['generated control 1', [50, '16', 4, 1, -5], [74, 45.0]],
  ['generated control 2', [3, '18', 2, 1, -2], [4, 1.1]],
  ['generated control 3', [30, '27.5', 4, 2, 5], [100, 34.9]]],
 [['invalid width', [3, '20', 2, 0, -5], 'error: bad measurements'],
  ['plain stockinette', [50, '20', 1, 0, 0], [100, 50.0]],
  ['rib with selvedges', [45, '22', 4, 1, 5], [114, 50.9]],
  ['regression: gauge per 10 cm', [3, '27.5', 4, 1, 10], [38, 13.1]],
  ['repair check: gauge per 10 cm', [50, '20', 1, 2, 0], [104, 50.0]],
  ['generated control 1', [45, '18', 4, 2, 7.5], [100, 53.3]],
  ['generated control 2', [3, '22', 1, 0, 7.5], [23, 10.5]],
  ['generated control 3', [8, '18', 2, 2, -5], [10, 3.3]]]]
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
plain stockinette[1000, 500.0][100, 50.0]Failed
rib with selvedges[1102, 500.0][114, 50.9]Failed
narrow strap one repeat[52, 30.0][12, 5.0]Failed
regression: gauge per 10 cm[861, 475.0][92, 47.8]Failed
repair check: gauge per 10 cm[176, 80.0][16, 7.3]Failed
generated control 1[72, 32.7][12, 5.5]Failed
generated control 2[12, 7.5][12, 7.5]Passed
generated control 3[960, 400.0][96, 40.0]Failed

SHA-256 / 3175a975ebe170913596f1a0d2faba774b124c963bca97c2a0197824a2bf8869

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(width_cm, sts_per_10cm, repeat, edge, ease_cm):
    w = Fraction(str(width_cm)) + Fraction(str(ease_cm))
    g = Fraction(str(sts_per_10cm))
    if w <= 0 or g <= 0 or repeat < 1:
        return 'error: bad measurements'
    raw = w / g * 10
    body = repeat * math.floor(raw / repeat + Fraction(1, 2))
    body = max(repeat, body)
    total = body + 2 * edge
    actual = body * 10 / g
    return [total, math.floor(actual * 10 + Fraction(1, 2)) / 10]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['plain stockinette', [50, '20', 1, 0, 0], [100, 50.0]],
  ['rib with selvedges', [45, '22', 4, 1, 5], [114, 50.9]],
  ['narrow strap one repeat', [3, '16', 8, 2, 0], [12, 5.0]],
  ['regression: gauge per 10 cm', [40, '18', 1, 3, 7.5], [92, 47.8]],
  ['repair check: gauge per 10 cm', [3, '22', 4, 0, 5], [16, 7.3]],
  ['generated control 1', [8, '22', 12, 0, -5], [12, 5.5]],
  ['generated control 2', [3, '16', 12, 0, -2], [12, 7.5]],
  ['generated control 3', [45, '24', 2, 0, -5], [96, 40.0]]],
 [['rib with selvedges', [45, '22', 4, 1, 5], [114, 50.9]],
  ['narrow strap one repeat', [3, '16', 8, 2, 0], [12, 5.0]],
  ['negative ease', [40, '24', 2, 1, -5], [86, 35.0]],
  ['regression: gauge per 10 cm', [30, '27.5', 8, 1, 7.5], [106, 37.8]],
  ['repair check: gauge per 10 cm', [52.5, '16', 8, 0, -5], [80, 50.0]],
  ['generated control 1', [50, '22', 2, 0, -2], [106, 48.2]],
  ['generated control 2', [30, '22', 6, 2, 5], [82, 35.5]],
  ['generated control 3', [40, '20', 4, 0, -5], [72, 36.0]]],
 [['narrow strap one repeat', [3, '16', 8, 2, 0], [12, 5.0]],
  ['negative ease', [40, '24', 2, 1, -5], [86, 35.0]],
  ['invalid width', [3, '20', 2, 0, -5], 'error: bad measurements'],
  ['regression: gauge per 10 cm', [3, '24', 4, 3, 0], [14, 3.3]],
  ['repair check: gauge per 10 cm', [45, '27.5', 1, 2, 10], [155, 54.9]],
  ['generated control 1', [40, '18', 6, 2, -5], [70, 36.7]],
  ['generated control 2', [45, '24', 6, 0, 10], [132, 55.0]],
  ['generated control 3', [52.5, '16', 1, 1, 7.5], [98, 60.0]]],
 [['negative ease', [40, '24', 2, 1, -5], [86, 35.0]],
  ['invalid width', [3, '20', 2, 0, -5], 'error: bad measurements'],
  ['plain stockinette', [50, '20', 1, 0, 0], [100, 50.0]],
  ['regression: gauge per 10 cm', [52.5, '22', 6, 2, 7.5], [136, 60.0]],
  ['repair check: gauge per 10 cm', [45, '16', 12, 3, -2], [78, 45.0]],
  ['generated control 1', [50, '16', 4, 1, -5], [74, 45.0]],
  ['generated control 2', [3, '18', 2, 1, -2], [4, 1.1]],
  ['generated control 3', [30, '27.5', 4, 2, 5], [100, 34.9]]],
 [['invalid width', [3, '20', 2, 0, -5], 'error: bad measurements'],
  ['plain stockinette', [50, '20', 1, 0, 0], [100, 50.0]],
  ['rib with selvedges', [45, '22', 4, 1, 5], [114, 50.9]],
  ['regression: gauge per 10 cm', [3, '27.5', 4, 1, 10], [38, 13.1]],
  ['repair check: gauge per 10 cm', [50, '20', 1, 2, 0], [104, 50.0]],
  ['generated control 1', [45, '18', 4, 2, 7.5], [100, 53.3]],
  ['generated control 2', [3, '22', 1, 0, 7.5], [23, 10.5]],
  ['generated control 3', [8, '18', 2, 2, -5], [10, 3.3]]]]
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
plain stockinette[25, 12.5][100, 50.0]Failed
rib with selvedges[26, 10.9][114, 50.9]Failed
narrow strap one repeat[12, 5.0][12, 5.0]Passed
regression: gauge per 10 cm[32, 14.4][92, 47.8]Failed
repair check: gauge per 10 cm[4, 1.8][16, 7.3]Failed
generated control 1[12, 5.5][12, 5.5]Passed
generated control 2[12, 7.5][12, 7.5]Passed
generated control 3[16, 6.7][96, 40.0]Failed

SHA-256 / 0e1d01a00cb470033e4e4c7eda69dee004350b61ae65a8fbf23f27ed8d4bc5e5

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(width_cm, sts_per_10cm, repeat, edge, ease_cm):
    w = Fraction(str(width_cm)) + Fraction(str(ease_cm))
    g = Fraction(str(sts_per_10cm))
    if w <= 0 or g <= 0 or repeat < 1:
        return 'error: bad measurements'
    raw = w * g / 10
    body = repeat * math.floor(raw / repeat + Fraction(1, 2))
    body = max(repeat, body)
    total = body + 2 * edge
    actual = body * 10 / g
    return [total, math.floor(actual * 10 + Fraction(1, 2)) / 10]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['plain stockinette', [50, '20', 1, 0, 0], [100, 50.0]],
  ['rib with selvedges', [45, '22', 4, 1, 5], [114, 50.9]],
  ['narrow strap one repeat', [3, '16', 8, 2, 0], [12, 5.0]],
  ['regression: gauge per 10 cm', [40, '18', 1, 3, 7.5], [92, 47.8]],
  ['repair check: gauge per 10 cm', [3, '22', 4, 0, 5], [16, 7.3]],
  ['generated control 1', [8, '22', 12, 0, -5], [12, 5.5]],
  ['generated control 2', [3, '16', 12, 0, -2], [12, 7.5]],
  ['generated control 3', [45, '24', 2, 0, -5], [96, 40.0]]],
 [['rib with selvedges', [45, '22', 4, 1, 5], [114, 50.9]],
  ['narrow strap one repeat', [3, '16', 8, 2, 0], [12, 5.0]],
  ['negative ease', [40, '24', 2, 1, -5], [86, 35.0]],
  ['regression: gauge per 10 cm', [30, '27.5', 8, 1, 7.5], [106, 37.8]],
  ['repair check: gauge per 10 cm', [52.5, '16', 8, 0, -5], [80, 50.0]],
  ['generated control 1', [50, '22', 2, 0, -2], [106, 48.2]],
  ['generated control 2', [30, '22', 6, 2, 5], [82, 35.5]],
  ['generated control 3', [40, '20', 4, 0, -5], [72, 36.0]]],
 [['narrow strap one repeat', [3, '16', 8, 2, 0], [12, 5.0]],
  ['negative ease', [40, '24', 2, 1, -5], [86, 35.0]],
  ['invalid width', [3, '20', 2, 0, -5], 'error: bad measurements'],
  ['regression: gauge per 10 cm', [3, '24', 4, 3, 0], [14, 3.3]],
  ['repair check: gauge per 10 cm', [45, '27.5', 1, 2, 10], [155, 54.9]],
  ['generated control 1', [40, '18', 6, 2, -5], [70, 36.7]],
  ['generated control 2', [45, '24', 6, 0, 10], [132, 55.0]],
  ['generated control 3', [52.5, '16', 1, 1, 7.5], [98, 60.0]]],
 [['negative ease', [40, '24', 2, 1, -5], [86, 35.0]],
  ['invalid width', [3, '20', 2, 0, -5], 'error: bad measurements'],
  ['plain stockinette', [50, '20', 1, 0, 0], [100, 50.0]],
  ['regression: gauge per 10 cm', [52.5, '22', 6, 2, 7.5], [136, 60.0]],
  ['repair check: gauge per 10 cm', [45, '16', 12, 3, -2], [78, 45.0]],
  ['generated control 1', [50, '16', 4, 1, -5], [74, 45.0]],
  ['generated control 2', [3, '18', 2, 1, -2], [4, 1.1]],
  ['generated control 3', [30, '27.5', 4, 2, 5], [100, 34.9]]],
 [['invalid width', [3, '20', 2, 0, -5], 'error: bad measurements'],
  ['plain stockinette', [50, '20', 1, 0, 0], [100, 50.0]],
  ['rib with selvedges', [45, '22', 4, 1, 5], [114, 50.9]],
  ['regression: gauge per 10 cm', [3, '27.5', 4, 1, 10], [38, 13.1]],
  ['repair check: gauge per 10 cm', [50, '20', 1, 2, 0], [104, 50.0]],
  ['generated control 1', [45, '18', 4, 2, 7.5], [100, 53.3]],
  ['generated control 2', [3, '22', 1, 0, 7.5], [23, 10.5]],
  ['generated control 3', [8, '18', 2, 2, -5], [10, 3.3]]]]
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
plain stockinette[100, 50.0][100, 50.0]Passed
rib with selvedges[114, 50.9][114, 50.9]Passed
narrow strap one repeat[12, 5.0][12, 5.0]Passed
regression: gauge per 10 cm[92, 47.8][92, 47.8]Passed
repair check: gauge per 10 cm[16, 7.3][16, 7.3]Passed
generated control 1[12, 5.5][12, 5.5]Passed
generated control 2[12, 7.5][12, 7.5]Passed
generated control 3[96, 40.0][96, 40.0]Passed

SHA-256 / e8ecab547de3cf8ee52b7430c2f1684297a7502654242a51c784393b31dbca09

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

Case digest / dd38350854b7023104480e3ae2e2ca11ba6e3e96d7e4c4652fdba73e15c1fec3