Hmbown/CodeWhale · error · SystemExit

no navy hero whale found in the founder sheet

Error message

no navy hero whale found in the founder sheet

What it means

`hero_coverage()` scans the hero band of the founder sheet for pixels matching `is_navy()` (blue-dominant dark pixels) to locate the whale artwork. If no navy pixel is found anywhere in the band, the whale cannot be located and this SystemExit is raised.

Solutions

  1. Sample the whale's pixel color: open the image, inspect RGB values where the whale is, and compare against is_navy's thresholds
  2. Adjust the is_navy thresholds (or HERO_BAND fractions) in braille-mark.py to match the actual artwork colors
  3. Re-export the founder sheet with the original navy whale color and layout
  4. Ensure the image is converted to RGB (load_sheet already does `.convert("RGB")`) and that the whale sits within the hero band

Example fix

// before (palette changed to teal)
def is_navy(pixel):
    r, g, b = pixel
    return b > 60 and b > r + 25 and r < 110 and g < 150
// after (loosen to match new palette)
def is_navy(pixel):
    r, g, b = pixel
    return b > 50 and b > r + 15 and r < 130 and g < 170
Defensive patterns

Strategy: validation

Validate before calling

from PIL import Image
img = Image.open("brand/codewhalemarkfinal.png").convert("RGB")
w, h = img.size
px = img.load()
x0, y0 = int(0.0 * w), int(0.0 * h)
found = any(
    (lambda p: p[2] > 60 and p[2] > p[0] + 25 and p[0] < 110 and p[1] < 150)(px[x, y])
    for y in range(y0, h) for x in range(x0, w)
)
assert found, "no navy hero pixels anywhere in sheet; check palette/hero band"

Try / catch

try:
    main()
except SystemExit as e:
    if "no navy hero whale" in str(e):
        raise SystemExit("re-export sheet with the navy whale inside the hero band, or adjust is_navy thresholds")

Prevention

When it happens

Trigger: `main()` calls `hero_coverage()`; the nested scan over the HERO_BAND region finds zero pixels satisfying `b > 60 and b > r + 25 and r < 110 and g < 150` at scripts/brand/braille-mark.py:103, so `xs` is empty.

Common situations: The sheet was re-exported with different colors (e.g. whale rendered in black, teal, or with alpha/anti-aliasing that shifts RGB); the raster was converted to grayscale or CMYK and flattened differently; the hero artwork moved outside the fractional HERO_BAND after a layout change.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15). Data as JSON: /api/errors/fba2036108e353b7. Report an issue: GitHub.

Appendix: source

Thrown at scripts/brand/braille-mark.py:103

        int(band[1] * width),
        int(band[2] * height),
        int(band[3] * height),
    )


def hero_coverage(image: Image.Image) -> tuple[int, int, list[list[float]]]:
    """Navy-darkness coverage of the hero whale crop, each in 0..1."""
    width, height = image.size
    x0, x1, y0, _ = band_box(image, HERO_BAND)
    pixels = image.load()
    xs, ys = [], []
    for y in range(y0, int(HERO_BAND[3] * height)):
        for x in range(x0, x1):
            if is_navy(pixels[x, y]):
                xs.append(x)
                ys.append(y)
    if not xs:
        raise SystemExit("no navy hero whale found in the founder sheet")
    box = (
        max(0, min(xs) - HERO_MARGIN),
        max(0, min(ys) - HERO_MARGIN),
        min(width, max(xs) + HERO_MARGIN + 1),
        min(height, max(ys) + HERO_MARGIN + 1),
    )
    crop = image.crop(box)
    cover = crop.load()
    cw, ch = crop.size
    coverage = []
    for y in range(ch):
        row = []
        for x in range(cw):
            r, g, b = cover[x, y]
            row.append(max(0.0, min(1.0, (180.0 - (r + g + b) / 3.0) / 120.0)))
        coverage.append(row)
    print(f"// hero whale box {box[0]},{box[1]}-{box[2]},{box[3]}", file=sys.stderr)
    return cw, ch, coverage

View on GitHub (pinned to 433685b202)