from collections import Counter def run(load,check): cum=load('C300_DATA.json')['cumulative_register'];reg=load('C286_DATA.json')['target_register'];hits=[];coverage=[] for c in cum: matches=[] for t in reg: if c['BC']-t['center']==2832: h={'cumulative':c,'regular':t,'gap':8464-t['center']-6};hits.append(h);matches.append(t) coverage.append({'source':c,'required_regular':c['BC']-2832,'matches':matches}) check('38016 source comparisons',len(cum)*len(reg)==38016) check('gap identity for every match',all(12696-h['cumulative']['BC']-1406==h['gap'] for h in hits)) check('source profiles retained',all(h['cumulative']['profile'] in ['MT_ON','LXX_OFF','SP_OFF'] for h in hits)) check('SP companion remains local',all(t.get('rail')!='companion' or t['tradition']=='SP' for t in reg)) check('28 labels18 coordinate matches',len(hits)==28 and len({(h['cumulative']['BC'],h['regular']['center']) for h in hits})==18) check('new Shem context exact',all((h['regular']['Cainan'],h['regular']['Terah60'],h['regular']['full430'])==(0,1,0) for h in hits if h['regular']['tradition']!='MT')) check('no cumulative Noah orSP profile match',all(h['cumulative']['role']!='Noah' and h['cumulative']['profile']!='SP_OFF' for h in hits)) group=Counter((h['regular']['tradition'],h['regular']['role'],h['regular']['Cainan'],h['regular']['Terah60'],h['regular']['full430']) for h in hits) return {'cumulative_coverage':coverage,'all_matches':hits,'comparison_count':len(cum)*len(reg),'labeled_matches':len(hits),'coordinate_matches':len({(h['cumulative']['BC'],h['regular']['center']) for h in hits}),'families':[{'tradition':k[0],'role':k[1],'Cainan':k[2],'Terah60':k[3],'full430':k[4],'count':v} for k,v in sorted(group.items())],'no_new_contexts':True}