FAILURE MAP
← Case archive

FA-70391 / GIS polygon topology / Open access

Point classification against a polygon with holes: every hole consulted · case 01

Points inside the second or later hole are reported as interior.

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

ROOT CAUSE

Only the first hole is tested for containment.

VERIFIED REPAIR

At the every hole consulted step restore `for hole in rings[1:]:`, leaving the rest of the model unchanged.

Unsuccessful approach: Only the last hole is tested, so points in earlier holes are still interior.

Case contract

Input [point, rings]: exterior ring then hole rings, closed, integer coordinates. A point on any ring edge (exact cross product 0 and inside the closed segment bounding box) is "boundary". Otherwise a crossing-number test with the half-open rule (a.y > py) != (b.y > py) and ray toward +x decides containment: outside the exterior or inside any hole is "exterior", else "interior".

Why this case matters

Parcel lookup, geofencing and spatial joins classify points against polygons with holes; lakes and courtyards must not count as inside.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
    pt, rings = x
    px, py = pt
    def on_seg(a, b):
        cross = (b[0] - a[0]) * (py - a[1]) - (b[1] - a[1]) * (px - a[0])
        if cross != 0:
            return False
        return min(a[0], b[0]) <= px <= max(a[0], b[0]) and min(a[1], b[1]) <= py <= max(a[1], b[1])
    def inside(ring):
        c = False
        for a, b in zip(ring, ring[1:]):
            if (a[1] > py) != (b[1] > py):
                xi = a[0] + (py - a[1]) * (b[0] - a[0]) / (b[1] - a[1])
                if px < xi:
                    c = not c
        return c
    for ring in rings:
        for a, b in zip(ring, ring[1:]):
            if on_seg(a, b):
                return 'boundary'
    if not inside(rings[0]):
        return 'exterior'
    for hole in rings[1:2]:
        if inside(hole):
            return 'exterior'
    return 'interior'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control #0', [[1, 1], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'interior'), ('control #1', [[3, 3], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'exterior'), ('control #2', [[8, 5], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'exterior'), ('control #3', [[6, 6], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'interior'), ('control #4', [[12, 6], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #5', [[0, 0], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #6', [[2, 3], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #7', [[7, 9], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary')], [('control #3', [[6, 6], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'interior'), ('control #4', [[12, 6], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #5', [[0, 0], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #6', [[2, 3], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #7', [[7, 9], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #8', [[8, 9], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #25', [[4, 2], [[[0, 0], [8, 0], [4, 6], [0, 0]]]], 'interior'), ('regression #30', [[3, 3], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]]]], 'exterior')], [('control #6', [[2, 3], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #7', [[7, 9], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #8', [[8, 9], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #9', [[11, 11], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'interior'), ('control #10', [[13, 5], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'exterior'), ('control #11', [[-1, 12], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'exterior'), ('regression #31', [[8, 5], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]], [[1, 7], [1, 10], [3, 10], [3, 7], [1, 7]]]], 'exterior'), ('regression #38', [[2, 5], [[[5, 0], [10, 5], [5, 10], [0, 5], [5, 0]]]], 'interior')], [('control #9', [[11, 11], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'interior'), ('control #10', [[13, 5], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'exterior'), ('control #11', [[-1, 12], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'exterior'), ('control #12', [[6, 12], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #13', [[5, 2], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #14', [[4, 2], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('regression #35', [[2, 8], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]], [[1, 7], [1, 10], [3, 10], [3, 7], [1, 7]]]], 'exterior'), ('regression #38', [[2, 5], [[[5, 0], [10, 5], [5, 10], [0, 5], [5, 0]]]], 'interior')], [('control #2', [[8, 5], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'exterior'), ('control #13', [[5, 2], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #14', [[4, 2], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #15', [[6, 2], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'interior'), ('control #16', [[9, 3], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #17', [[10, 12], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #18', [[12, 12], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('regression #39', [[4, 5], [[[5, 0], [10, 5], [5, 10], [0, 5], [5, 0]]]], 'interior')]]
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
control #0interiorinteriorPassed
control #1exteriorexteriorPassed
control #2interiorexteriorFailed
control #3interiorinteriorPassed
control #4boundaryboundaryPassed
control #5boundaryboundaryPassed
control #6boundaryboundaryPassed
control #7boundaryboundaryPassed

