FAILURE MAP
← Case archive

FA-91416 / Digital signal filters / Open access

Centered average drops zero padding from the divisor · case 01

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

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

ROOT CAUSE

Missing samples are skipped instead of appended as zeros, so the divisor shrinks.

VERIFIED REPAIR

Append explicit zeros so the divisor is always K.

Unsuccessful approach: The attempted repair pads zeros only below the start, leaving the upper edge unpadded.

Case contract

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.

Why this case matters

Offline smoothing needs explicit edge handling; mirror and padding conventions differ between tools and are easy to mix up.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(x):
    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)
Boundary fixtureActualExpectedOutcome
regression: zero padding['3', '3', '3']['2', '3', '2']Failed
regression: random centered 0['5/2', '13/3', '7/2']['5/3', '13/3', '7/3']Failed
regression: random centered 4['-2', '-2', '-2']['-6/5', '-6/5', '-6/5']Failed
control: reflect edges['11/3', '8/3', '5', '4']['11/3', '8/3', '5', '4']Passed
control: reflect wide['8/5', '12/5', '13/5', '3', '17/5']['8/5', '12/5', '13/5', '3', '17/5']Passed
control: shrink edges['3', '4', '5']['3', '4', '5']Passed
control: even windowbad-windowbad-windowPassed

SHA-256 / c62a62b2e04e0cec7187d605e83c52fd84a8e5923be4f823ad14a3efbf466968

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(x):
    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)
Boundary fixtureActualExpectedOutcome
regression: zero padding['2', '3', '3']['2', '3', '2']Failed
regression: random centered 0['5/3', '13/3', '7/2']['5/3', '13/3', '7/3']Failed
regression: random centered 4['-6/5', '-3/2', '-2']['-6/5', '-6/5', '-6/5']Failed
control: reflect edges['11/3', '8/3', '5', '4']['11/3', '8/3', '5', '4']Passed
control: reflect wide['8/5', '12/5', '13/5', '3', '17/5']['8/5', '12/5', '13/5', '3', '17/5']Passed
control: shrink edges['3', '4', '5']['3', '4', '5']Passed
control: even windowbad-windowbad-windowPassed

SHA-256 / 5406b8d6065aa0b93fac0d7f404c7c050863713edf4c21182b357214667e345d

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(x):
    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: 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)
Boundary fixtureActualExpectedOutcome
regression: zero padding['2', '3', '2']['2', '3', '2']Passed
regression: random centered 0['5/3', '13/3', '7/3']['5/3', '13/3', '7/3']Passed
regression: random centered 4['-6/5', '-6/5', '-6/5']['-6/5', '-6/5', '-6/5']Passed
control: reflect edges['11/3', '8/3', '5', '4']['11/3', '8/3', '5', '4']Passed
control: reflect wide['8/5', '12/5', '13/5', '3', '17/5']['8/5', '12/5', '13/5', '3', '17/5']Passed
control: shrink edges['3', '4', '5']['3', '4', '5']Passed
control: even windowbad-windowbad-windowPassed

SHA-256 / 9ffe2832f2deb12c9a842e2a4e8a628a3473ef6642eb25ee670f4e92194effbf

Verification & scope

A deterministic bounded teaching model with a stipulated toy contract; exact rational arithmetic or fixed-decimal rounding keeps outputs strict JSON. It is not a production DSP library and claims no standards conformance. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:51:35.680645+00:00.

Case digest / 6b8346b047f34c9c22da43773619ca9e60fa918f0ef48210d253c268da84c835