FAILURE MAP
← Case archive

FA-91656 / Digital signal filters / Open access

Linear-phase classifier does not strip leading zeros · case 01

[0, 3, 3, 0, 0] is reported as not linear phase.

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

ROOT CAUSE

Only trailing zeros are trimmed, so a delayed symmetric filter looks asymmetric.

VERIFIED REPAIR

Strip leading zeros too and account for them in the delay.

Unsuccessful approach: The attempted repair removes every zero tap, including interior ones, which destroys the shape.

Case contract

Input integer taps. Strip leading and trailing zeros ("degenerate" if all zero). The trimmed support of length N is type 1/2 if symmetric (odd/even N), type 3/4 if antisymmetric (odd/even N), otherwise not linear phase. Return {"type", "group_delay": leading zeros + (N-1)/2 as a fraction string} or both None.

Why this case matters

Linear-phase type determines which responses an FIR can realize (e.g. no highpass for type 2); misclassification picks the wrong design.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(x):
    h = list(x)
    lead = 0
    if all(v == 0 for v in h):
        return 'degenerate'
    end = len(h)
    while h[end - 1] == 0:
        end -= 1
    g = h[lead:end]
    N = len(g)
    sym = all(g[i] == g[N - 1 - i] for i in range(N))
    anti = all(g[i] == -g[N - 1 - i] for i in range(N))
    if sym:
        typ = 1 if N % 2 else 2
    elif anti:
        typ = 3 if N % 2 else 4
    else:
        return {'type': None, 'group_delay': None}
    return {'type': typ, 'group_delay': str(lead + Fraction(N - 1, 2))}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: leading zeros symmetric', [0, 0, 1, 2, 1], {'type': 1, 'group_delay': '3'}], ['regression: padded type II', [0, 3, 3, 0, 0], {'type': 2, 'group_delay': '3/2'}], ['repair check: type III zero centre', [1, 0, -1], {'type': 3, 'group_delay': '1'}], ['control: type III nonzero centre', [1, 2, -1], {'type': None, 'group_delay': None}], ['control: type I', [1, 2, 1], {'type': 1, 'group_delay': '1'}], ['control: type II', [1, 1], {'type': 2, 'group_delay': '1/2'}], ['control: type IV', [1, -1], {'type': 4, 'group_delay': '1/2'}]], [['regression: random linear phase 1', [0, 2, -2, 0, 0, 0], {'type': 4, 'group_delay': '3/2'}], ['regression: random linear phase 5', [0, 0, -3, -3, -2, -3, -3, 0], {'type': 1, 'group_delay': '4'}], ['repair check: interior zero symmetric', [1, 0, 1], {'type': 1, 'group_delay': '1'}], ['control: trailing zeros', [1, 2, 1, 0], {'type': 1, 'group_delay': '1'}], ['control: all zero', [0, 0, 0], 'degenerate'], ['control: not linear phase', [1, 2, 3], {'type': None, 'group_delay': None}], ['control: type IV longer', [2, 1, -1, -2], {'type': 4, 'group_delay': '3/2'}]], [['regression: random linear phase 10', [0, 0, 0, -1, 1, 0], {'type': 4, 'group_delay': '7/2'}], ['regression: random linear phase 11', [0, 0, 2, -2, 0], {'type': 4, 'group_delay': '5/2'}], ['regression: padded interior zeros', [0, 2, 0, 0, 2], {'type': 2, 'group_delay': '5/2'}], ['control: single tap', [5], {'type': 1, 'group_delay': '0'}], ['control: random linear phase 2', [0, 0, 2, 0, 2, 0, -2, 0, 0], {'type': None, 'group_delay': None}], ['control: random linear phase 4', [0, 1, -1, -1, 0], {'type': None, 'group_delay': None}], ['control: random linear phase 6', [0, 3, 2, -3], {'type': None, 'group_delay': None}]], [['regression: random linear phase 15', [0, 0, 1, -1, -1, 1, 0, 0], {'type': 2, 'group_delay': '7/2'}], ['regression: random linear phase 16', [0, -3, -1, 1, 3, 0, 0], {'type': 4, 'group_delay': '5/2'}], ['regression: random linear phase 1', [0, 2, -2, 0, 0, 0], {'type': 4, 'group_delay': '3/2'}], ['control: random linear phase 7', [0, 0, 0, 0, 0], 'degenerate'], ['control: random linear phase 8', [2, -2, -2, 2, 2, -2, 0, 0], {'type': 4, 'group_delay': '5/2'}], ['control: random linear phase 12', [-1, 1, -1, 1, 0, 0], {'type': 4, 'group_delay': '3/2'}], ['control: random linear phase 13', [-3, -3, 0, 0], {'type': 2, 'group_delay': '1/2'}]], [['regression: random linear phase 18', [0, 0, 3, 3, 0, 0], {'type': 2, 'group_delay': '5/2'}], ['regression: random linear phase 20', [0, 2, -2, 2, 0, 0], {'type': 1, 'group_delay': '2'}], ['regression: random linear phase 5', [0, 0, -3, -3, -2, -3, -3, 0], {'type': 1, 'group_delay': '4'}], ['control: random linear phase 19', [3, -1, 3, -3, 1, -3, 0, 0], {'type': 4, 'group_delay': '5/2'}], ['control: random linear phase 21', [1, -2, 1, 1, -2, 1, 0], {'type': 2, 'group_delay': '5/2'}], ['control: type III nonzero centre', [1, 2, -1], {'type': None, 'group_delay': None}], ['control: type I', [1, 2, 1], {'type': 1, 'group_delay': '1'}]]]
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
regression: leading zeros symmetric{'group_delay': None, 'type': None}{'group_delay': '3', 'type': 1}Failed
regression: padded type II{'group_delay': None, 'type': None}{'group_delay': '3/2', 'type': 2}Failed
repair check: type III zero centre{'group_delay': '1', 'type': 3}{'group_delay': '1', 'type': 3}Passed
control: type III nonzero centre{'group_delay': None, 'type': None}{'group_delay': None, 'type': None}Passed
control: type I{'group_delay': '1', 'type': 1}{'group_delay': '1', 'type': 1}Passed
control: type II{'group_delay': '1/2', 'type': 2}{'group_delay': '1/2', 'type': 2}Passed
control: type IV{'group_delay': '1/2', 'type': 4}{'group_delay': '1/2', 'type': 4}Passed

