broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(x):
    t = cliff = 0
    for idx, op in enumerate(x):
        name = op[0]
        if name in ('t', 'tdg'):
            t += 1
        elif name in ('h', 's', 'sdg', 'x', 'y', 'z', 'cx', 'cz', 'swap'):
            cliff += 1
        elif name == 'ccx':
            t += 7
            cliff += 8
        elif name == 'rz':
            a = Fraction(op[2])
            if a == 0:
                continue
            if (a * 2).denominator == 1:
                cliff += 1
            elif (a * 4).denominator == 1:
                t += 1
            else:
                return ['unsupported', idx]
        else:
            return ['unknown-gate', idx]
    return {'t_count': t, 'clifford_count': cliff}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: rz two pi', [['rz', 0, '2']], {'t_count': 0, 'clifford_count': 0}], ['regression: rz four pi', [['rz', 0, '4']], {'t_count': 0, 'clifford_count': 0}], ['repair check: rz pi is Z', [['rz', 0, '1']], {'t_count': 0, 'clifford_count': 1}], ['control: rz zero', [['rz', 0, '0']], {'t_count': 0, 'clifford_count': 0}], ['control: rz half pi is S', [['rz', 0, '1/2']], {'t_count': 0, 'clifford_count': 1}], ['control: rz quarter pi', [['rz', 0, '1/4']], {'t_count': 1, 'clifford_count': 0}], ['control: tdg', [['tdg', 0]], {'t_count': 1, 'clifford_count': 0}]], [['regression: random t-count 1', [['rz', 0, '-2'], ['ccx', 0, 1, 2], ['rz', 0, '1'], ['rz', 0, '1'], ['rz', 0, '0'], ['x', 0]], {'t_count': 7, 'clifford_count': 11}], ['regression: random t-count 16', [['rz', 0, '3/4'], ['rz', 0, '-1'], ['tdg', 0], ['sdg', 0], ['rz', 0, '-2'], ['rz', 0, '3/2'], ['sdg', 0]], {'t_count': 2, 'clifford_count': 4}], ['repair check: random t-count 5', [['ccx', 0, 1, 2], ['rz', 0, '1'], ['rz', 0, '5/4'], ['tdg', 0]], {'t_count': 9, 'clifford_count': 9}], ['control: toffoli', [['ccx', 0, 1, 2]], {'t_count': 7, 'clifford_count': 8}], ['control: unsupported angle', [['h', 0], ['rz', 0, '1/8']], ['unsupported', 1]], ['control: negative angles', [['rz', 0, '-1/4'], ['rz', 1, '-3/2']], {'t_count': 1, 'clifford_count': 1}], ['control: unknown gate', [['u3', 0]], ['unknown-gate', 0]]], [['regression: random t-count 23', [['rz', 0, '-2'], ['tdg', 0], ['ccx', 0, 1, 2], ['t', 0], ['rz', 0, '4'], ['rz', 0, '-1']], {'t_count': 9, 'clifford_count': 9}], ['regression: random t-count 31', [['rz', 0, '2'], ['h', 0], ['x', 0], ['x', 0], ['t', 0], ['rz', 0, '-2']], {'t_count': 1, 'clifford_count': 3}], ['repair check: random t-count 11', [['s', 0], ['rz', 0, '5/4'], ['rz', 0, '-1'], ['x', 0], ['t', 0]], {'t_count': 2, 'clifford_count': 3}], ['control: random t-count 2', [['sdg', 0], ['rz', 0, '1/4'], ['cx', 0]], {'t_count': 1, 'clifford_count': 2}], ['control: random t-count 3', [['rz', 0, '1/2'], ['rz', 0, '0'], ['t', 0]], {'t_count': 1, 'clifford_count': 1}], ['control: random t-count 4', [['ccx', 0, 1, 2]], {'t_count': 7, 'clifford_count': 8}], ['control: random t-count 6', [['ccx', 0, 1, 2], ['x', 0], ['x', 0], ['rz', 0, '0'], ['sdg', 0], ['t', 0], ['ccx', 0, 1, 2]], {'t_count': 15, 'clifford_count': 19}]], [['regression: random t-count 37', [['t', 0], ['rz', 0, '-1'], ['cx', 0], ['t', 0], ['rz', 0, '1/4'], ['rz', 0, '2'], ['tdg', 0]], {'t_count': 4, 'clifford_count': 2}], ['regression: random t-count 42', [['cx', 0], ['rz', 0, '2'], ['rz', 0, '-1'], ['rz', 0, '1/4'], ['rz', 0, '3/4'], ['tdg', 0]], {'t_count': 3, 'clifford_count': 2}], ['regression: random t-count 16', [['rz', 0, '3/4'], ['rz', 0, '-1'], ['tdg', 0], ['sdg', 0], ['rz', 0, '-2'], ['rz', 0, '3/2'], ['sdg', 0]], {'t_count': 2, 'clifford_count': 4}], ['control: random t-count 8', [['rz', 0, '-1/4'], ['ccx', 0, 1, 2], ['ccx', 0, 1, 2], ['ccx', 0, 1, 2], ['cx', 0]], {'t_count': 22, 'clifford_count': 25}], ['control: random t-count 9', [['rz', 0, '1/4']], {'t_count': 1, 'clifford_count': 0}], ['control: random t-count 10', [['ccx', 0, 1, 2], ['s', 0], ['ccx', 0, 1, 2], ['tdg', 0]], {'t_count': 15, 'clifford_count': 17}], ['control: random t-count 13', [['rz', 0, '-1/4'], ['rz', 0, '7/2'], ['rz', 0, '3/4'], ['s', 0]], {'t_count': 2, 'clifford_count': 2}]], [['regression: random t-count 45', [['s', 0], ['rz', 0, '7/2'], ['tdg', 0], ['tdg', 0], ['rz', 0, '-1/4'], ['rz', 0, '4'], ['rz', 0, '-2']], {'t_count': 3, 'clifford_count': 2}], ['regression: random t-count 46', [['rz', 0, '3/2'], ['rz', 0, '-1/4'], ['rz', 0, '4'], ['rz', 0, '-1'], ['t', 0]], {'t_count': 2, 'clifford_count': 2}], ['regression: random t-count 23', [['rz', 0, '-2'], ['tdg', 0], ['ccx', 0, 1, 2], ['t', 0], ['rz', 0, '4'], ['rz', 0, '-1']], {'t_count': 9, 'clifford_count': 9}], ['control: random t-count 14', [['sdg', 0]], {'t_count': 0, 'clifford_count': 1}], ['control: random t-count 15', [['ccx', 0, 1, 2], ['sdg', 0], ['t', 0], ['rz', 0, '3/2']], {'t_count': 8, 'clifford_count': 10}], ['control: random t-count 17', [['tdg', 0]], {'t_count': 1, 'clifford_count': 0}], ['control: random t-count 19', [['rz', 0, '3/4'], ['rz', 0, '-1/4'], ['rz', 0, '5/4']], {'t_count': 3, 'clifford_count': 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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(x):
    t = cliff = 0
    for idx, op in enumerate(x):
        name = op[0]
        if name in ('t', 'tdg'):
            t += 1
        elif name in ('h', 's', 'sdg', 'x', 'y', 'z', 'cx', 'cz', 'swap'):
            cliff += 1
        elif name == 'ccx':
            t += 7
            cliff += 8
        elif name == 'rz':
            a = Fraction(op[2]) % 1
            if a == 0:
                continue
            if (a * 2).denominator == 1:
                cliff += 1
            elif (a * 4).denominator == 1:
                t += 1
            else:
                return ['unsupported', idx]
        else:
            return ['unknown-gate', idx]
    return {'t_count': t, 'clifford_count': cliff}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: rz two pi', [['rz', 0, '2']], {'t_count': 0, 'clifford_count': 0}], ['regression: rz four pi', [['rz', 0, '4']], {'t_count': 0, 'clifford_count': 0}], ['repair check: rz pi is Z', [['rz', 0, '1']], {'t_count': 0, 'clifford_count': 1}], ['control: rz zero', [['rz', 0, '0']], {'t_count': 0, 'clifford_count': 0}], ['control: rz half pi is S', [['rz', 0, '1/2']], {'t_count': 0, 'clifford_count': 1}], ['control: rz quarter pi', [['rz', 0, '1/4']], {'t_count': 1, 'clifford_count': 0}], ['control: tdg', [['tdg', 0]], {'t_count': 1, 'clifford_count': 0}]], [['regression: random t-count 1', [['rz', 0, '-2'], ['ccx', 0, 1, 2], ['rz', 0, '1'], ['rz', 0, '1'], ['rz', 0, '0'], ['x', 0]], {'t_count': 7, 'clifford_count': 11}], ['regression: random t-count 16', [['rz', 0, '3/4'], ['rz', 0, '-1'], ['tdg', 0], ['sdg', 0], ['rz', 0, '-2'], ['rz', 0, '3/2'], ['sdg', 0]], {'t_count': 2, 'clifford_count': 4}], ['repair check: random t-count 5', [['ccx', 0, 1, 2], ['rz', 0, '1'], ['rz', 0, '5/4'], ['tdg', 0]], {'t_count': 9, 'clifford_count': 9}], ['control: toffoli', [['ccx', 0, 1, 2]], {'t_count': 7, 'clifford_count': 8}], ['control: unsupported angle', [['h', 0], ['rz', 0, '1/8']], ['unsupported', 1]], ['control: negative angles', [['rz', 0, '-1/4'], ['rz', 1, '-3/2']], {'t_count': 1, 'clifford_count': 1}], ['control: unknown gate', [['u3', 0]], ['unknown-gate', 0]]], [['regression: random t-count 23', [['rz', 0, '-2'], ['tdg', 0], ['ccx', 0, 1, 2], ['t', 0], ['rz', 0, '4'], ['rz', 0, '-1']], {'t_count': 9, 'clifford_count': 9}], ['regression: random t-count 31', [['rz', 0, '2'], ['h', 0], ['x', 0], ['x', 0], ['t', 0], ['rz', 0, '-2']], {'t_count': 1, 'clifford_count': 3}], ['repair check: random t-count 11', [['s', 0], ['rz', 0, '5/4'], ['rz', 0, '-1'], ['x', 0], ['t', 0]], {'t_count': 2, 'clifford_count': 3}], ['control: random t-count 2', [['sdg', 0], ['rz', 0, '1/4'], ['cx', 0]], {'t_count': 1, 'clifford_count': 2}], ['control: random t-count 3', [['rz', 0, '1/2'], ['rz', 0, '0'], ['t', 0]], {'t_count': 1, 'clifford_count': 1}], ['control: random t-count 4', [['ccx', 0, 1, 2]], {'t_count': 7, 'clifford_count': 8}], ['control: random t-count 6', [['ccx', 0, 1, 2], ['x', 0], ['x', 0], ['rz', 0, '0'], ['sdg', 0], ['t', 0], ['ccx', 0, 1, 2]], {'t_count': 15, 'clifford_count': 19}]], [['regression: random t-count 37', [['t', 0], ['rz', 0, '-1'], ['cx', 0], ['t', 0], ['rz', 0, '1/4'], ['rz', 0, '2'], ['tdg', 0]], {'t_count': 4, 'clifford_count': 2}], ['regression: random t-count 42', [['cx', 0], ['rz', 0, '2'], ['rz', 0, '-1'], ['rz', 0, '1/4'], ['rz', 0, '3/4'], ['tdg', 0]], {'t_count': 3, 'clifford_count': 2}], ['regression: random t-count 16', [['rz', 0, '3/4'], ['rz', 0, '-1'], ['tdg', 0], ['sdg', 0], ['rz', 0, '-2'], ['rz', 0, '3/2'], ['sdg', 0]], {'t_count': 2, 'clifford_count': 4}], ['control: random t-count 8', [['rz', 0, '-1/4'], ['ccx', 0, 1, 2], ['ccx', 0, 1, 2], ['ccx', 0, 1, 2], ['cx', 0]], {'t_count': 22, 'clifford_count': 25}], ['control: random t-count 9', [['rz', 0, '1/4']], {'t_count': 1, 'clifford_count': 0}], ['control: random t-count 10', [['ccx', 0, 1, 2], ['s', 0], ['ccx', 0, 1, 2], ['tdg', 0]], {'t_count': 15, 'clifford_count': 17}], ['control: random t-count 13', [['rz', 0, '-1/4'], ['rz', 0, '7/2'], ['rz', 0, '3/4'], ['s', 0]], {'t_count': 2, 'clifford_count': 2}]], [['regression: random t-count 45', [['s', 0], ['rz', 0, '7/2'], ['tdg', 0], ['tdg', 0], ['rz', 0, '-1/4'], ['rz', 0, '4'], ['rz', 0, '-2']], {'t_count': 3, 'clifford_count': 2}], ['regression: random t-count 46', [['rz', 0, '3/2'], ['rz', 0, '-1/4'], ['rz', 0, '4'], ['rz', 0, '-1'], ['t', 0]], {'t_count': 2, 'clifford_count': 2}], ['regression: random t-count 23', [['rz', 0, '-2'], ['tdg', 0], ['ccx', 0, 1, 2], ['t', 0], ['rz', 0, '4'], ['rz', 0, '-1']], {'t_count': 9, 'clifford_count': 9}], ['control: random t-count 14', [['sdg', 0]], {'t_count': 0, 'clifford_count': 1}], ['control: random t-count 15', [['ccx', 0, 1, 2], ['sdg', 0], ['t', 0], ['rz', 0, '3/2']], {'t_count': 8, 'clifford_count': 10}], ['control: random t-count 17', [['tdg', 0]], {'t_count': 1, 'clifford_count': 0}], ['control: random t-count 19', [['rz', 0, '3/4'], ['rz', 0, '-1/4'], ['rz', 0, '5/4']], {'t_count': 3, 'clifford_count': 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)

prompt:
rz(4pi) counts as a Clifford gate instead of being skipped.

Input a gate list. t and tdg count one T each; h, s, sdg, x, y, z, cx, cz, swap count one Clifford; ccx costs 7 T and 8 Clifford; ["rz", q, a] with a in units of pi reduced mod 2 is skipped if 0, Clifford if a multiple of 1/2, one T if an odd multiple of 1/4, else ["unsupported", index]; other names give ["unknown-gate", index]. Return {"t_count", "clifford_count"}.

split: open-access


meaning: Fixture-count band, not measured model difficulty

deps: stdlib

