"""Read Figure 2's actual vector circles and labeled axis grid from the PDF. Tests the original configuration rather than relying on the caption alone. """ import csv import json from pathlib import Path import numpy as np import pymupdf doc = pymupdf.open('evidence/paper.pdf') page = doc[4] drawings = page.get_drawings() points = [] for d in drawings: r = d['rect'] if d['type']=='fs' and len(d['items'])==4 and 98.9: if 1141 and blocks[-2][0]*blocks[-1][1]>blocks[-1][0]*blocks[-2][1]: b,n=blocks.pop(); a,m=blocks.pop(); blocks.append((a+b,m+n)) fit=np.array([a/n for a,n in blocks for _ in range(n)]) stress=100*np.sqrt(sum((y-fit)**2)/sum(y*y)) assert errors.max()<.02 assert round(stress,1)==34.8 out={'pdf_stress_approx':float(stress),'max_native_coordinate_error':float(errors.max()), 'points':23,'x_tick_scale':float(xscale),'y_tick_scale':float(yscale), 'note':'Drawing order matches released sequence order; axis-calibrated PDF rounding causes small errors.'} Path('results/pdf_plot_check.json').write_text(json.dumps(out,indent=2)+'\n') print(json.dumps(out,indent=2))