SHA-256 / 051e3799ce4271c61c9275f1647038af54de219db8a4200e59a7f418f90bdc79

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
    pt, rings = x
    px, py = pt
    def on_seg(a, b):
        cross = (b[0] - a[0]) * (py - a[1]) - (b[1] - a[1]) * (px - a[0])
        if cross != 0:
            return False
        return min(a[0], b[0]) <= px <= max(a[0], b[0]) and min(a[1], b[1]) <= py <= max(a[1], b[1])
    def inside(ring):
        c = False
        for a, b in zip(ring, ring[1:]):
            if (a[1] > py) != (b[1] > py):
                xi = a[0] + (py - a[1]) * (b[0] - a[0]) / (b[1] - a[1])
                if px < xi:
                    c = not c
        return c
    for ring in rings:
        for a, b in zip(ring, ring[1:]):
            if on_seg(a, b):
                return 'boundary'
    if not inside(rings[0]):
        return 'exterior'
    for hole in rings[-1:]:
        if inside(hole):
            return 'exterior'
    return 'interior'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control #0', [[1, 1], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'interior'), ('control #1', [[3, 3], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'exterior'), ('control #2', [[8, 5], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'exterior'), ('control #3', [[6, 6], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'interior'), ('control #4', [[12, 6], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #5', [[0, 0], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #6', [[2, 3], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #7', [[7, 9], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary')], [('control #3', [[6, 6], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'interior'), ('control #4', [[12, 6], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #5', [[0, 0], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #6', [[2, 3], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #7', [[7, 9], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #8', [[8, 9], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #25', [[4, 2], [[[0, 0], [8, 0], [4, 6], [0, 0]]]], 'interior'), ('regression #30', [[3, 3], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]]]], 'exterior')], [('control #6', [[2, 3], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #7', [[7, 9], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #8', [[8, 9], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #9', [[11, 11], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'interior'), ('control #10', [[13, 5], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'exterior'), ('control #11', [[-1, 12], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'exterior'), ('regression #31', [[8, 5], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]], [[1, 7], [1, 10], [3, 10], [3, 7], [1, 7]]]], 'exterior'), ('regression #38', [[2, 5], [[[5, 0], [10, 5], [5, 10], [0, 5], [5, 0]]]], 'interior')], [('control #9', [[11, 11], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'interior'), ('control #10', [[13, 5], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'exterior'), ('control #11', [[-1, 12], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'exterior'), ('control #12', [[6, 12], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #13', [[5, 2], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #14', [[4, 2], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('regression #35', [[2, 8], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]], [[1, 7], [1, 10], [3, 10], [3, 7], [1, 7]]]], 'exterior'), ('regression #38', [[2, 5], [[[5, 0], [10, 5], [5, 10], [0, 5], [5, 0]]]], 'interior')], [('control #2', [[8, 5], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'exterior'), ('control #13', [[5, 2], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #14', [[4, 2], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #15', [[6, 2], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'interior'), ('control #16', [[9, 3], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #17', [[10, 12], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #18', [[12, 12], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('regression #39', [[4, 5], [[[5, 0], [10, 5], [5, 10], [0, 5], [5, 0]]]], 'interior')]]
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
control #0interiorinteriorPassed
control #1interiorexteriorFailed
control #2exteriorexteriorPassed
control #3interiorinteriorPassed
control #4boundaryboundaryPassed
control #5boundaryboundaryPassed
control #6boundaryboundaryPassed
control #7boundaryboundaryPassed