prompt:
Outputs at the start of each block ignore samples from the previous block, producing edge glitches.

Input [taps, blocks] of integers. Filter the concatenated stream with y[n] = sum_k taps[k] x[n-k] (zero initial history) while processing block by block; return the outputs grouped per input block.

split: open-access


prompt:
Every output equals taps[0] times the current sample; past samples never enter the delay line.

Input [taps, blocks] of integers. Filter the concatenated stream with y[n] = sum_k taps[k] x[n-k] (zero initial history) while processing block by block; return the outputs grouped per input block.

split: open-access


prompt:
An asymmetric impulse response comes out time-reversed.

Input [taps, blocks] of integers. Filter the concatenated stream with y[n] = sum_k taps[k] x[n-k] (zero initial history) while processing block by block; return the outputs grouped per input block.

split: open-access


prompt:
A filter specified with a1 = -1/2 (a decaying pole at +1/2) produces an alternating impulse response.

Input [[b0, b1, b2, a0, a1, a2], samples]; coefficients are rational strings, normalized by a0 ("a0-zero" if a0 == 0). y[n] = b0 x[n] + b1 x[n-1] + b2 x[n-2] - a1 y[n-1] - a2 y[n-2] with zero initial state; return outputs as exact fraction strings.

split: open-access


prompt:
The x[n-2] tap always equals x[n-1], so b2 acts on the wrong sample.

Input [[b0, b1, b2, a0, a1, a2], samples]; coefficients are rational strings, normalized by a0 ("a0-zero" if a0 == 0). y[n] = b0 x[n] + b1 x[n-1] + b2 x[n-2] - a1 y[n-1] - a2 y[n-2] with zero initial state; return outputs as exact fraction strings.

split: open-access


prompt:
With a0 = 2 the poles are twice as strong as specified and the filter can blow up.

Input [[b0, b1, b2, a0, a1, a2], samples]; coefficients are rational strings, normalized by a0 ("a0-zero" if a0 == 0). y[n] = b0 x[n] + b1 x[n-1] + b2 x[n-2] - a1 y[n-1] - a2 y[n-2] with zero initial state; return outputs as exact fraction strings.

split: open-access


prompt:
A pure second-order feedback filter never feels its a2 term correctly and the impulse response rings at the wrong rate.

Input [[b0, b1, b2, a0, a1, a2], samples]; coefficients are rational strings, normalized by a0 ("a0-zero" if a0 == 0). y[n] = b0 x[n] + b1 x[n-1] + b2 x[n-2] - a1 y[n-1] - a2 y[n-2] with zero initial state; return outputs as exact fraction strings.

split: open-access


prompt:
The impulse response loses its two-sample memory: s1 uses the freshly computed s2 from the same sample.

Input [[b0, b1, b2, a1, a2], samples, prime] (a0 = 1). Transposed direct form II: y = b0 x + s1; s1 = b1 x - a1 y + s2; s2 = b2 x - a2 y. If prime and samples exist, initialize s1, s2 to the steady state for a constant input equal to the first sample (y_ss = x0 (b0+b1+b2)/(1+a1+a2), "dc-pole" if the denominator is 0). Return exact fraction strings.

split: open-access


prompt:
The first output sample skips b1 contributions and the response is delayed by a sample.

Input [[b0, b1, b2, a1, a2], samples, prime] (a0 = 1). Transposed direct form II: y = b0 x + s1; s1 = b1 x - a1 y + s2; s2 = b2 x - a2 y. If prime and samples exist, initialize s1, s2 to the steady state for a constant input equal to the first sample (y_ss = x0 (b0+b1+b2)/(1+a1+a2), "dc-pole" if the denominator is 0). Return exact fraction strings.

split: open-access


prompt:
Second-order feedback has the wrong sign, e.g. a stable resonance diverges.

Input [[b0, b1, b2, a1, a2], samples, prime] (a0 = 1). Transposed direct form II: y = b0 x + s1; s1 = b1 x - a1 y + s2; s2 = b2 x - a2 y. If prime and samples exist, initialize s1, s2 to the steady state for a constant input equal to the first sample (y_ss = x0 (b0+b1+b2)/(1+a1+a2), "dc-pole" if the denominator is 0). Return exact fraction strings.

split: open-access


prompt:
A primed lowpass fed a constant still shows a transient on its first sample.

Input [[b0, b1, b2, a1, a2], samples, prime] (a0 = 1). Transposed direct form II: y = b0 x + s1; s1 = b1 x - a1 y + s2; s2 = b2 x - a2 y. If prime and samples exist, initialize s1, s2 to the steady state for a constant input equal to the first sample (y_ss = x0 (b0+b1+b2)/(1+a1+a2), "dc-pole" if the denominator is 0). Return exact fraction strings.

split: open-access


prompt:
Primed outputs start at the wrong level and then settle, a visible start-up step.

Input [[b0, b1, b2, a1, a2], samples, prime] (a0 = 1). Transposed direct form II: y = b0 x + s1; s1 = b1 x - a1 y + s2; s2 = b2 x - a2 y. If prime and samples exist, initialize s1, s2 to the steady state for a constant input equal to the first sample (y_ss = x0 (b0+b1+b2)/(1+a1+a2), "dc-pole" if the denominator is 0). Return exact fraction strings.

split: open-access


prompt:
The first full window contains W+1 samples summed but divided by W.

Input [W, samples]; causal moving average using a running sum. During warm-up divide by the number of samples seen (min(n+1, W)). Return exact fraction strings; "bad-window" if W < 1.

split: open-access


prompt:
The first W-1 outputs are biased toward zero.

Input [W, samples]; causal moving average using a running sum. During warm-up divide by the number of samples seen (min(n+1, W)). Return exact fraction strings; "bad-window" if W < 1.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(x):
    k, mode, xs = x
    if k < 1 or k % 2 == 0:
        return 'bad-window'
    n = len(xs)
    h = k // 2
    out = []
    for i in range(n):
        vals = []
        for j in range(i - h, i + h + 1):
            if 0 <= j < n:
                vals.append(xs[j])
            elif mode == 'zero':
                vals.append(0)
            elif mode == 'replicate':
                vals.append(xs[min(max(j, 0), n - 1)])
            elif mode == 'reflect':
                jj = -j - 1 if j < 0 else 2 * n - 1 - j
                vals.append(xs[jj])
        out.append(str(Fraction(sum(vals), len(vals))))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: reflect edges', [3, 'reflect', [1, 5, 2, 8]], ['11/3', '8/3', '5', '4']], ['regression: reflect wide', [5, 'reflect', [4, 0, 2, 6, 1]], ['8/5', '12/5', '13/5', '3', '17/5']], ['regression: random centered 3', [3, 'reflect', [-2, 3, 6]], ['4/3', '7/3', '4']], ['control: zero padding', [3, 'zero', [3, 3, 3]], ['2', '3', '2']], ['control: shrink edges', [3, 'shrink', [2, 4, 6]], ['3', '4', '5']], ['control: even window', [2, 'shrink', [1, 2, 3]], 'bad-window'], ['control: even window four', [4, 'zero', [1, 2, 3, 4]], 'bad-window']], [['regression: random centered 10', [5, 'reflect', [-1, -5, 8]], ['1', '-8/5', '-4/5']], ['regression: random centered 25', [3, 'reflect', [8, 5, 5, 3, -4]], ['6', '6', '13/3', '4/3', '2/3']], ['regression: random centered 3', [3, 'reflect', [-2, 3, 6]], ['4/3', '7/3', '4']], ['control: replicate', [5, 'replicate', [1, 2, 3, 10]], ['8/5', '17/5', '26/5', '7']], ['control: random centered 0', [3, 'zero', [6, -1, 8]], ['5/3', '13/3', '7/3']], ['control: random centered 1', [3, 'shrink', [-4, 0, 9]], ['-2', '5/3', '9/2']], ['control: random centered 2', [5, 'replicate', [3, 1, 0, 6, 1, 3]], ['2', '13/5', '11/5', '11/5', '13/5', '16/5']]], [['regression: random centered 35', [5, 'reflect', [8, -3, -3, 0, 2, 6, 0]], ['-4/5', '-1/5', '4/5', '2/5', '1', '14/5', '16/5']], ['regression: random centered 39', [3, 'reflect', [6, 4, -4, -3, 0]], ['14/3', '2', '-1', '-7/3', '-2']], ['regression: random centered 25', [3, 'reflect', [8, 5, 5, 3, -4]], ['6', '6', '13/3', '4/3', '2/3']], ['control: random centered 4', [5, 'zero', [-5, 1, -2]], ['-6/5', '-6/5', '-6/5']], ['control: random centered 5', [5, 'zero', [-2, 7, -2]], ['3/5', '3/5', '3/5']], ['control: random centered 6', [3, 'shrink', [0, 8, -5, -4, 8, 9]], ['4', '1', '-1/3', '-1/3', '13/3', '17/2']], ['control: random centered 7', [3, 'shrink', [0, 4, -2, -2, 2, -3]], ['2', '2/3', '0', '-2/3', '-1', '-1/2']]], [['regression: random centered 44', [3, 'reflect', [3, -5, 0, 6, 1, 3]], ['-7/3', '-2/3', '1/3', '7/3', '10/3', '5/3']], ['regression: random centered 45', [3, 'reflect', [6, -1, -1, -1, 9, -5, 1]], ['4/3', '4/3', '-1', '7/3', '1', '5/3', '-3']], ['regression: random centered 35', [5, 'reflect', [8, -3, -3, 0, 2, 6, 0]], ['-4/5', '-1/5', '4/5', '2/5', '1', '14/5', '16/5']], ['control: random centered 8', [3, 'shrink', [3, -3, 2, -2]], ['0', '2/3', '-1', '0']], ['control: random centered 9', [3, 'replicate', [8, 2, 4, 4, 6]], ['6', '14/3', '10/3', '14/3', '16/3']], ['control: random centered 11', [3, 'shrink', [-1, -3, -4, 4, 1]], ['-2', '-8/3', '-1', '1/3', '5/2']], ['control: random centered 12', [5, 'replicate', [-4, 2, -1, 3, 0, -4]], ['-11/5', '-4/5', '0', '0', '-6/5', '-9/5']]], [['regression: reflect wide', [5, 'reflect', [4, 0, 2, 6, 1]], ['8/5', '12/5', '13/5', '3', '17/5']], ['regression: random centered 3', [3, 'reflect', [-2, 3, 6]], ['4/3', '7/3', '4']], ['regression: random centered 42', [3, 'reflect', [-5, 5, 0, -5, 1, 4, 6]], ['5/3', '0', '0', '-4/3', '0', '11/3', '14/3']], ['control: random centered 13', [3, 'replicate', [3, 1, 2, 4, -3]], ['7/3', '2', '7/3', '1', '-2/3']], ['control: random centered 14', [1, 'zero', [7, 5, 6, 0, 8]], ['7', '5', '6', '0', '8']], ['control: random centered 15', [3, 'shrink', [3, 9, 5, -5, -5, 0]], ['6', '17/3', '3', '-5/3', '-10/3', '-5/2']], ['control: random centered 16', [5, 'shrink', [2, 3, -1, 3]], ['4/3', '7/4', '7/4', '5/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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(x):
    k, mode, xs = x
    if k < 1 or k % 2 == 0:
        return 'bad-window'
    n = len(xs)
    h = k // 2
    out = []
    for i in range(n):
        vals = []
        for j in range(i - h, i + h + 1):
            if 0 <= j < n:
                vals.append(xs[j])
            elif mode == 'zero':
                vals.append(0)
            elif mode == 'replicate':
                vals.append(xs[min(max(j, 0), n - 1)])
            elif mode == 'reflect':
                jj = -j if j < 0 else 2 * n - 1 - j
                vals.append(xs[jj])
        out.append(str(Fraction(sum(vals), len(vals))))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: reflect edges', [3, 'reflect', [1, 5, 2, 8]], ['11/3', '8/3', '5', '4']], ['regression: reflect wide', [5, 'reflect', [4, 0, 2, 6, 1]], ['8/5', '12/5', '13/5', '3', '17/5']], ['regression: random centered 3', [3, 'reflect', [-2, 3, 6]], ['4/3', '7/3', '4']], ['control: zero padding', [3, 'zero', [3, 3, 3]], ['2', '3', '2']], ['control: shrink edges', [3, 'shrink', [2, 4, 6]], ['3', '4', '5']], ['control: even window', [2, 'shrink', [1, 2, 3]], 'bad-window'], ['control: even window four', [4, 'zero', [1, 2, 3, 4]], 'bad-window']], [['regression: random centered 10', [5, 'reflect', [-1, -5, 8]], ['1', '-8/5', '-4/5']], ['regression: random centered 25', [3, 'reflect', [8, 5, 5, 3, -4]], ['6', '6', '13/3', '4/3', '2/3']], ['regression: random centered 3', [3, 'reflect', [-2, 3, 6]], ['4/3', '7/3', '4']], ['control: replicate', [5, 'replicate', [1, 2, 3, 10]], ['8/5', '17/5', '26/5', '7']], ['control: random centered 0', [3, 'zero', [6, -1, 8]], ['5/3', '13/3', '7/3']], ['control: random centered 1', [3, 'shrink', [-4, 0, 9]], ['-2', '5/3', '9/2']], ['control: random centered 2', [5, 'replicate', [3, 1, 0, 6, 1, 3]], ['2', '13/5', '11/5', '11/5', '13/5', '16/5']]], [['regression: random centered 35', [5, 'reflect', [8, -3, -3, 0, 2, 6, 0]], ['-4/5', '-1/5', '4/5', '2/5', '1', '14/5', '16/5']], ['regression: random centered 39', [3, 'reflect', [6, 4, -4, -3, 0]], ['14/3', '2', '-1', '-7/3', '-2']], ['regression: random centered 25', [3, 'reflect', [8, 5, 5, 3, -4]], ['6', '6', '13/3', '4/3', '2/3']], ['control: random centered 4', [5, 'zero', [-5, 1, -2]], ['-6/5', '-6/5', '-6/5']], ['control: random centered 5', [5, 'zero', [-2, 7, -2]], ['3/5', '3/5', '3/5']], ['control: random centered 6', [3, 'shrink', [0, 8, -5, -4, 8, 9]], ['4', '1', '-1/3', '-1/3', '13/3', '17/2']], ['control: random centered 7', [3, 'shrink', [0, 4, -2, -2, 2, -3]], ['2', '2/3', '0', '-2/3', '-1', '-1/2']]], [['regression: random centered 44', [3, 'reflect', [3, -5, 0, 6, 1, 3]], ['-7/3', '-2/3', '1/3', '7/3', '10/3', '5/3']], ['regression: random centered 45', [3, 'reflect', [6, -1, -1, -1, 9, -5, 1]], ['4/3', '4/3', '-1', '7/3', '1', '5/3', '-3']], ['regression: random centered 35', [5, 'reflect', [8, -3, -3, 0, 2, 6, 0]], ['-4/5', '-1/5', '4/5', '2/5', '1', '14/5', '16/5']], ['control: random centered 8', [3, 'shrink', [3, -3, 2, -2]], ['0', '2/3', '-1', '0']], ['control: random centered 9', [3, 'replicate', [8, 2, 4, 4, 6]], ['6', '14/3', '10/3', '14/3', '16/3']], ['control: random centered 11', [3, 'shrink', [-1, -3, -4, 4, 1]], ['-2', '-8/3', '-1', '1/3', '5/2']], ['control: random centered 12', [5, 'replicate', [-4, 2, -1, 3, 0, -4]], ['-11/5', '-4/5', '0', '0', '-6/5', '-9/5']]], [['regression: reflect wide', [5, 'reflect', [4, 0, 2, 6, 1]], ['8/5', '12/5', '13/5', '3', '17/5']], ['regression: random centered 3', [3, 'reflect', [-2, 3, 6]], ['4/3', '7/3', '4']], ['regression: random centered 42', [3, 'reflect', [-5, 5, 0, -5, 1, 4, 6]], ['5/3', '0', '0', '-4/3', '0', '11/3', '14/3']], ['control: random centered 13', [3, 'replicate', [3, 1, 2, 4, -3]], ['7/3', '2', '7/3', '1', '-2/3']], ['control: random centered 14', [1, 'zero', [7, 5, 6, 0, 8]], ['7', '5', '6', '0', '8']], ['control: random centered 15', [3, 'shrink', [3, 9, 5, -5, -5, 0]], ['6', '17/3', '3', '-5/3', '-10/3', '-5/2']], ['control: random centered 16', [5, 'shrink', [2, 3, -1, 3]], ['4/3', '7/4', '7/4', '5/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)

