import pathlib import re import struct root = pathlib.Path.cwd() img_path = root / 'train-images-idx3-ubyte' label_path = root / 'train-labels-idx1-ubyte' assert img_path.exists(), 'missing train-images-idx3-ubyte fixture' assert label_path.exists(), 'missing train-labels-idx1-ubyte fixture' magic, count, rows, cols = struct.unpack('>IIII', img_path.read_bytes()[:16]) assert (magic, count, rows, cols) == (2051, 10, 8, 8), 'unexpected tiny MNIST image header' lmagic, lcount = struct.unpack('>II', label_path.read_bytes()[:8]) assert (lmagic, lcount) == (2049, 10), 'unexpected tiny MNIST label header' report_path = root / 'report.html' assert report_path.exists() and report_path.stat().st_size > 0, 'missing report.html' report = report_path.read_text(encoding='utf-8', errors='ignore').lower() for token in ['mnist', 'mlp']: assert token in report, f'report missing {token}' assert 'f1' in report, 'report missing f1' assert 'acc' in report or 'accuracy' in report, 'report missing accuracy/acc' assert ( '80/20' in report or '4:1' in report or ('80%' in report and '20%' in report) or ('0.8' in report and '0.2' in report) ), 'report missing 80/20 split evidence' numbers = [float(x) for x in re.findall(r'(?