SHA-256 / 6589192c735a29c831007c85b29a5bdc7efa1f06ee10035ec8f799535ed2ff65

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(x):
    h = list(x)
    lead = 0
    if all(v == 0 for v in h):
        return 'degenerate'
    g = [v for v in h if v != 0]
    N = len(g)
    sym = all(g[i] == g[N - 1 - i] for i in range(N))
    anti = all(g[i] == -g[N - 1 - i] for i in range(N))
    if sym:
        typ = 1 if N % 2 else 2
    elif anti:
        typ = 3 if N % 2 else 4
    else:
        return {'type': None, 'group_delay': None}
    return {'type': typ, 'group_delay': str(lead + Fraction(N - 1, 2))}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: leading zeros symmetric', [0, 0, 1, 2, 1], {'type': 1, 'group_delay': '3'}], ['regression: padded type II', [0, 3, 3, 0, 0], {'type': 2, 'group_delay': '3/2'}], ['repair check: type III zero centre', [1, 0, -1], {'type': 3, 'group_delay': '1'}], ['control: type III nonzero centre', [1, 2, -1], {'type': None, 'group_delay': None}], ['control: type I', [1, 2, 1], {'type': 1, 'group_delay': '1'}], ['control: type II', [1, 1], {'type': 2, 'group_delay': '1/2'}], ['control: type IV', [1, -1], {'type': 4, 'group_delay': '1/2'}]], [['regression: random linear phase 1', [0, 2, -2, 0, 0, 0], {'type': 4, 'group_delay': '3/2'}], ['regression: random linear phase 5', [0, 0, -3, -3, -2, -3, -3, 0], {'type': 1, 'group_delay': '4'}], ['repair check: interior zero symmetric', [1, 0, 1], {'type': 1, 'group_delay': '1'}], ['control: trailing zeros', [1, 2, 1, 0], {'type': 1, 'group_delay': '1'}], ['control: all zero', [0, 0, 0], 'degenerate'], ['control: not linear phase', [1, 2, 3], {'type': None, 'group_delay': None}], ['control: type IV longer', [2, 1, -1, -2], {'type': 4, 'group_delay': '3/2'}]], [['regression: random linear phase 10', [0, 0, 0, -1, 1, 0], {'type': 4, 'group_delay': '7/2'}], ['regression: random linear phase 11', [0, 0, 2, -2, 0], {'type': 4, 'group_delay': '5/2'}], ['regression: padded interior zeros', [0, 2, 0, 0, 2], {'type': 2, 'group_delay': '5/2'}], ['control: single tap', [5], {'type': 1, 'group_delay': '0'}], ['control: random linear phase 2', [0, 0, 2, 0, 2, 0, -2, 0, 0], {'type': None, 'group_delay': None}], ['control: random linear phase 4', [0, 1, -1, -1, 0], {'type': None, 'group_delay': None}], ['control: random linear phase 6', [0, 3, 2, -3], {'type': None, 'group_delay': None}]], [['regression: random linear phase 15', [0, 0, 1, -1, -1, 1, 0, 0], {'type': 2, 'group_delay': '7/2'}], ['regression: random linear phase 16', [0, -3, -1, 1, 3, 0, 0], {'type': 4, 'group_delay': '5/2'}], ['regression: random linear phase 1', [0, 2, -2, 0, 0, 0], {'type': 4, 'group_delay': '3/2'}], ['control: random linear phase 7', [0, 0, 0, 0, 0], 'degenerate'], ['control: random linear phase 8', [2, -2, -2, 2, 2, -2, 0, 0], {'type': 4, 'group_delay': '5/2'}], ['control: random linear phase 12', [-1, 1, -1, 1, 0, 0], {'type': 4, 'group_delay': '3/2'}], ['control: random linear phase 13', [-3, -3, 0, 0], {'type': 2, 'group_delay': '1/2'}]], [['regression: random linear phase 18', [0, 0, 3, 3, 0, 0], {'type': 2, 'group_delay': '5/2'}], ['regression: random linear phase 20', [0, 2, -2, 2, 0, 0], {'type': 1, 'group_delay': '2'}], ['regression: random linear phase 5', [0, 0, -3, -3, -2, -3, -3, 0], {'type': 1, 'group_delay': '4'}], ['control: random linear phase 19', [3, -1, 3, -3, 1, -3, 0, 0], {'type': 4, 'group_delay': '5/2'}], ['control: random linear phase 21', [1, -2, 1, 1, -2, 1, 0], {'type': 2, 'group_delay': '5/2'}], ['control: type III nonzero centre', [1, 2, -1], {'type': None, 'group_delay': None}], ['control: type I', [1, 2, 1], {'type': 1, 'group_delay': '1'}]]]
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
regression: leading zeros symmetric{'group_delay': '1', 'type': 1}{'group_delay': '3', 'type': 1}Failed
regression: padded type II{'group_delay': '1/2', 'type': 2}{'group_delay': '3/2', 'type': 2}Failed
repair check: type III zero centre{'group_delay': '1/2', 'type': 4}{'group_delay': '1', 'type': 3}Failed
control: type III nonzero centre{'group_delay': None, 'type': None}{'group_delay': None, 'type': None}Passed
control: type I{'group_delay': '1', 'type': 1}{'group_delay': '1', 'type': 1}Passed
control: type II{'group_delay': '1/2', 'type': 2}{'group_delay': '1/2', 'type': 2}Passed
control: type IV{'group_delay': '1/2', 'type': 4}{'group_delay': '1/2', 'type': 4}Passed