prompt:
At the edges the first sample is counted twice, over-weighting endpoints.

Input [K, mode, samples]; K must be odd ("bad-window"). Centered moving average over indices i-K//2..i+K//2 with edge mode "shrink" (average available samples), "zero" (missing samples count as 0, divide by K), "replicate" (clamp index) or "reflect" (mirror without repeating the edge: -1 -> 1, n -> n-2). Return exact fraction strings.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(x):
    k, mode, xs = x
    if k < 1 or k % 2 == 0:
        return 'bad-window'
    n = len(xs)
    h = k // 2
    out = []
    for i in range(n):
        vals = []
        for j in range(i - h, i + h + 1):
            if 0 <= j < n:
                vals.append(xs[j])
            elif mode == 'zero':
                pass
            elif mode == 'replicate':
                vals.append(xs[min(max(j, 0), n - 1)])
            elif mode == 'reflect':
                jj = -j if j < 0 else 2 * (n - 1) - j
                vals.append(xs[jj])
        out.append(str(Fraction(sum(vals), len(vals))))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: zero padding', [3, 'zero', [3, 3, 3]], ['2', '3', '2']], ['regression: random centered 0', [3, 'zero', [6, -1, 8]], ['5/3', '13/3', '7/3']], ['regression: random centered 4', [5, 'zero', [-5, 1, -2]], ['-6/5', '-6/5', '-6/5']], ['control: reflect edges', [3, 'reflect', [1, 5, 2, 8]], ['11/3', '8/3', '5', '4']], ['control: reflect wide', [5, 'reflect', [4, 0, 2, 6, 1]], ['8/5', '12/5', '13/5', '3', '17/5']], ['control: shrink edges', [3, 'shrink', [2, 4, 6]], ['3', '4', '5']], ['control: even window', [2, 'shrink', [1, 2, 3]], 'bad-window']], [['regression: random centered 5', [5, 'zero', [-2, 7, -2]], ['3/5', '3/5', '3/5']], ['regression: random centered 27', [5, 'zero', [-1, -3, -3]], ['-7/5', '-7/5', '-7/5']], ['regression: random centered 4', [5, 'zero', [-5, 1, -2]], ['-6/5', '-6/5', '-6/5']], ['control: even window four', [4, 'zero', [1, 2, 3, 4]], 'bad-window'], ['control: replicate', [5, 'replicate', [1, 2, 3, 10]], ['8/5', '17/5', '26/5', '7']], ['control: random centered 1', [3, 'shrink', [-4, 0, 9]], ['-2', '5/3', '9/2']], ['control: random centered 2', [5, 'replicate', [3, 1, 0, 6, 1, 3]], ['2', '13/5', '11/5', '11/5', '13/5', '16/5']]], [['regression: random centered 0', [3, 'zero', [6, -1, 8]], ['5/3', '13/3', '7/3']], ['regression: random centered 4', [5, 'zero', [-5, 1, -2]], ['-6/5', '-6/5', '-6/5']], ['regression: random centered 27', [5, 'zero', [-1, -3, -3]], ['-7/5', '-7/5', '-7/5']], ['control: random centered 3', [3, 'reflect', [-2, 3, 6]], ['4/3', '7/3', '4']], ['control: random centered 6', [3, 'shrink', [0, 8, -5, -4, 8, 9]], ['4', '1', '-1/3', '-1/3', '13/3', '17/2']], ['control: random centered 7', [3, 'shrink', [0, 4, -2, -2, 2, -3]], ['2', '2/3', '0', '-2/3', '-1', '-1/2']], ['control: random centered 8', [3, 'shrink', [3, -3, 2, -2]], ['0', '2/3', '-1', '0']]], [['regression: random centered 27', [5, 'zero', [-1, -3, -3]], ['-7/5', '-7/5', '-7/5']], ['regression: zero padding', [3, 'zero', [3, 3, 3]], ['2', '3', '2']], ['regression: random centered 0', [3, 'zero', [6, -1, 8]], ['5/3', '13/3', '7/3']], ['control: random centered 9', [3, 'replicate', [8, 2, 4, 4, 6]], ['6', '14/3', '10/3', '14/3', '16/3']], ['control: random centered 10', [5, 'reflect', [-1, -5, 8]], ['1', '-8/5', '-4/5']], ['control: random centered 11', [3, 'shrink', [-1, -3, -4, 4, 1]], ['-2', '-8/3', '-1', '1/3', '5/2']], ['control: random centered 12', [5, 'replicate', [-4, 2, -1, 3, 0, -4]], ['-11/5', '-4/5', '0', '0', '-6/5', '-9/5']]], [['regression: random centered 4', [5, 'zero', [-5, 1, -2]], ['-6/5', '-6/5', '-6/5']], ['regression: random centered 5', [5, 'zero', [-2, 7, -2]], ['3/5', '3/5', '3/5']], ['regression: random centered 27', [5, 'zero', [-1, -3, -3]], ['-7/5', '-7/5', '-7/5']], ['control: random centered 13', [3, 'replicate', [3, 1, 2, 4, -3]], ['7/3', '2', '7/3', '1', '-2/3']], ['control: random centered 14', [1, 'zero', [7, 5, 6, 0, 8]], ['7', '5', '6', '0', '8']], ['control: random centered 15', [3, 'shrink', [3, 9, 5, -5, -5, 0]], ['6', '17/3', '3', '-5/3', '-10/3', '-5/2']], ['control: random centered 16', [5, 'shrink', [2, 3, -1, 3]], ['4/3', '7/4', '7/4', '5/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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(x):
    k, mode, xs = x
    if k < 1 or k % 2 == 0:
        return 'bad-window'
    n = len(xs)
    h = k // 2
    out = []
    for i in range(n):
        vals = []
        for j in range(i - h, i + h + 1):
            if 0 <= j < n:
                vals.append(xs[j])
            elif mode == 'zero':
                if j < 0:
                    vals.append(0)
            elif mode == 'replicate':
                vals.append(xs[min(max(j, 0), n - 1)])
            elif mode == 'reflect':
                jj = -j if j < 0 else 2 * (n - 1) - j
                vals.append(xs[jj])
        out.append(str(Fraction(sum(vals), len(vals))))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: zero padding', [3, 'zero', [3, 3, 3]], ['2', '3', '2']], ['regression: random centered 0', [3, 'zero', [6, -1, 8]], ['5/3', '13/3', '7/3']], ['regression: random centered 4', [5, 'zero', [-5, 1, -2]], ['-6/5', '-6/5', '-6/5']], ['control: reflect edges', [3, 'reflect', [1, 5, 2, 8]], ['11/3', '8/3', '5', '4']], ['control: reflect wide', [5, 'reflect', [4, 0, 2, 6, 1]], ['8/5', '12/5', '13/5', '3', '17/5']], ['control: shrink edges', [3, 'shrink', [2, 4, 6]], ['3', '4', '5']], ['control: even window', [2, 'shrink', [1, 2, 3]], 'bad-window']], [['regression: random centered 5', [5, 'zero', [-2, 7, -2]], ['3/5', '3/5', '3/5']], ['regression: random centered 27', [5, 'zero', [-1, -3, -3]], ['-7/5', '-7/5', '-7/5']], ['regression: random centered 4', [5, 'zero', [-5, 1, -2]], ['-6/5', '-6/5', '-6/5']], ['control: even window four', [4, 'zero', [1, 2, 3, 4]], 'bad-window'], ['control: replicate', [5, 'replicate', [1, 2, 3, 10]], ['8/5', '17/5', '26/5', '7']], ['control: random centered 1', [3, 'shrink', [-4, 0, 9]], ['-2', '5/3', '9/2']], ['control: random centered 2', [5, 'replicate', [3, 1, 0, 6, 1, 3]], ['2', '13/5', '11/5', '11/5', '13/5', '16/5']]], [['regression: random centered 0', [3, 'zero', [6, -1, 8]], ['5/3', '13/3', '7/3']], ['regression: random centered 4', [5, 'zero', [-5, 1, -2]], ['-6/5', '-6/5', '-6/5']], ['regression: random centered 27', [5, 'zero', [-1, -3, -3]], ['-7/5', '-7/5', '-7/5']], ['control: random centered 3', [3, 'reflect', [-2, 3, 6]], ['4/3', '7/3', '4']], ['control: random centered 6', [3, 'shrink', [0, 8, -5, -4, 8, 9]], ['4', '1', '-1/3', '-1/3', '13/3', '17/2']], ['control: random centered 7', [3, 'shrink', [0, 4, -2, -2, 2, -3]], ['2', '2/3', '0', '-2/3', '-1', '-1/2']], ['control: random centered 8', [3, 'shrink', [3, -3, 2, -2]], ['0', '2/3', '-1', '0']]], [['regression: random centered 27', [5, 'zero', [-1, -3, -3]], ['-7/5', '-7/5', '-7/5']], ['regression: zero padding', [3, 'zero', [3, 3, 3]], ['2', '3', '2']], ['regression: random centered 0', [3, 'zero', [6, -1, 8]], ['5/3', '13/3', '7/3']], ['control: random centered 9', [3, 'replicate', [8, 2, 4, 4, 6]], ['6', '14/3', '10/3', '14/3', '16/3']], ['control: random centered 10', [5, 'reflect', [-1, -5, 8]], ['1', '-8/5', '-4/5']], ['control: random centered 11', [3, 'shrink', [-1, -3, -4, 4, 1]], ['-2', '-8/3', '-1', '1/3', '5/2']], ['control: random centered 12', [5, 'replicate', [-4, 2, -1, 3, 0, -4]], ['-11/5', '-4/5', '0', '0', '-6/5', '-9/5']]], [['regression: random centered 4', [5, 'zero', [-5, 1, -2]], ['-6/5', '-6/5', '-6/5']], ['regression: random centered 5', [5, 'zero', [-2, 7, -2]], ['3/5', '3/5', '3/5']], ['regression: random centered 27', [5, 'zero', [-1, -3, -3]], ['-7/5', '-7/5', '-7/5']], ['control: random centered 13', [3, 'replicate', [3, 1, 2, 4, -3]], ['7/3', '2', '7/3', '1', '-2/3']], ['control: random centered 14', [1, 'zero', [7, 5, 6, 0, 8]], ['7', '5', '6', '0', '8']], ['control: random centered 15', [3, 'shrink', [3, 9, 5, -5, -5, 0]], ['6', '17/3', '3', '-5/3', '-10/3', '-5/2']], ['control: random centered 16', [5, 'shrink', [2, 3, -1, 3]], ['4/3', '7/4', '7/4', '5/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)

prompt:
In zero mode the edge outputs equal the shrink-mode averages instead of being pulled toward zero.

