AstroFrame/tools/check_real_frames.py
2026-10-03 18:29:15 -07:00

15 lines
944 B
Python

"""Assert explicitly labeled real FITS examples against persisted automatic decisions."""
import json,sys
from pathlib import Path
p=json.loads(Path(sys.argv[1] if len(sys.argv)>1 else 'projects/Sample Survey/project.json').read_text(encoding='utf-8'))
if not p['Complete']:
raise SystemExit('Analysis is incomplete; no classification regression result can be reported.')
labels=json.loads(Path('tests/real-frame-labels.json').read_text(encoding='utf-8'))['frames']
by_name={Path(f['Path']).name:f for f in p['Frames']}
failures=0
for label in labels:
f=by_name[label['file']];actual=f['Automatic'];good=actual==label['expected'];failures+=not good
print(f"{'PASS' if good else 'FAIL'} {label['file']}: {actual} -> expected {label['expected']}")
print(' '+f['Cause'])
print(f'{len(labels)-failures}/{len(labels)} real regression examples pass. These examples do not establish general accuracy.')
sys.exit(1 if failures else 0)