SHA-256 / 5705c74f0e31477f04ae29d8ac2a20e7177b67ea8a95f524de0a9b0feb7df4d4

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
    pt, rings = x
    px, py = pt
    def on_seg(a, b):
        cross = (b[0] - a[0]) * (py - a[1]) - (b[1] - a[1]) * (px - a[0])
        if cross != 0:
            return False
        return min(a[0], b[0]) <= px <= max(a[0], b[0]) and min(a[1], b[1]) <= py <= max(a[1], b[1])
    def inside(ring):
        c = False
        for a, b in zip(ring, ring[1:]):
            if (a[1] > py) != (b[1] > py):
                xi = a[0] + (py - a[1]) * (b[0] - a[0]) / (b[1] - a[1])
                if px < xi:
                    c = not c
        return c
    for ring in rings:
        for a, b in zip(ring, ring[1:]):
            if on_seg(a, b):
                return 'boundary'
    if not inside(rings[0]):
        return 'exterior'
    for hole in rings[1:]:
        if inside(hole):
            return 'exterior'
    return 'interior'
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control #0', [[1, 1], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'interior'), ('control #1', [[3, 3], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'exterior'), ('control #2', [[8, 5], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'exterior'), ('control #3', [[6, 6], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'interior'), ('control #4', [[12, 6], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #5', [[0, 0], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #6', [[2, 3], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #7', [[7, 9], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary')], [('control #3', [[6, 6], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'interior'), ('control #4', [[12, 6], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #5', [[0, 0], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #6', [[2, 3], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #7', [[7, 9], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #8', [[8, 9], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #25', [[4, 2], [[[0, 0], [8, 0], [4, 6], [0, 0]]]], 'interior'), ('regression #30', [[3, 3], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]]]], 'exterior')], [('control #6', [[2, 3], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #7', [[7, 9], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #8', [[8, 9], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #9', [[11, 11], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'interior'), ('control #10', [[13, 5], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'exterior'), ('control #11', [[-1, 12], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'exterior'), ('regression #31', [[8, 5], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]], [[1, 7], [1, 10], [3, 10], [3, 7], [1, 7]]]], 'exterior'), ('regression #38', [[2, 5], [[[5, 0], [10, 5], [5, 10], [0, 5], [5, 0]]]], 'interior')], [('control #9', [[11, 11], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'interior'), ('control #10', [[13, 5], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'exterior'), ('control #11', [[-1, 12], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'exterior'), ('control #12', [[6, 12], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #13', [[5, 2], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #14', [[4, 2], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('regression #35', [[2, 8], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]], [[1, 7], [1, 10], [3, 10], [3, 7], [1, 7]]]], 'exterior'), ('regression #38', [[2, 5], [[[5, 0], [10, 5], [5, 10], [0, 5], [5, 0]]]], 'interior')], [('control #2', [[8, 5], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'exterior'), ('control #13', [[5, 2], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #14', [[4, 2], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #15', [[6, 2], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'interior'), ('control #16', [[9, 3], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #17', [[10, 12], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('control #18', [[12, 12], [[[0, 0], [12, 0], [12, 12], [0, 12], [0, 0]], [[2, 2], [2, 5], [5, 5], [5, 2], [2, 2]], [[7, 3], [7, 9], [10, 9], [10, 3], [7, 3]]]], 'boundary'), ('regression #39', [[4, 5], [[[5, 0], [10, 5], [5, 10], [0, 5], [5, 0]]]], 'interior')]]
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
control #0interiorinteriorPassed
control #1exteriorexteriorPassed
control #2exteriorexteriorPassed
control #3interiorinteriorPassed
control #4boundaryboundaryPassed
control #5boundaryboundaryPassed
control #6boundaryboundaryPassed
control #7boundaryboundaryPassed

SHA-256 / 5991fa65febfda0f0db23fd400056b2b133b2b28df26f52631f5d6a473dd30d5

Verification & scope

Stipulated deterministic toy contract on a bounded input domain; results are rounded as stated and no conformance with any published standard or library is claimed. 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:48:20.419332+00:00.

Case digest / d127b471eac35e0254c3662e816397e6d0dcbbe89ea045568857c520752ac8ea