Input [K, mode, samples]; K must be odd ("bad-window"). Centered moving average over indices i-K//2..i+K//2 with edge mode "shrink" (average available samples), "zero" (missing samples count as 0, divide by K), "replicate" (clamp index) or "reflect" (mirror without repeating the edge: -1 -> 1, n -> n-2). Return exact fraction strings.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(x):
    k, mode, xs = x
    if k < 1:
        return 'bad-window'
    n = len(xs)
    h = k // 2
    out = []
    for i in range(n):
        vals = []
        for j in range(i - h, i + h + 1):
            if 0 <= j < n:
                vals.append(xs[j])
            elif mode == 'zero':
                vals.append(0)
            elif mode == 'replicate':
                vals.append(xs[min(max(j, 0), n - 1)])
            elif mode == 'reflect':
                jj = -j if j < 0 else 2 * (n - 1) - j
                vals.append(xs[jj])
        out.append(str(Fraction(sum(vals), len(vals))))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: even window', [2, 'shrink', [1, 2, 3]], 'bad-window'], ['regression: even window four', [4, 'zero', [1, 2, 3, 4]], 'bad-window'], ['control: reflect edges', [3, 'reflect', [1, 5, 2, 8]], ['11/3', '8/3', '5', '4']], ['control: reflect wide', [5, 'reflect', [4, 0, 2, 6, 1]], ['8/5', '12/5', '13/5', '3', '17/5']], ['control: zero padding', [3, 'zero', [3, 3, 3]], ['2', '3', '2']], ['control: shrink edges', [3, 'shrink', [2, 4, 6]], ['3', '4', '5']]], [['regression: even window four', [4, 'zero', [1, 2, 3, 4]], 'bad-window'], ['regression: even window', [2, 'shrink', [1, 2, 3]], 'bad-window'], ['control: replicate', [5, 'replicate', [1, 2, 3, 10]], ['8/5', '17/5', '26/5', '7']], ['control: random centered 0', [3, 'zero', [6, -1, 8]], ['5/3', '13/3', '7/3']], ['control: random centered 1', [3, 'shrink', [-4, 0, 9]], ['-2', '5/3', '9/2']], ['control: random centered 2', [5, 'replicate', [3, 1, 0, 6, 1, 3]], ['2', '13/5', '11/5', '11/5', '13/5', '16/5']]], [['regression: even window', [2, 'shrink', [1, 2, 3]], 'bad-window'], ['regression: even window four', [4, 'zero', [1, 2, 3, 4]], 'bad-window'], ['control: random centered 3', [3, 'reflect', [-2, 3, 6]], ['4/3', '7/3', '4']], ['control: random centered 4', [5, 'zero', [-5, 1, -2]], ['-6/5', '-6/5', '-6/5']], ['control: random centered 5', [5, 'zero', [-2, 7, -2]], ['3/5', '3/5', '3/5']], ['control: random centered 6', [3, 'shrink', [0, 8, -5, -4, 8, 9]], ['4', '1', '-1/3', '-1/3', '13/3', '17/2']]], [['regression: even window four', [4, 'zero', [1, 2, 3, 4]], 'bad-window'], ['regression: even window', [2, 'shrink', [1, 2, 3]], 'bad-window'], ['control: random centered 7', [3, 'shrink', [0, 4, -2, -2, 2, -3]], ['2', '2/3', '0', '-2/3', '-1', '-1/2']], ['control: random centered 8', [3, 'shrink', [3, -3, 2, -2]], ['0', '2/3', '-1', '0']], ['control: random centered 9', [3, 'replicate', [8, 2, 4, 4, 6]], ['6', '14/3', '10/3', '14/3', '16/3']], ['control: random centered 10', [5, 'reflect', [-1, -5, 8]], ['1', '-8/5', '-4/5']]], [['regression: even window', [2, 'shrink', [1, 2, 3]], 'bad-window'], ['regression: even window four', [4, 'zero', [1, 2, 3, 4]], 'bad-window'], ['control: random centered 11', [3, 'shrink', [-1, -3, -4, 4, 1]], ['-2', '-8/3', '-1', '1/3', '5/2']], ['control: random centered 12', [5, 'replicate', [-4, 2, -1, 3, 0, -4]], ['-11/5', '-4/5', '0', '0', '-6/5', '-9/5']], ['control: random centered 13', [3, 'replicate', [3, 1, 2, 4, -3]], ['7/3', '2', '7/3', '1', '-2/3']], ['control: random centered 14', [1, 'zero', [7, 5, 6, 0, 8]], ['7', '5', '6', '0', '8']]]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(x):
    k, mode, xs = x
    if k < 1 or k % 2 == 0 and k > 2:
        return 'bad-window'
    n = len(xs)
    h = k // 2
    out = []
    for i in range(n):
        vals = []
        for j in range(i - h, i + h + 1):
            if 0 <= j < n:
                vals.append(xs[j])
            elif mode == 'zero':
                vals.append(0)
            elif mode == 'replicate':
                vals.append(xs[min(max(j, 0), n - 1)])
            elif mode == 'reflect':
                jj = -j if j < 0 else 2 * (n - 1) - j
                vals.append(xs[jj])
        out.append(str(Fraction(sum(vals), len(vals))))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: even window', [2, 'shrink', [1, 2, 3]], 'bad-window'], ['regression: even window four', [4, 'zero', [1, 2, 3, 4]], 'bad-window'], ['control: reflect edges', [3, 'reflect', [1, 5, 2, 8]], ['11/3', '8/3', '5', '4']], ['control: reflect wide', [5, 'reflect', [4, 0, 2, 6, 1]], ['8/5', '12/5', '13/5', '3', '17/5']], ['control: zero padding', [3, 'zero', [3, 3, 3]], ['2', '3', '2']], ['control: shrink edges', [3, 'shrink', [2, 4, 6]], ['3', '4', '5']]], [['regression: even window four', [4, 'zero', [1, 2, 3, 4]], 'bad-window'], ['regression: even window', [2, 'shrink', [1, 2, 3]], 'bad-window'], ['control: replicate', [5, 'replicate', [1, 2, 3, 10]], ['8/5', '17/5', '26/5', '7']], ['control: random centered 0', [3, 'zero', [6, -1, 8]], ['5/3', '13/3', '7/3']], ['control: random centered 1', [3, 'shrink', [-4, 0, 9]], ['-2', '5/3', '9/2']], ['control: random centered 2', [5, 'replicate', [3, 1, 0, 6, 1, 3]], ['2', '13/5', '11/5', '11/5', '13/5', '16/5']]], [['regression: even window', [2, 'shrink', [1, 2, 3]], 'bad-window'], ['regression: even window four', [4, 'zero', [1, 2, 3, 4]], 'bad-window'], ['control: random centered 3', [3, 'reflect', [-2, 3, 6]], ['4/3', '7/3', '4']], ['control: random centered 4', [5, 'zero', [-5, 1, -2]], ['-6/5', '-6/5', '-6/5']], ['control: random centered 5', [5, 'zero', [-2, 7, -2]], ['3/5', '3/5', '3/5']], ['control: random centered 6', [3, 'shrink', [0, 8, -5, -4, 8, 9]], ['4', '1', '-1/3', '-1/3', '13/3', '17/2']]], [['regression: even window four', [4, 'zero', [1, 2, 3, 4]], 'bad-window'], ['regression: even window', [2, 'shrink', [1, 2, 3]], 'bad-window'], ['control: random centered 7', [3, 'shrink', [0, 4, -2, -2, 2, -3]], ['2', '2/3', '0', '-2/3', '-1', '-1/2']], ['control: random centered 8', [3, 'shrink', [3, -3, 2, -2]], ['0', '2/3', '-1', '0']], ['control: random centered 9', [3, 'replicate', [8, 2, 4, 4, 6]], ['6', '14/3', '10/3', '14/3', '16/3']], ['control: random centered 10', [5, 'reflect', [-1, -5, 8]], ['1', '-8/5', '-4/5']]], [['regression: even window', [2, 'shrink', [1, 2, 3]], 'bad-window'], ['regression: even window four', [4, 'zero', [1, 2, 3, 4]], 'bad-window'], ['control: random centered 11', [3, 'shrink', [-1, -3, -4, 4, 1]], ['-2', '-8/3', '-1', '1/3', '5/2']], ['control: random centered 12', [5, 'replicate', [-4, 2, -1, 3, 0, -4]], ['-11/5', '-4/5', '0', '0', '-6/5', '-9/5']], ['control: random centered 13', [3, 'replicate', [3, 1, 2, 4, -3]], ['7/3', '2', '7/3', '1', '-2/3']], ['control: random centered 14', [1, 'zero', [7, 5, 6, 0, 8]], ['7', '5', '6', '0', '8']]]]
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)

prompt:
K = 2 silently produces a three-sample window instead of "bad-window".

Input [K, mode, samples]; K must be odd ("bad-window"). Centered moving average over indices i-K//2..i+K//2 with edge mode "shrink" (average available samples), "zero" (missing samples count as 0, divide by K), "replicate" (clamp index) or "reflect" (mirror without repeating the edge: -1 -> 1, n -> n-2). Return exact fraction strings.

split: open-access


prompt:
The decimator output lags a full block behind and includes a sample from an incomplete block.

Input [N, R, M, samples]: N integrator stages at the input rate, keep the integrator output at indices R-1, 2R-1, ... (whole blocks only), then N comb stages y = v - v[k-M] at the low rate with zero initial state; divide by the gain (R M)^N and return exact fraction strings.

split: open-access


prompt:
A multi-stage CIC behaves like a single-stage one with a scaled gain.

Input [N, R, M, samples]: N integrator stages at the input rate, keep the integrator output at indices R-1, 2R-1, ... (whole blocks only), then N comb stages y = v - v[k-M] at the low rate with zero initial state; divide by the gain (R M)^N and return exact fraction strings.

split: open-access


prompt:
With M = 2 the comb subtracts the previous low-rate sample instead of the one two samples back.

Input [N, R, M, samples]: N integrator stages at the input rate, keep the integrator output at indices R-1, 2R-1, ... (whole blocks only), then N comb stages y = v - v[k-M] at the low rate with zero initial state; divide by the gain (R M)^N and return exact fraction strings.

split: open-access


prompt:
With M = 2 the output of a unit step settles at 2^N instead of 1.

Input [N, R, M, samples]: N integrator stages at the input rate, keep the integrator output at indices R-1, 2R-1, ... (whole blocks only), then N comb stages y = v - v[k-M] at the low rate with zero initial state; divide by the gain (R M)^N and return exact fraction strings.

split: open-access


prompt:
Outputs have the opposite sign for odd N.

Input [N, R, M, samples]: N integrator stages at the input rate, keep the integrator output at indices R-1, 2R-1, ... (whole blocks only), then N comb stages y = v - v[k-M] at the low rate with zero initial state; divide by the gain (R M)^N and return exact fraction strings.

split: open-access


prompt:
The output is the centre sample of the window, i.e. no filtering at all.