SHA-256 / 84a59d51bddce76e1febabdd3a68453f6dca86fb63b03e01e6b00c45b5d01ad0

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(x):
    h = list(x)
    lead = 0
    while lead < len(h) and h[lead] == 0:
        lead += 1
    if lead == len(h):
        return 'degenerate'
    end = len(h)
    while h[end - 1] == 0:
        end -= 1
    g = h[lead:end]
    N = len(g)
    sym = all(g[i] == g[N - 1 - i] for i in range(N))
    anti = all(g[i] == -g[N - 1 - i] for i in range(N))
    if sym:
        typ = 1 if N % 2 else 2
    elif anti:
        typ = 3 if N % 2 else 4
    else:
        return {'type': None, 'group_delay': None}
    return {'type': typ, 'group_delay': str(lead + Fraction(N - 1, 2))}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: leading zeros symmetric', [0, 0, 1, 2, 1], {'type': 1, 'group_delay': '3'}], ['regression: padded type II', [0, 3, 3, 0, 0], {'type': 2, 'group_delay': '3/2'}], ['repair check: type III zero centre', [1, 0, -1], {'type': 3, 'group_delay': '1'}], ['control: type III nonzero centre', [1, 2, -1], {'type': None, 'group_delay': None}], ['control: type I', [1, 2, 1], {'type': 1, 'group_delay': '1'}], ['control: type II', [1, 1], {'type': 2, 'group_delay': '1/2'}], ['control: type IV', [1, -1], {'type': 4, 'group_delay': '1/2'}]], [['regression: random linear phase 1', [0, 2, -2, 0, 0, 0], {'type': 4, 'group_delay': '3/2'}], ['regression: random linear phase 5', [0, 0, -3, -3, -2, -3, -3, 0], {'type': 1, 'group_delay': '4'}], ['repair check: interior zero symmetric', [1, 0, 1], {'type': 1, 'group_delay': '1'}], ['control: trailing zeros', [1, 2, 1, 0], {'type': 1, 'group_delay': '1'}], ['control: all zero', [0, 0, 0], 'degenerate'], ['control: not linear phase', [1, 2, 3], {'type': None, 'group_delay': None}], ['control: type IV longer', [2, 1, -1, -2], {'type': 4, 'group_delay': '3/2'}]], [['regression: random linear phase 10', [0, 0, 0, -1, 1, 0], {'type': 4, 'group_delay': '7/2'}], ['regression: random linear phase 11', [0, 0, 2, -2, 0], {'type': 4, 'group_delay': '5/2'}], ['regression: padded interior zeros', [0, 2, 0, 0, 2], {'type': 2, 'group_delay': '5/2'}], ['control: single tap', [5], {'type': 1, 'group_delay': '0'}], ['control: random linear phase 2', [0, 0, 2, 0, 2, 0, -2, 0, 0], {'type': None, 'group_delay': None}], ['control: random linear phase 4', [0, 1, -1, -1, 0], {'type': None, 'group_delay': None}], ['control: random linear phase 6', [0, 3, 2, -3], {'type': None, 'group_delay': None}]], [['regression: random linear phase 15', [0, 0, 1, -1, -1, 1, 0, 0], {'type': 2, 'group_delay': '7/2'}], ['regression: random linear phase 16', [0, -3, -1, 1, 3, 0, 0], {'type': 4, 'group_delay': '5/2'}], ['regression: random linear phase 1', [0, 2, -2, 0, 0, 0], {'type': 4, 'group_delay': '3/2'}], ['control: random linear phase 7', [0, 0, 0, 0, 0], 'degenerate'], ['control: random linear phase 8', [2, -2, -2, 2, 2, -2, 0, 0], {'type': 4, 'group_delay': '5/2'}], ['control: random linear phase 12', [-1, 1, -1, 1, 0, 0], {'type': 4, 'group_delay': '3/2'}], ['control: random linear phase 13', [-3, -3, 0, 0], {'type': 2, 'group_delay': '1/2'}]], [['regression: random linear phase 18', [0, 0, 3, 3, 0, 0], {'type': 2, 'group_delay': '5/2'}], ['regression: random linear phase 20', [0, 2, -2, 2, 0, 0], {'type': 1, 'group_delay': '2'}], ['regression: random linear phase 5', [0, 0, -3, -3, -2, -3, -3, 0], {'type': 1, 'group_delay': '4'}], ['control: random linear phase 19', [3, -1, 3, -3, 1, -3, 0, 0], {'type': 4, 'group_delay': '5/2'}], ['control: random linear phase 21', [1, -2, 1, 1, -2, 1, 0], {'type': 2, 'group_delay': '5/2'}], ['control: type III nonzero centre', [1, 2, -1], {'type': None, 'group_delay': None}], ['control: type I', [1, 2, 1], {'type': 1, 'group_delay': '1'}]]]
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
regression: leading zeros symmetric{'group_delay': '3', 'type': 1}{'group_delay': '3', 'type': 1}Passed
regression: padded type II{'group_delay': '3/2', 'type': 2}{'group_delay': '3/2', 'type': 2}Passed
repair check: type III zero centre{'group_delay': '1', 'type': 3}{'group_delay': '1', 'type': 3}Passed
control: type III nonzero centre{'group_delay': None, 'type': None}{'group_delay': None, 'type': None}Passed
control: type I{'group_delay': '1', 'type': 1}{'group_delay': '1', 'type': 1}Passed
control: type II{'group_delay': '1/2', 'type': 2}{'group_delay': '1/2', 'type': 2}Passed
control: type IV{'group_delay': '1/2', 'type': 4}{'group_delay': '1/2', 'type': 4}Passed

SHA-256 / d67d311fe7339e9c11130cc5e574d96e90a370bc2d2270bbd8997b65ea3bc367

Verification & scope

A deterministic bounded teaching model with a stipulated toy contract; exact rational arithmetic or fixed-decimal rounding keeps outputs strict JSON. It is not a production DSP library and claims no standards conformance. 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:51:38.146331+00:00.

Case digest / 5bf9223455efffd8f6d16fa29a5d2559a5decc5bb0cf96af9932c22da097fc4c