Input [K, samples]; K odd ("bad-kernel" otherwise). Output i is the median of samples[i-K//2 .. i+K//2] clipped to the valid range (shrinking windows at the edges); an even count uses the mean of the two middle values. Return exact fraction strings.

split: open-access


prompt:
The window is asymmetric and lags the signal by half a sample.

Input [K, samples]; K odd ("bad-kernel" otherwise). Output i is the median of samples[i-K//2 .. i+K//2] clipped to the valid range (shrinking windows at the edges); an even count uses the mean of the two middle values. Return exact fraction strings.

split: open-access


prompt:
At the start of the signal the window slice is empty or picks samples from the end.

Input [K, samples]; K odd ("bad-kernel" otherwise). Output i is the median of samples[i-K//2 .. i+K//2] clipped to the valid range (shrinking windows at the edges); an even count uses the mean of the two middle values. Return exact fraction strings.

split: open-access


prompt:
Shrunken edge windows report the larger middle value instead of the mean of the two.

Input [K, samples]; K odd ("bad-kernel" otherwise). Output i is the median of samples[i-K//2 .. i+K//2] clipped to the valid range (shrinking windows at the edges); an even count uses the mean of the two middle values. Return exact fraction strings.

split: open-access


prompt:
K = 4 filters with an asymmetric five-sample window instead of returning "bad-kernel".

Input [K, samples]; K odd ("bad-kernel" otherwise). Output i is the median of samples[i-K//2 .. i+K//2] clipped to the valid range (shrinking windows at the edges); an even count uses the mean of the two middle values. Return exact fraction strings.

split: open-access


prompt:
Negative steps settle one LSB short of the input; the filter has a persistent downward bias.

Input [alpha, samples]; alpha is Q15 in [0, 32768] ("bad-alpha" otherwise). Inputs are saturated to int16; y += ((x - y) * alpha + 2**14) >> 15 (round half up on the Q15 product via arithmetic shift), starting at y = 0. Return the integer outputs.

split: open-access


prompt:
Negative updates round differently from positive ones, producing an asymmetric limit cycle.

Input [alpha, samples]; alpha is Q15 in [0, 32768] ("bad-alpha" otherwise). Inputs are saturated to int16; y += ((x - y) * alpha + 2**14) >> 15 (round half up on the Q15 product via arithmetic shift), starting at y = 0. Return the integer outputs.

split: open-access


prompt:
An input of 40000 drives the state above 32767.

Input [alpha, samples]; alpha is Q15 in [0, 32768] ("bad-alpha" otherwise). Inputs are saturated to int16; y += ((x - y) * alpha + 2**14) >> 15 (round half up on the Q15 product via arithmetic shift), starting at y = 0. Return the integer outputs.

split: open-access


prompt:
alpha = 32768 (pass-through) returns "bad-alpha".

Input [alpha, samples]; alpha is Q15 in [0, 32768] ("bad-alpha" otherwise). Inputs are saturated to int16; y += ((x - y) * alpha + 2**14) >> 15 (round half up on the Q15 product via arithmetic shift), starting at y = 0. Return the integer outputs.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    N, fc_s, win = x
    fc = float(Fraction(fc_s))
    if N < 1 or not 0 < fc <= 1:
        return 'bad-spec'
    c = N // 2
    taps = []
    for n in range(N):
        t = n - c
        s = 1.0 if t == 0 else math.sin(math.pi * fc * t) / (math.pi * fc * t)
        if N == 1 or win == 'rect':
            w = 1.0
        elif win == 'hann':
            w = 0.5 - 0.5 * math.cos(2 * math.pi * n / (N - 1))
        else:
            w = 0.54 - 0.46 * math.cos(2 * math.pi * n / (N - 1))
        taps.append(fc * s * w)
    tot = sum(taps)
    return [round(v / tot, 8) + 0.0 for v in taps]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: N=2 fc=1/2 hamming', [2, '1/2', 'hamming'], [0.5, 0.5]], ['regression: N=2 fc=1/2 rect', [2, '1/2', 'rect'], [0.5, 0.5]], ['regression: N=2 fc=1/4 hamming', [2, '1/4', 'hamming'], [0.5, 0.5]], ['control: N=1 fc=1/2 hamming', [1, '1/2', 'hamming'], [1.0]], ['control: N=1 fc=1/2 hann', [1, '1/2', 'hann'], [1.0]], ['control: N=1 fc=1/2 rect', [1, '1/2', 'rect'], [1.0]], ['control: N=1 fc=1/4 hamming', [1, '1/4', 'hamming'], [1.0]]], [['regression: N=2 fc=1/4 rect', [2, '1/4', 'rect'], [0.5, 0.5]], ['regression: N=2 fc=3/5 hamming', [2, '3/5', 'hamming'], [0.5, 0.5]], ['regression: N=2 fc=1/4 hamming', [2, '1/4', 'hamming'], [0.5, 0.5]], ['control: N=1 fc=1/4 hann', [1, '1/4', 'hann'], [1.0]], ['control: N=1 fc=1/4 rect', [1, '1/4', 'rect'], [1.0]], ['control: N=1 fc=3/5 hamming', [1, '3/5', 'hamming'], [1.0]], ['control: N=1 fc=3/5 hann', [1, '3/5', 'hann'], [1.0]]], [['regression: N=2 fc=1 hamming', [2, '1', 'hamming'], [0.5, 0.5]], ['regression: N=2 fc=1 rect', [2, '1', 'rect'], [0.5, 0.5]], ['regression: N=2 fc=3/5 hamming', [2, '3/5', 'hamming'], [0.5, 0.5]], ['control: N=1 fc=3/5 rect', [1, '3/5', 'rect'], [1.0]], ['control: N=1 fc=1 hamming', [1, '1', 'hamming'], [1.0]], ['control: N=1 fc=1 hann', [1, '1', 'hann'], [1.0]], ['control: N=1 fc=1 rect', [1, '1', 'rect'], [1.0]]], [['regression: N=4 fc=1/2 hann', [4, '1/2', 'hann'], [0.0, 0.5, 0.5, 0.0]], ['regression: N=4 fc=1/2 rect', [4, '1/2', 'rect'], [0.125, 0.375, 0.375, 0.125]], ['regression: N=2 fc=1 hamming', [2, '1', 'hamming'], [0.5, 0.5]], ['control: N=5 fc=1/2 hamming', [5, '1/2', 'hamming'], [0.0, 0.20371237, 0.59257526, 0.20371237, 0.0]], ['control: N=5 fc=1/2 hann', [5, '1/2', 'hann'], [0.0, 0.19449226, 0.61101547, 0.19449226, 0.0]], ['control: N=5 fc=1/2 rect', [5, '1/2', 'rect'], [0.0, 0.28004958, 0.43990085, 0.28004958, 0.0]], ['control: N=5 fc=1/4 hamming', [5, '1/4', 'hamming'], [0.02455383, 0.23438946, 0.4821134, 0.23438946, 0.02455383]]], [['regression: N=4 fc=1/4 hann', [4, '1/4', 'hann'], [0.0, 0.5, 0.5, 0.0]], ['regression: N=4 fc=1/4 rect', [4, '1/4', 'rect'], [0.22295145, 0.27704855, 0.27704855, 0.22295145]], ['regression: N=4 fc=1/2 hamming', [4, '1/2', 'hamming'], [0.0167364, 0.4832636, 0.4832636, 0.0167364]], ['control: N=5 fc=1/4 hann', [5, '1/4', 'hann'], [0.0, 0.23688591, 0.52622818, 0.23688591, 0.0]], ['control: N=5 fc=1/4 rect', [5, '1/4', 'rect'], [0.15626896, 0.22099768, 0.24546671, 0.22099768, 0.15626896]], ['control: N=5 fc=3/5 hamming', [5, '3/5', 'hamming'], [-0.00820621, 0.17925211, 0.65790821, 0.17925211, -0.00820621]], ['control: N=5 fc=3/5 hann', [5, '3/5', 'hann'], [0.0, 0.16767497, 0.66465005, 0.16767497, 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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    N, fc_s, win = x
    fc = float(Fraction(fc_s))
    if N < 1 or not 0 < fc <= 1:
        return 'bad-spec'
    c = (N - 1) // 2
    taps = []
    for n in range(N):
        t = n - c
        s = 1.0 if t == 0 else math.sin(math.pi * fc * t) / (math.pi * fc * t)
        if N == 1 or win == 'rect':
            w = 1.0
        elif win == 'hann':
            w = 0.5 - 0.5 * math.cos(2 * math.pi * n / (N - 1))
        else:
            w = 0.54 - 0.46 * math.cos(2 * math.pi * n / (N - 1))
        taps.append(fc * s * w)
    tot = sum(taps)
    return [round(v / tot, 8) + 0.0 for v in taps]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: N=2 fc=1/2 hamming', [2, '1/2', 'hamming'], [0.5, 0.5]], ['regression: N=2 fc=1/2 rect', [2, '1/2', 'rect'], [0.5, 0.5]], ['regression: N=2 fc=1/4 hamming', [2, '1/4', 'hamming'], [0.5, 0.5]], ['control: N=1 fc=1/2 hamming', [1, '1/2', 'hamming'], [1.0]], ['control: N=1 fc=1/2 hann', [1, '1/2', 'hann'], [1.0]], ['control: N=1 fc=1/2 rect', [1, '1/2', 'rect'], [1.0]], ['control: N=1 fc=1/4 hamming', [1, '1/4', 'hamming'], [1.0]]], [['regression: N=2 fc=1/4 rect', [2, '1/4', 'rect'], [0.5, 0.5]], ['regression: N=2 fc=3/5 hamming', [2, '3/5', 'hamming'], [0.5, 0.5]], ['regression: N=2 fc=1/4 hamming', [2, '1/4', 'hamming'], [0.5, 0.5]], ['control: N=1 fc=1/4 hann', [1, '1/4', 'hann'], [1.0]], ['control: N=1 fc=1/4 rect', [1, '1/4', 'rect'], [1.0]], ['control: N=1 fc=3/5 hamming', [1, '3/5', 'hamming'], [1.0]], ['control: N=1 fc=3/5 hann', [1, '3/5', 'hann'], [1.0]]], [['regression: N=2 fc=1 hamming', [2, '1', 'hamming'], [0.5, 0.5]], ['regression: N=2 fc=1 rect', [2, '1', 'rect'], [0.5, 0.5]], ['regression: N=2 fc=3/5 hamming', [2, '3/5', 'hamming'], [0.5, 0.5]], ['control: N=1 fc=3/5 rect', [1, '3/5', 'rect'], [1.0]], ['control: N=1 fc=1 hamming', [1, '1', 'hamming'], [1.0]], ['control: N=1 fc=1 hann', [1, '1', 'hann'], [1.0]], ['control: N=1 fc=1 rect', [1, '1', 'rect'], [1.0]]], [['regression: N=4 fc=1/2 hann', [4, '1/2', 'hann'], [0.0, 0.5, 0.5, 0.0]], ['regression: N=4 fc=1/2 rect', [4, '1/2', 'rect'], [0.125, 0.375, 0.375, 0.125]], ['regression: N=2 fc=1 hamming', [2, '1', 'hamming'], [0.5, 0.5]], ['control: N=5 fc=1/2 hamming', [5, '1/2', 'hamming'], [0.0, 0.20371237, 0.59257526, 0.20371237, 0.0]], ['control: N=5 fc=1/2 hann', [5, '1/2', 'hann'], [0.0, 0.19449226, 0.61101547, 0.19449226, 0.0]], ['control: N=5 fc=1/2 rect', [5, '1/2', 'rect'], [0.0, 0.28004958, 0.43990085, 0.28004958, 0.0]], ['control: N=5 fc=1/4 hamming', [5, '1/4', 'hamming'], [0.02455383, 0.23438946, 0.4821134, 0.23438946, 0.02455383]]], [['regression: N=4 fc=1/4 hann', [4, '1/4', 'hann'], [0.0, 0.5, 0.5, 0.0]], ['regression: N=4 fc=1/4 rect', [4, '1/4', 'rect'], [0.22295145, 0.27704855, 0.27704855, 0.22295145]], ['regression: N=4 fc=1/2 hamming', [4, '1/2', 'hamming'], [0.0167364, 0.4832636, 0.4832636, 0.0167364]], ['control: N=5 fc=1/4 hann', [5, '1/4', 'hann'], [0.0, 0.23688591, 0.52622818, 0.23688591, 0.0]], ['control: N=5 fc=1/4 rect', [5, '1/4', 'rect'], [0.15626896, 0.22099768, 0.24546671, 0.22099768, 0.15626896]], ['control: N=5 fc=3/5 hamming', [5, '3/5', 'hamming'], [-0.00820621, 0.17925211, 0.65790821, 0.17925211, -0.00820621]], ['control: N=5 fc=3/5 hann', [5, '3/5', 'hann'], [0.0, 0.16767497, 0.66465005, 0.16767497, 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)

prompt:
Even-length designs are not symmetric and lose linear phase.

Input [N, fc, window]; fc is the cutoff as a fraction of Nyquist in (0, 1], window hamming (0.54 - 0.46 cos(2 pi n/(N-1))), hann (0.5 - 0.5 cos(...)) or rect (N = 1 uses 1). Taps h[n] = fc sinc(fc (n - (N-1)/2)) w[n], normalized to unit DC gain and rounded to 8 decimals; "bad-spec" for invalid input (Hann needs N != 2).

split: open-access


prompt:
All cutoffs yield the same (full-band) impulse shape.

Input [N, fc, window]; fc is the cutoff as a fraction of Nyquist in (0, 1], window hamming (0.54 - 0.46 cos(2 pi n/(N-1))), hann (0.5 - 0.5 cos(...)) or rect (N = 1 uses 1). Taps h[n] = fc sinc(fc (n - (N-1)/2)) w[n], normalized to unit DC gain and rounded to 8 decimals; "bad-spec" for invalid input (Hann needs N != 2).

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    N, fc_s, win = x
    fc = float(Fraction(fc_s))
    if N < 1 or not 0 < fc <= 1:
        return 'bad-spec'
    c = (N - 1) / 2
    taps = []
    for n in range(N):
        t = n - c
        s = 1.0 if t == 0 else math.sin(math.pi * fc * t) / (math.pi * fc * t)
        if N == 1 or win == 'rect':
            w = 1.0
        elif win == 'hann':
            w = 0.5 - 0.5 * math.cos(2 * math.pi * n / N)
        else:
            w = 0.54 - 0.46 * math.cos(2 * math.pi * n / N)
        taps.append(fc * s * w)
    tot = sum(taps)
    return [round(v / tot, 8) + 0.0 for v in taps]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: N=2 fc=1/2 hamming', [2, '1/2', 'hamming'], [0.5, 0.5]], ['regression: N=2 fc=1/4 hamming', [2, '1/4', 'hamming'], [0.5, 0.5]], ['regression: N=2 fc=3/5 hamming', [2, '3/5', 'hamming'], [0.5, 0.5]], ['control: N=1 fc=1/2 hamming', [1, '1/2', 'hamming'], [1.0]], ['control: N=1 fc=1/2 hann', [1, '1/2', 'hann'], [1.0]], ['control: N=1 fc=1/2 rect', [1, '1/2', 'rect'], [1.0]], ['control: N=1 fc=1/4 hamming', [1, '1/4', 'hamming'], [1.0]]], [['regression: N=2 fc=1 hamming', [2, '1', 'hamming'], [0.5, 0.5]], ['regression: N=4 fc=1/2 hamming', [4, '1/2', 'hamming'], [0.0167364, 0.4832636, 0.4832636, 0.0167364]], ['regression: N=2 fc=3/5 hamming', [2, '3/5', 'hamming'], [0.5, 0.5]], ['control: N=1 fc=1/4 hann', [1, '1/4', 'hann'], [1.0]], ['control: N=1 fc=1/4 rect', [1, '1/4', 'rect'], [1.0]], ['control: N=1 fc=3/5 hamming', [1, '3/5', 'hamming'], [1.0]], ['control: N=1 fc=3/5 hann', [1, '3/5', 'hann'], [1.0]]], [['regression: N=4 fc=1/4 hamming', [4, '1/4', 'hamming'], [0.03857901, 0.46142099, 0.46142099, 0.03857901]], ['regression: N=4 fc=1/4 hann', [4, '1/4', 'hann'], [0.0, 0.5, 0.5, 0.0]], ['regression: N=4 fc=1/2 hamming', [4, '1/2', 'hamming'], [0.0167364, 0.4832636, 0.4832636, 0.0167364]], ['control: N=1 fc=3/5 rect', [1, '3/5', 'rect'], [1.0]], ['control: N=1 fc=1 hamming', [1, '1', 'hamming'], [1.0]], ['control: N=1 fc=1 hann', [1, '1', 'hann'], [1.0]], ['control: N=1 fc=1 rect', [1, '1', 'rect'], [1.0]]], [['regression: N=4 fc=3/5 hann', [4, '3/5', 'hann'], [0.0, 0.5, 0.5, 0.0]], ['regression: N=4 fc=1 hamming', [4, '1', 'hamming'], [-0.01793722, 0.51793722, 0.51793722, -0.01793722]], ['regression: N=4 fc=3/5 hamming', [4, '3/5', 'hamming'], [0.00652778, 0.49347222, 0.49347222, 0.00652778]], ['control: N=2 fc=1/2 rect', [2, '1/2', 'rect'], [0.5, 0.5]], ['control: N=2 fc=1/4 rect', [2, '1/4', 'rect'], [0.5, 0.5]], ['control: N=2 fc=3/5 rect', [2, '3/5', 'rect'], [0.5, 0.5]], ['control: N=2 fc=1 rect', [2, '1', 'rect'], [0.5, 0.5]]], [['regression: N=5 fc=1/2 hamming', [5, '1/2', 'hamming'], [0.0, 0.20371237, 0.59257526, 0.20371237, 0.0]], ['regression: N=5 fc=1/2 hann', [5, '1/2', 'hann'], [0.0, 0.19449226, 0.61101547, 0.19449226, 0.0]], ['regression: N=5 fc=1/4 hamming', [5, '1/4', 'hamming'], [0.02455383, 0.23438946, 0.4821134, 0.23438946, 0.02455383]], ['control: N=4 fc=1/2 rect', [4, '1/2', 'rect'], [0.125, 0.375, 0.375, 0.125]], ['control: N=4 fc=1/4 rect', [4, '1/4', 'rect'], [0.22295145, 0.27704855, 0.27704855, 0.22295145]], ['control: N=4 fc=3/5 rect', [4, '3/5', 'rect'], [0.056471, 0.443529, 0.443529, 0.056471]], ['control: N=4 fc=1 rect', [4, '1', 'rect'], [-0.25, 0.75, 0.75, -0.25]]]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    N, fc_s, win = x
    fc = float(Fraction(fc_s))
    if N < 1 or not 0 < fc <= 1:
        return 'bad-spec'
    c = (N - 1) / 2
    taps = []
    for n in range(N):
        t = n - c
        s = 1.0 if t == 0 else math.sin(math.pi * fc * t) / (math.pi * fc * t)
        if N == 1 or win == 'rect':
            w = 1.0
        elif win == 'hann':
            w = 0.5 - 0.5 * math.cos(2 * math.pi * n / (N - 1))
        else:
            w = 0.54 - 0.46 * math.cos(2 * math.pi * n / N)
        taps.append(fc * s * w)
    tot = sum(taps)
    return [round(v / tot, 8) + 0.0 for v in taps]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: N=2 fc=1/2 hamming', [2, '1/2', 'hamming'], [0.5, 0.5]], ['regression: N=2 fc=1/4 hamming', [2, '1/4', 'hamming'], [0.5, 0.5]], ['regression: N=2 fc=3/5 hamming', [2, '3/5', 'hamming'], [0.5, 0.5]], ['control: N=1 fc=1/2 hamming', [1, '1/2', 'hamming'], [1.0]], ['control: N=1 fc=1/2 hann', [1, '1/2', 'hann'], [1.0]], ['control: N=1 fc=1/2 rect', [1, '1/2', 'rect'], [1.0]], ['control: N=1 fc=1/4 hamming', [1, '1/4', 'hamming'], [1.0]]], [['regression: N=2 fc=1 hamming', [2, '1', 'hamming'], [0.5, 0.5]], ['regression: N=4 fc=1/2 hamming', [4, '1/2', 'hamming'], [0.0167364, 0.4832636, 0.4832636, 0.0167364]], ['regression: N=2 fc=3/5 hamming', [2, '3/5', 'hamming'], [0.5, 0.5]], ['control: N=1 fc=1/4 hann', [1, '1/4', 'hann'], [1.0]], ['control: N=1 fc=1/4 rect', [1, '1/4', 'rect'], [1.0]], ['control: N=1 fc=3/5 hamming', [1, '3/5', 'hamming'], [1.0]], ['control: N=1 fc=3/5 hann', [1, '3/5', 'hann'], [1.0]]], [['regression: N=4 fc=1/4 hamming', [4, '1/4', 'hamming'], [0.03857901, 0.46142099, 0.46142099, 0.03857901]], ['regression: N=4 fc=1/4 hann', [4, '1/4', 'hann'], [0.0, 0.5, 0.5, 0.0]], ['regression: N=4 fc=1/2 hamming', [4, '1/2', 'hamming'], [0.0167364, 0.4832636, 0.4832636, 0.0167364]], ['control: N=1 fc=3/5 rect', [1, '3/5', 'rect'], [1.0]], ['control: N=1 fc=1 hamming', [1, '1', 'hamming'], [1.0]], ['control: N=1 fc=1 hann', [1, '1', 'hann'], [1.0]], ['control: N=1 fc=1 rect', [1, '1', 'rect'], [1.0]]], [['regression: N=4 fc=3/5 hann', [4, '3/5', 'hann'], [0.0, 0.5, 0.5, 0.0]], ['regression: N=4 fc=1 hamming', [4, '1', 'hamming'], [-0.01793722, 0.51793722, 0.51793722, -0.01793722]], ['regression: N=4 fc=3/5 hamming', [4, '3/5', 'hamming'], [0.00652778, 0.49347222, 0.49347222, 0.00652778]], ['control: N=2 fc=1/2 rect', [2, '1/2', 'rect'], [0.5, 0.5]], ['control: N=2 fc=1/4 rect', [2, '1/4', 'rect'], [0.5, 0.5]], ['control: N=2 fc=3/5 rect', [2, '3/5', 'rect'], [0.5, 0.5]], ['control: N=2 fc=1 rect', [2, '1', 'rect'], [0.5, 0.5]]], [['regression: N=5 fc=1/2 hamming', [5, '1/2', 'hamming'], [0.0, 0.20371237, 0.59257526, 0.20371237, 0.0]], ['regression: N=5 fc=1/2 hann', [5, '1/2', 'hann'], [0.0, 0.19449226, 0.61101547, 0.19449226, 0.0]], ['regression: N=5 fc=1/4 hamming', [5, '1/4', 'hamming'], [0.02455383, 0.23438946, 0.4821134, 0.23438946, 0.02455383]], ['control: N=4 fc=1/2 rect', [4, '1/2', 'rect'], [0.125, 0.375, 0.375, 0.125]], ['control: N=4 fc=1/4 rect', [4, '1/4', 'rect'], [0.22295145, 0.27704855, 0.27704855, 0.22295145]], ['control: N=4 fc=3/5 rect', [4, '3/5', 'rect'], [0.056471, 0.443529, 0.443529, 0.056471]], ['control: N=4 fc=1 rect', [4, '1', 'rect'], [-0.25, 0.75, 0.75, -0.25]]]]
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)

prompt:
Window end points are not zero-tapered symmetrically; the filter is slightly asymmetric.

Input [N, fc, window]; fc is the cutoff as a fraction of Nyquist in (0, 1], window hamming (0.54 - 0.46 cos(2 pi n/(N-1))), hann (0.5 - 0.5 cos(...)) or rect (N = 1 uses 1). Taps h[n] = fc sinc(fc (n - (N-1)/2)) w[n], normalized to unit DC gain and rounded to 8 decimals; "bad-spec" for invalid input (Hann needs N != 2).

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    N, fc_s, win = x
    fc = float(Fraction(fc_s))
    if N < 1 or not 0 < fc <= 1:
        return 'bad-spec'
    c = (N - 1) / 2
    taps = []
    for n in range(N):
        t = n - c
        s = 1.0 if t == 0 else math.sin(math.pi * fc * t) / (math.pi * fc * t)
        if N == 1 or win == 'rect':
            w = 1.0
        elif win == 'hann':
            w = 0.5 - 0.5 * math.cos(2 * math.pi * n / (N - 1))
        else:
            w = 0.54 - 0.46 * math.cos(2 * math.pi * n / (N - 1))
        taps.append(fc * s * w)
    tot = max(taps)
    return [round(v / tot, 8) + 0.0 for v in taps]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: N=2 fc=1/2 hamming', [2, '1/2', 'hamming'], [0.5, 0.5]], ['regression: N=2 fc=1/2 rect', [2, '1/2', 'rect'], [0.5, 0.5]], ['regression: N=4 fc=1 hamming', [4, '1', 'hamming'], [-0.01793722, 0.51793722, 0.51793722, -0.01793722]], ['control: N=1 fc=1/2 hamming', [1, '1/2', 'hamming'], [1.0]], ['control: N=1 fc=1/2 hann', [1, '1/2', 'hann'], [1.0]], ['control: N=1 fc=1/2 rect', [1, '1/2', 'rect'], [1.0]], ['control: N=1 fc=1/4 hamming', [1, '1/4', 'hamming'], [1.0]]], [['regression: N=2 fc=1/4 rect', [2, '1/4', 'rect'], [0.5, 0.5]], ['regression: N=2 fc=3/5 hamming', [2, '3/5', 'hamming'], [0.5, 0.5]], ['regression: N=5 fc=3/5 hamming', [5, '3/5', 'hamming'], [-0.00820621, 0.17925211, 0.65790821, 0.17925211, -0.00820621]], ['control: N=1 fc=1/4 hann', [1, '1/4', 'hann'], [1.0]], ['control: N=1 fc=1/4 rect', [1, '1/4', 'rect'], [1.0]], ['control: N=1 fc=3/5 hamming', [1, '3/5', 'hamming'], [1.0]], ['control: N=1 fc=3/5 hann', [1, '3/5', 'hann'], [1.0]]], [['regression: N=2 fc=1 hamming', [2, '1', 'hamming'], [0.5, 0.5]], ['regression: N=2 fc=1 rect', [2, '1', 'rect'], [0.5, 0.5]], ['regression: N=7 fc=1/2 hamming', [7, '1/2', 'hamming'], [-0.00872183, 0.0, 0.25184279, 0.51375808, 0.25184279, 0.0, -0.00872183]], ['control: N=1 fc=3/5 rect', [1, '3/5', 'rect'], [1.0]], ['control: N=1 fc=1 hamming', [1, '1', 'hamming'], [1.0]], ['control: N=1 fc=1 hann', [1, '1', 'hann'], [1.0]], ['control: N=1 fc=1 rect', [1, '1', 'rect'], [1.0]]], [['regression: N=4 fc=1/2 hann', [4, '1/2', 'hann'], [0.0, 0.5, 0.5, 0.0]], ['regression: N=4 fc=1/2 rect', [4, '1/2', 'rect'], [0.125, 0.375, 0.375, 0.125]], ['regression: N=7 fc=3/5 hamming', [7, '3/5', 'hamming'], [-0.00499814, -0.02905169, 0.2335168, 0.60106606, 0.2335168, -0.02905169, -0.00499814]], ['control: N=5 fc=1 hamming', [5, '1', 'hamming'], [0.0, 0.0, 1.0, 0.0, 0.0]], ['control: N=5 fc=1 hann', [5, '1', 'hann'], [0.0, 0.0, 1.0, 0.0, 0.0]], ['control: N=5 fc=1 rect', [5, '1', 'rect'], [0.0, 0.0, 1.0, 0.0, 0.0]], ['control: N=7 fc=1 hamming', [7, '1', 'hamming'], [0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0]]], [['regression: N=4 fc=1/4 hann', [4, '1/4', 'hann'], [0.0, 0.5, 0.5, 0.0]], ['regression: N=4 fc=1/4 rect', [4, '1/4', 'rect'], [0.22295145, 0.27704855, 0.27704855, 0.22295145]], ['regression: N=7 fc=3/5 rect', [7, '3/5', 'rect'], [-0.06978933, -0.104684, 0.33876452, 0.6714176, 0.33876452, -0.104684, -0.06978933]], ['control: N=7 fc=1 hann', [7, '1', 'hann'], [0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0]], ['control: N=7 fc=1 rect', [7, '1', 'rect'], [0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0]], ['control: N=11 fc=1 hamming', [11, '1', 'hamming'], [0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0]], ['control: N=11 fc=1 hann', [11, '1', 'hann'], [0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    N, fc_s, win = x
    fc = float(Fraction(fc_s))
    if N < 1 or not 0 < fc <= 1:
        return 'bad-spec'
    c = (N - 1) / 2
    taps = []
    for n in range(N):
        t = n - c
        s = 1.0 if t == 0 else math.sin(math.pi * fc * t) / (math.pi * fc * t)
        if N == 1 or win == 'rect':
            w = 1.0
        elif win == 'hann':
            w = 0.5 - 0.5 * math.cos(2 * math.pi * n / (N - 1))
        else:
            w = 0.54 - 0.46 * math.cos(2 * math.pi * n / (N - 1))
        taps.append(fc * s * w)
    tot = sum(abs(v) for v in taps)
    return [round(v / tot, 8) + 0.0 for v in taps]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: N=2 fc=1/2 hamming', [2, '1/2', 'hamming'], [0.5, 0.5]], ['regression: N=2 fc=1/2 rect', [2, '1/2', 'rect'], [0.5, 0.5]], ['regression: N=4 fc=1 hamming', [4, '1', 'hamming'], [-0.01793722, 0.51793722, 0.51793722, -0.01793722]], ['control: N=1 fc=1/2 hamming', [1, '1/2', 'hamming'], [1.0]], ['control: N=1 fc=1/2 hann', [1, '1/2', 'hann'], [1.0]], ['control: N=1 fc=1/2 rect', [1, '1/2', 'rect'], [1.0]], ['control: N=1 fc=1/4 hamming', [1, '1/4', 'hamming'], [1.0]]], [['regression: N=2 fc=1/4 rect', [2, '1/4', 'rect'], [0.5, 0.5]], ['regression: N=2 fc=3/5 hamming', [2, '3/5', 'hamming'], [0.5, 0.5]], ['regression: N=5 fc=3/5 hamming', [5, '3/5', 'hamming'], [-0.00820621, 0.17925211, 0.65790821, 0.17925211, -0.00820621]], ['control: N=1 fc=1/4 hann', [1, '1/4', 'hann'], [1.0]], ['control: N=1 fc=1/4 rect', [1, '1/4', 'rect'], [1.0]], ['control: N=1 fc=3/5 hamming', [1, '3/5', 'hamming'], [1.0]], ['control: N=1 fc=3/5 hann', [1, '3/5', 'hann'], [1.0]]], [['regression: N=2 fc=1 hamming', [2, '1', 'hamming'], [0.5, 0.5]], ['regression: N=2 fc=1 rect', [2, '1', 'rect'], [0.5, 0.5]], ['regression: N=7 fc=1/2 hamming', [7, '1/2', 'hamming'], [-0.00872183, 0.0, 0.25184279, 0.51375808, 0.25184279, 0.0, -0.00872183]], ['control: N=1 fc=3/5 rect', [1, '3/5', 'rect'], [1.0]], ['control: N=1 fc=1 hamming', [1, '1', 'hamming'], [1.0]], ['control: N=1 fc=1 hann', [1, '1', 'hann'], [1.0]], ['control: N=1 fc=1 rect', [1, '1', 'rect'], [1.0]]], [['regression: N=4 fc=1/2 hann', [4, '1/2', 'hann'], [0.0, 0.5, 0.5, 0.0]], ['regression: N=4 fc=1/2 rect', [4, '1/2', 'rect'], [0.125, 0.375, 0.375, 0.125]], ['regression: N=7 fc=3/5 hamming', [7, '3/5', 'hamming'], [-0.00499814, -0.02905169, 0.2335168, 0.60106606, 0.2335168, -0.02905169, -0.00499814]], ['control: N=5 fc=1 hamming', [5, '1', 'hamming'], [0.0, 0.0, 1.0, 0.0, 0.0]], ['control: N=5 fc=1 hann', [5, '1', 'hann'], [0.0, 0.0, 1.0, 0.0, 0.0]], ['control: N=5 fc=1 rect', [5, '1', 'rect'], [0.0, 0.0, 1.0, 0.0, 0.0]], ['control: N=7 fc=1 hamming', [7, '1', 'hamming'], [0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0]]], [['regression: N=4 fc=1/4 hann', [4, '1/4', 'hann'], [0.0, 0.5, 0.5, 0.0]], ['regression: N=4 fc=1/4 rect', [4, '1/4', 'rect'], [0.22295145, 0.27704855, 0.27704855, 0.22295145]], ['regression: N=7 fc=3/5 rect', [7, '3/5', 'rect'], [-0.06978933, -0.104684, 0.33876452, 0.6714176, 0.33876452, -0.104684, -0.06978933]], ['control: N=7 fc=1 hann', [7, '1', 'hann'], [0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0]], ['control: N=7 fc=1 rect', [7, '1', 'rect'], [0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0]], ['control: N=11 fc=1 hamming', [11, '1', 'hamming'], [0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0]], ['control: N=11 fc=1 hann', [11, '1', 'hann'], [0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 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)

prompt:
The DC gain is far above unity for long filters.

Input [N, fc, window]; fc is the cutoff as a fraction of Nyquist in (0, 1], window hamming (0.54 - 0.46 cos(2 pi n/(N-1))), hann (0.5 - 0.5 cos(...)) or rect (N = 1 uses 1). Taps h[n] = fc sinc(fc (n - (N-1)/2)) w[n], normalized to unit DC gain and rounded to 8 decimals; "bad-spec" for invalid input (Hann needs N != 2).

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import cmath
from fractions import Fraction
N = 1
observations = []
def solve(x):
    b, a, fs = x
    b = [float(Fraction(v)) for v in b]
    a = [float(Fraction(v)) for v in a]
    out = []
    for f in fs:
        w = 2 * math.pi * float(Fraction(f))
        B = sum(c * cmath.exp(-1j * w * k) for k, c in enumerate(b))
        A = sum(c * cmath.exp(-1j * w * k) for k, c in enumerate(a))
        if abs(A) < 1e-12:
            out.append('pole')
            continue
        H = B / A
        mag = abs(H)
        if mag < 1e-9:
            out.append('zero')
            continue
        out.append([round(20 * math.log10(mag), 4) + 0.0, round(math.degrees(cmath.phase(H)), 3) + 0.0])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: two-tap average at nyquist', [[1, 1], [1], ['1']], ['zero']], ['regression: first difference', [[1, -1], [1], ['0', '1/2', '1']], ['zero', [3.0103, 45.0], [6.0206, 0.0]]], ['regression: one pole', [[1], [1, '-1/2'], ['0', '1/4', '1/2']], [[6.0206, 0.0], [2.6529, -28.675], [-0.9691, -26.565]]], ['control: pole on unit circle', [[1], [1, -1], ['0']], ['pole']], ['control: small magnitude', [[1, '-0.9999'], [1], ['0']], [[-80.0, 0.0]]], ['regression: deep notch', [[1, 0, 1], [1], ['1/2', '0.49']], ['zero', [-24.0378, -88.2]]], ['regression: pure delay phase', [[0, 1], [1], ['1/4', '1/2']], [[0.0, -45.0], [0.0, -90.0]]]], [['regression: deep notch', [[1, 0, 1], [1], ['1/2', '0.49']], ['zero', [-24.0378, -88.2]]], ['regression: pure delay phase', [[0, 1], [1], ['1/4', '1/2']], [[0.0, -45.0], [0.0, -90.0]]], ['regression: one pole', [[1], [1, '-1/2'], ['0', '1/4', '1/2']], [[6.0206, 0.0], [2.6529, -28.675], [-0.9691, -26.565]]], ['control: pole on unit circle', [[1], [1, -1], ['0']], ['pole']], ['control: small magnitude', [[1, '-0.9999'], [1], ['0']], [[-80.0, 0.0]]], ['regression: random response 0', [['-1/4', 1], [1, 0], ['1/3', '1/8', '1/8']], [[-0.9018, -73.898], [-2.2144, -29.591], [-2.2144, -29.591]]], ['regression: random response 1', [[0, -1, 1, 0], [1, '1/3', '1/3'], ['1/2', '3/4', '1/8']], [[5.563, 161.565], [7.5974, 60.22], [-12.1798, -110.508]]]], [['regression: random response 1', [[0, -1, 1, 0], [1, '1/3', '1/3'], ['1/2', '3/4', '1/8']], [[5.563, 161.565], [7.5974, 60.22], [-12.1798, -110.508]]], ['regression: random response 2', [['1/2', '-1/4', 0, 2], [1, '1/2', '1/2'], ['1/2', '1/2', '1/2']], [[10.2633, 122.471], [10.2633, 122.471], [10.2633, 122.471]]], ['regression: pure delay phase', [[0, 1], [1], ['1/4', '1/2']], [[0.0, -45.0], [0.0, -90.0]]], ['control: pole on unit circle', [[1], [1, -1], ['0']], ['pole']], ['control: small magnitude', [[1, '-0.9999'], [1], ['0']], [[-80.0, 0.0]]], ['regression: deep notch', [[1, 0, 1], [1], ['1/2', '0.49']], ['zero', [-24.0378, -88.2]]], ['regression: random response 0', [['-1/4', 1], [1, 0], ['1/3', '1/8', '1/8']], [[-0.9018, -73.898], [-2.2144, -29.591], [-2.2144, -29.591]]]], [['regression: random response 4', [[-1], [1, '1/2'], ['3/4', '1', '0']], [[2.6529, -151.325], [6.0206, -180.0], [-3.5218, 180.0]]], ['regression: random response 5', [[1], [1, '1/2', '1/2'], ['1/4', '1', '1/8']], [[-4.0835, 32.236], [0.0, 0.0], [-5.5545, 16.706]]], ['regression: random response 1', [[0, -1, 1, 0], [1, '1/3', '1/3'], ['1/2', '3/4', '1/8']], [[5.563, 161.565], [7.5974, 60.22], [-12.1798, -110.508]]], ['control: pole on unit circle', [[1], [1, -1], ['0']], ['pole']], ['control: small magnitude', [[1, '-0.9999'], [1], ['0']], [[-80.0, 0.0]]], ['regression: pure delay phase', [[0, 1], [1], ['1/4', '1/2']], [[0.0, -45.0], [0.0, -90.0]]], ['regression: random response 0', [['-1/4', 1], [1, 0], ['1/3', '1/8', '1/8']], [[-0.9018, -73.898], [-2.2144, -29.591], [-2.2144, -29.591]]]], [['regression: random response 7', [[2, -1], [1, '1/2'], ['3/4', '1/3', '1/3']], [[11.5896, 43.314], [2.3408, 49.107], [2.3408, 49.107]]], ['regression: random response 8', [[1, 2, -1, 1], [1, '-1/4', 0], ['1', '1/4', '0']], [[7.6042, -180.0], [7.6969, -45.419], [12.0412, 0.0]]], ['regression: random response 3', [[0, 0, -1], [1], ['1/2', '1/8', '1']], [[0.0, 0.0], [0.0, 135.0], [0.0, -180.0]]], ['control: pole on unit circle', [[1], [1, -1], ['0']], ['pole']], ['control: small magnitude', [[1, '-0.9999'], [1], ['0']], [[-80.0, 0.0]]], ['regression: random response 0', [['-1/4', 1], [1, 0], ['1/3', '1/8', '1/8']], [[-0.9018, -73.898], [-2.2144, -29.591], [-2.2144, -29.591]]], ['regression: random response 1', [[0, -1, 1, 0], [1, '1/3', '1/3'], ['1/2', '3/4', '1/8']], [[5.563, 161.565], [7.5974, 60.22], [-12.1798, -110.508]]]]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import cmath
from fractions import Fraction
N = 1
observations = []
def solve(x):
    b, a, fs = x
    b = [float(Fraction(v)) for v in b]
    a = [float(Fraction(v)) for v in a]
    out = []
    for f in fs:
        w = math.pi * float(Fraction(f)) / 2
        B = sum(c * cmath.exp(-1j * w * k) for k, c in enumerate(b))
        A = sum(c * cmath.exp(-1j * w * k) for k, c in enumerate(a))
        if abs(A) < 1e-12:
            out.append('pole')
            continue
        H = B / A
        mag = abs(H)
        if mag < 1e-9:
            out.append('zero')
            continue
        out.append([round(20 * math.log10(mag), 4) + 0.0, round(math.degrees(cmath.phase(H)), 3) + 0.0])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: two-tap average at nyquist', [[1, 1], [1], ['1']], ['zero']], ['regression: first difference', [[1, -1], [1], ['0', '1/2', '1']], ['zero', [3.0103, 45.0], [6.0206, 0.0]]], ['regression: one pole', [[1], [1, '-1/2'], ['0', '1/4', '1/2']], [[6.0206, 0.0], [2.6529, -28.675], [-0.9691, -26.565]]], ['control: pole on unit circle', [[1], [1, -1], ['0']], ['pole']], ['control: small magnitude', [[1, '-0.9999'], [1], ['0']], [[-80.0, 0.0]]], ['regression: deep notch', [[1, 0, 1], [1], ['1/2', '0.49']], ['zero', [-24.0378, -88.2]]], ['regression: pure delay phase', [[0, 1], [1], ['1/4', '1/2']], [[0.0, -45.0], [0.0, -90.0]]]], [['regression: deep notch', [[1, 0, 1], [1], ['1/2', '0.49']], ['zero', [-24.0378, -88.2]]], ['regression: pure delay phase', [[0, 1], [1], ['1/4', '1/2']], [[0.0, -45.0], [0.0, -90.0]]], ['regression: one pole', [[1], [1, '-1/2'], ['0', '1/4', '1/2']], [[6.0206, 0.0], [2.6529, -28.675], [-0.9691, -26.565]]], ['control: pole on unit circle', [[1], [1, -1], ['0']], ['pole']], ['control: small magnitude', [[1, '-0.9999'], [1], ['0']], [[-80.0, 0.0]]], ['regression: random response 0', [['-1/4', 1], [1, 0], ['1/3', '1/8', '1/8']], [[-0.9018, -73.898], [-2.2144, -29.591], [-2.2144, -29.591]]], ['regression: random response 1', [[0, -1, 1, 0], [1, '1/3', '1/3'], ['1/2', '3/4', '1/8']], [[5.563, 161.565], [7.5974, 60.22], [-12.1798, -110.508]]]], [['regression: random response 1', [[0, -1, 1, 0], [1, '1/3', '1/3'], ['1/2', '3/4', '1/8']], [[5.563, 161.565], [7.5974, 60.22], [-12.1798, -110.508]]], ['regression: random response 2', [['1/2', '-1/4', 0, 2], [1, '1/2', '1/2'], ['1/2', '1/2', '1/2']], [[10.2633, 122.471], [10.2633, 122.471], [10.2633, 122.471]]], ['regression: pure delay phase', [[0, 1], [1], ['1/4', '1/2']], [[0.0, -45.0], [0.0, -90.0]]], ['control: pole on unit circle', [[1], [1, -1], ['0']], ['pole']], ['control: small magnitude', [[1, '-0.9999'], [1], ['0']], [[-80.0, 0.0]]], ['regression: deep notch', [[1, 0, 1], [1], ['1/2', '0.49']], ['zero', [-24.0378, -88.2]]], ['regression: random response 0', [['-1/4', 1], [1, 0], ['1/3', '1/8', '1/8']], [[-0.9018, -73.898], [-2.2144, -29.591], [-2.2144, -29.591]]]], [['regression: random response 4', [[-1], [1, '1/2'], ['3/4', '1', '0']], [[2.6529, -151.325], [6.0206, -180.0], [-3.5218, 180.0]]], ['regression: random response 5', [[1], [1, '1/2', '1/2'], ['1/4', '1', '1/8']], [[-4.0835, 32.236], [0.0, 0.0], [-5.5545, 16.706]]], ['regression: random response 1', [[0, -1, 1, 0], [1, '1/3', '1/3'], ['1/2', '3/4', '1/8']], [[5.563, 161.565], [7.5974, 60.22], [-12.1798, -110.508]]], ['control: pole on unit circle', [[1], [1, -1], ['0']], ['pole']], ['control: small magnitude', [[1, '-0.9999'], [1], ['0']], [[-80.0, 0.0]]], ['regression: pure delay phase', [[0, 1], [1], ['1/4', '1/2']], [[0.0, -45.0], [0.0, -90.0]]], ['regression: random response 0', [['-1/4', 1], [1, 0], ['1/3', '1/8', '1/8']], [[-0.9018, -73.898], [-2.2144, -29.591], [-2.2144, -29.591]]]], [['regression: random response 7', [[2, -1], [1, '1/2'], ['3/4', '1/3', '1/3']], [[11.5896, 43.314], [2.3408, 49.107], [2.3408, 49.107]]], ['regression: random response 8', [[1, 2, -1, 1], [1, '-1/4', 0], ['1', '1/4', '0']], [[7.6042, -180.0], [7.6969, -45.419], [12.0412, 0.0]]], ['regression: random response 3', [[0, 0, -1], [1], ['1/2', '1/8', '1']], [[0.0, 0.0], [0.0, 135.0], [0.0, -180.0]]], ['control: pole on unit circle', [[1], [1, -1], ['0']], ['pole']], ['control: small magnitude', [[1, '-0.9999'], [1], ['0']], [[-80.0, 0.0]]], ['regression: random response 0', [['-1/4', 1], [1, 0], ['1/3', '1/8', '1/8']], [[-0.9018, -73.898], [-2.2144, -29.591], [-2.2144, -29.591]]], ['regression: random response 1', [[0, -1, 1, 0], [1, '1/3', '1/3'], ['1/2', '3/4', '1/8']], [[5.563, 161.565], [7.5974, 60.22], [-12.1798, -110.508]]]]]
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)

prompt:
f = 1/2 (half Nyquist) is evaluated at Nyquist.

Input [b, a, freqs]; coefficients and frequencies are numbers or rational strings, frequencies are fractions of Nyquist. For w = pi f evaluate H = B(e^{jw})/A(e^{jw}) with z^-k = e^{-jwk}; return per frequency [20 log10 |H| rounded to 4, phase in degrees rounded to 3], "pole" if |A| < 1e-12, "zero" if |H| < 1e-9.

split: open-access


prompt:
A gain of 2 is reported as 3.01 dB instead of 6.02 dB.

Input [b, a, freqs]; coefficients and frequencies are numbers or rational strings, frequencies are fractions of Nyquist. For w = pi f evaluate H = B(e^{jw})/A(e^{jw}) with z^-k = e^{-jwk}; return per frequency [20 log10 |H| rounded to 4, phase in degrees rounded to 3], "pole" if |A| < 1e-12, "zero" if |H| < 1e-9.

split: open-access


prompt:
Magnitudes are right but every phase has the opposite sign; a pure delay shows phase lead.

Input [b, a, freqs]; coefficients and frequencies are numbers or rational strings, frequencies are fractions of Nyquist. For w = pi f evaluate H = B(e^{jw})/A(e^{jw}) with z^-k = e^{-jwk}; return per frequency [20 log10 |H| rounded to 4, phase in degrees rounded to 3], "pole" if |A| < 1e-12, "zero" if |H| < 1e-9.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import cmath
from fractions import Fraction
N = 1
observations = []
def solve(x):
    b, a, fs = x
    b = [float(Fraction(v)) for v in b]
    a = [float(Fraction(v)) for v in a]
    out = []
    for f in fs:
        w = math.pi * float(Fraction(f))
        B = sum(c * cmath.exp(-1j * w * k) for k, c in enumerate(b))
        A = sum(c * cmath.exp(-1j * w * k) for k, c in enumerate(a))
        if abs(A) < 1e-12:
            out.append('pole')
            continue
        H = B / A
        mag = abs(H)
        if mag == 0:
            out.append('zero')
            continue
        out.append([round(20 * math.log10(mag), 4) + 0.0, round(math.degrees(cmath.phase(H)), 3) + 0.0])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: two-tap average at nyquist', [[1, 1], [1], ['1']], ['zero']], ['regression: deep notch', [[1, 0, 1], [1], ['1/2', '0.49']], ['zero', [-24.0378, -88.2]]], ['repair check: small magnitude', [[1, '-0.9999'], [1], ['0']], [[-80.0, 0.0]]], ['control: first difference', [[1, -1], [1], ['0', '1/2', '1']], ['zero', [3.0103, 45.0], [6.0206, 0.0]]], ['control: one pole', [[1], [1, '-1/2'], ['0', '1/4', '1/2']], [[6.0206, 0.0], [2.6529, -28.675], [-0.9691, -26.565]]], ['control: pole on unit circle', [[1], [1, -1], ['0']], ['pole']], ['control: pure delay phase', [[0, 1], [1], ['1/4', '1/2']], [[0.0, -45.0], [0.0, -90.0]]]], [['regression: two-tap average at nyquist', [[1, 1], [1], ['1']], ['zero']], ['regression: deep notch', [[1, 0, 1], [1], ['1/2', '0.49']], ['zero', [-24.0378, -88.2]]], ['repair check: small magnitude', [[1, '-0.9999'], [1], ['0']], [[-80.0, 0.0]]], ['control: random response 0', [['-1/4', 1], [1, 0], ['1/3', '1/8', '1/8']], [[-0.9018, -73.898], [-2.2144, -29.591], [-2.2144, -29.591]]], ['control: random response 1', [[0, -1, 1, 0], [1, '1/3', '1/3'], ['1/2', '3/4', '1/8']], [[5.563, 161.565], [7.5974, 60.22], [-12.1798, -110.508]]], ['control: random response 2', [['1/2', '-1/4', 0, 2], [1, '1/2', '1/2'], ['1/2', '1/2', '1/2']], [[10.2633, 122.471], [10.2633, 122.471], [10.2633, 122.471]]], ['control: random response 3', [[0, 0, -1], [1], ['1/2', '1/8', '1']], [[0.0, 0.0], [0.0, 135.0], [0.0, -180.0]]]], [['regression: two-tap average at nyquist', [[1, 1], [1], ['1']], ['zero']], ['regression: deep notch', [[1, 0, 1], [1], ['1/2', '0.49']], ['zero', [-24.0378, -88.2]]], ['repair check: small magnitude', [[1, '-0.9999'], [1], ['0']], [[-80.0, 0.0]]], ['control: random response 4', [[-1], [1, '1/2'], ['3/4', '1', '0']], [[2.6529, -151.325], [6.0206, -180.0], [-3.5218, 180.0]]], ['control: random response 5', [[1], [1, '1/2', '1/2'], ['1/4', '1', '1/8']], [[-4.0835, 32.236], [0.0, 0.0], [-5.5545, 16.706]]], ['control: random response 6', [[1, -1], [1, '1/3', '1/3'], ['1/8', '1', '1/2']], [[-12.1798, 91.992], [6.0206, 0.0], [5.563, 71.565]]], ['control: random response 7', [[2, -1], [1, '1/2'], ['3/4', '1/3', '1/3']], [[11.5896, 43.314], [2.3408, 49.107], [2.3408, 49.107]]]], [['regression: two-tap average at nyquist', [[1, 1], [1], ['1']], ['zero']], ['regression: deep notch', [[1, 0, 1], [1], ['1/2', '0.49']], ['zero', [-24.0378, -88.2]]], ['repair check: small magnitude', [[1, '-0.9999'], [1], ['0']], [[-80.0, 0.0]]], ['control: random response 8', [[1, 2, -1, 1], [1, '-1/4', 0], ['1', '1/4', '0']], [[7.6042, -180.0], [7.6969, -45.419], [12.0412, 0.0]]], ['control: random response 9', [[1], [1, '1/2'], ['1', '1/4', '1']], [[6.0206, 0.0], [-2.9161, 14.639], [6.0206, 0.0]]], ['control: random response 10', [[-1, 1], [1], ['1/3', '1', '1/3']], [[0.0, -120.0], [6.0206, -180.0], [0.0, -120.0]]], ['control: random response 11', [[1, 2, 0], [1], ['1/2', '0', '1/8']], [[6.9897, -63.435], [9.5424, 0.0], [9.393, -15.043]]]], [['regression: two-tap average at nyquist', [[1, 1], [1], ['1']], ['zero']], ['regression: deep notch', [[1, 0, 1], [1], ['1/2', '0.49']], ['zero', [-24.0378, -88.2]]], ['repair check: small magnitude', [[1, '-0.9999'], [1], ['0']], [[-80.0, 0.0]]], ['control: random response 12', [['-1/4'], [1, '1/2', 0], ['1/8', '0', '0']], [[-15.4136, -172.543], [-15.563, 180.0], [-15.563, 180.0]]], ['control: random response 13', [[-1, 2], [1, 0, '1/3'], ['1/2', '1/2', '1/8']], [[10.5115, -116.565], [10.5115, -116.565], [-0.8391, -31.277]]], ['control: random response 14', [[2, '1/2', -1], [1], ['1/8', '1/3', '0']], [[5.2445, 16.379], [8.893, 8.948], [3.5218, 0.0]]], ['control: random response 15', [[0, -1, '1/2', 0], [1], ['0', '1/8', '3/4']], [[-6.0206, 180.0], [-4.8662, 177.076], [2.9161, 59.639]]]]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import cmath
from fractions import Fraction
N = 1
observations = []
def solve(x):
    b, a, fs = x
    b = [float(Fraction(v)) for v in b]
    a = [float(Fraction(v)) for v in a]
    out = []
    for f in fs:
        w = math.pi * float(Fraction(f))
        B = sum(c * cmath.exp(-1j * w * k) for k, c in enumerate(b))
        A = sum(c * cmath.exp(-1j * w * k) for k, c in enumerate(a))
        if abs(A) < 1e-12:
            out.append('pole')
            continue
        H = B / A
        mag = abs(H)
        if mag < 1e-3:
            out.append('zero')
            continue
        out.append([round(20 * math.log10(mag), 4) + 0.0, round(math.degrees(cmath.phase(H)), 3) + 0.0])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: two-tap average at nyquist', [[1, 1], [1], ['1']], ['zero']], ['regression: deep notch', [[1, 0, 1], [1], ['1/2', '0.49']], ['zero', [-24.0378, -88.2]]], ['repair check: small magnitude', [[1, '-0.9999'], [1], ['0']], [[-80.0, 0.0]]], ['control: first difference', [[1, -1], [1], ['0', '1/2', '1']], ['zero', [3.0103, 45.0], [6.0206, 0.0]]], ['control: one pole', [[1], [1, '-1/2'], ['0', '1/4', '1/2']], [[6.0206, 0.0], [2.6529, -28.675], [-0.9691, -26.565]]], ['control: pole on unit circle', [[1], [1, -1], ['0']], ['pole']], ['control: pure delay phase', [[0, 1], [1], ['1/4', '1/2']], [[0.0, -45.0], [0.0, -90.0]]]], [['regression: two-tap average at nyquist', [[1, 1], [1], ['1']], ['zero']], ['regression: deep notch', [[1, 0, 1], [1], ['1/2', '0.49']], ['zero', [-24.0378, -88.2]]], ['repair check: small magnitude', [[1, '-0.9999'], [1], ['0']], [[-80.0, 0.0]]], ['control: random response 0', [['-1/4', 1], [1, 0], ['1/3', '1/8', '1/8']], [[-0.9018, -73.898], [-2.2144, -29.591], [-2.2144, -29.591]]], ['control: random response 1', [[0, -1, 1, 0], [1, '1/3', '1/3'], ['1/2', '3/4', '1/8']], [[5.563, 161.565], [7.5974, 60.22], [-12.1798, -110.508]]], ['control: random response 2', [['1/2', '-1/4', 0, 2], [1, '1/2', '1/2'], ['1/2', '1/2', '1/2']], [[10.2633, 122.471], [10.2633, 122.471], [10.2633, 122.471]]], ['control: random response 3', [[0, 0, -1], [1], ['1/2', '1/8', '1']], [[0.0, 0.0], [0.0, 135.0], [0.0, -180.0]]]], [['regression: two-tap average at nyquist', [[1, 1], [1], ['1']], ['zero']], ['regression: deep notch', [[1, 0, 1], [1], ['1/2', '0.49']], ['zero', [-24.0378, -88.2]]], ['repair check: small magnitude', [[1, '-0.9999'], [1], ['0']], [[-80.0, 0.0]]], ['control: random response 4', [[-1], [1, '1/2'], ['3/4', '1', '0']], [[2.6529, -151.325], [6.0206, -180.0], [-3.5218, 180.0]]], ['control: random response 5', [[1], [1, '1/2', '1/2'], ['1/4', '1', '1/8']], [[-4.0835, 32.236], [0.0, 0.0], [-5.5545, 16.706]]], ['control: random response 6', [[1, -1], [1, '1/3', '1/3'], ['1/8', '1', '1/2']], [[-12.1798, 91.992], [6.0206, 0.0], [5.563, 71.565]]], ['control: random response 7', [[2, -1], [1, '1/2'], ['3/4', '1/3', '1/3']], [[11.5896, 43.314], [2.3408, 49.107], [2.3408, 49.107]]]], [['regression: two-tap average at nyquist', [[1, 1], [1], ['1']], ['zero']], ['regression: deep notch', [[1, 0, 1], [1], ['1/2', '0.49']], ['zero', [-24.0378, -88.2]]], ['repair check: small magnitude', [[1, '-0.9999'], [1], ['0']], [[-80.0, 0.0]]], ['control: random response 8', [[1, 2, -1, 1], [1, '-1/4', 0], ['1', '1/4', '0']], [[7.6042, -180.0], [7.6969, -45.419], [12.0412, 0.0]]], ['control: random response 9', [[1], [1, '1/2'], ['1', '1/4', '1']], [[6.0206, 0.0], [-2.9161, 14.639], [6.0206, 0.0]]], ['control: random response 10', [[-1, 1], [1], ['1/3', '1', '1/3']], [[0.0, -120.0], [6.0206, -180.0], [0.0, -120.0]]], ['control: random response 11', [[1, 2, 0], [1], ['1/2', '0', '1/8']], [[6.9897, -63.435], [9.5424, 0.0], [9.393, -15.043]]]], [['regression: two-tap average at nyquist', [[1, 1], [1], ['1']], ['zero']], ['regression: deep notch', [[1, 0, 1], [1], ['1/2', '0.49']], ['zero', [-24.0378, -88.2]]], ['repair check: small magnitude', [[1, '-0.9999'], [1], ['0']], [[-80.0, 0.0]]], ['control: random response 12', [['-1/4'], [1, '1/2', 0], ['1/8', '0', '0']], [[-15.4136, -172.543], [-15.563, 180.0], [-15.563, 180.0]]], ['control: random response 13', [[-1, 2], [1, 0, '1/3'], ['1/2', '1/2', '1/8']], [[10.5115, -116.565], [10.5115, -116.565], [-0.8391, -31.277]]], ['control: random response 14', [[2, '1/2', -1], [1], ['1/8', '1/3', '0']], [[5.2445, 16.379], [8.893, 8.948], [3.5218, 0.0]]], ['control: random response 15', [[0, -1, '1/2', 0], [1], ['0', '1/8', '3/4']], [[-6.0206, 180.0], [-4.8662, 177.076], [2.9161, 59.639]]]]]
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)

prompt:
A notch that evaluates to 1e-16 due to rounding is reported as about -320 dB with a random phase.

Input [b, a, freqs]; coefficients and frequencies are numbers or rational strings, frequencies are fractions of Nyquist. For w = pi f evaluate H = B(e^{jw})/A(e^{jw}) with z^-k = e^{-jwk}; return per frequency [20 log10 |H| rounded to 4, phase in degrees rounded to 3], "pole" if |A| < 1e-12, "zero" if |H| < 1e-9.

split: open-access


prompt:
The output uses future samples x[mD + p], a non-causal and wrongly aligned result.

Input [h, D, samples] (integers). Output y[m] = sum_k h[k] x[mD - k] for m = 0 .. ceil(len/D) - 1 with x = 0 outside the signal, computed through the polyphase split E_p[j] = h[jD + p].

split: open-access


prompt:
Long filters produce outputs that do not match filter-then-downsample.

Input [h, D, samples] (integers). Output y[m] = sum_k h[k] x[mD - k] for m = 0 .. ceil(len/D) - 1 with x = 0 outside the signal, computed through the polyphase split E_p[j] = h[jD + p].

split: open-access


prompt:
For a length not divisible by D the final output sample is missing.

Input [h, D, samples] (integers). Output y[m] = sum_k h[k] x[mD - k] for m = 0 .. ceil(len/D) - 1 with x = 0 outside the signal, computed through the polyphase split E_p[j] = h[jD + p].

split: open-access


prompt:
Early outputs pick up samples from the tail of the buffer.

Input [h, D, samples] (integers). Output y[m] = sum_k h[k] x[mD - k] for m = 0 .. ceil(len/D) - 1 with x = 0 outside the signal, computed through the polyphase split E_p[j] = h[jD + p].

split: open-access


prompt:
The interpolated signal is L times too quiet because zero-stuffing removed energy.

Input [h, L, samples] (integers). Zero-stuff by L and filter with h, scaled by gain L: y[mL + p] = L sum_j h[jL + p] x[m - j]; return len(samples) * L outputs in time order.

split: open-access


prompt:
The first outputs include contributions from the last input samples.

Input [h, L, samples] (integers). Zero-stuff by L and filter with h, scaled by gain L: y[mL + p] = L sum_j h[jL + p] x[m - j]; return len(samples) * L outputs in time order.

split: open-access


prompt:
When the filter length is not a multiple of L the last taps are never applied.

Input [h, L, samples] (integers). Zero-stuff by L and filter with h, scaled by gain L: y[mL + p] = L sum_j h[jL + p] x[m - j]; return len(samples) * L outputs in time order.

split: open-access