from fractions import Fraction as F def run(load,check): old={x['i']:x for x in load('C344_DATA.json')['rows']};shem={x['i']:x for x in load('C346_DATA.json')['rows'] if x['both_images_source_matched']};deaths={x['i']:x for x in load('C347_DATA.json')['rows']};fields=[] expected={'E_N':{'N':'N','M':'S','R':'H','H':'F'},'E_N_inverse':{'N':'N','S':'M','H':'R','F':'H'},'J_R':{'R':'R','M':'U'},'J_R_inverse':{'R':'R','U':'M'},'J_M':{'M':'M','R':'V'},'J_M_inverse':{'M':'M','V':'R'}} for x in load('C340_DATA.json')['rows']: if x['rail']!='primary' or x['Shem_mode_sigma']!=0:continue i=x['i'];rec=dict(x['records']);rec.update({'S':shem[i]['SP_Shem'],'U':old[i]['hold_Flood_Noah_matches'][0],'V':old[i]['hold_Noah_Flood_matches'][0],'B':deaths[i]['old_MT_death'],'C':deaths[i]['new_MT_death']});vals={k:v['center'] for k,v in rec.items()};check(f'i{i} distinct11',len(vals)==len(set(vals.values()))==11) maps={};trials=[] for name,anchor,ratio in [('E_N','N',F(25,23)),('J_R','R',F(300,299)),('J_M','M',F(300,299))]: for inverse in [False,True]: label=name+('_inverse' if inverse else '');slope=1/ratio if inverse else ratio;hits={} for key,v in vals.items(): out=vals[anchor]+slope*(v-vals[anchor]);matches=[k for k,z in vals.items() if z==out] check(f'i{i}/{label}/{key} membership',matches==([expected[label][key]] if key in expected[label] else [])) if matches:hits[key]=matches[0] trials.append({'map':label,'input':key,'diagnostic_output':str(out),'matched_source_labels':matches}) maps[label]=hits for name in ['E_N','J_R','J_M']:check(f'i{i}/{name} inverse closure',all(maps[name+'_inverse'][v]==k for k,v in maps[name].items())) check(f'i{i} two E steps',maps['E_N']['R']=='H' and maps['E_N']['H']=='F' and 'F' not in maps['E_N']) fields.append({'i':i,'records':rec,'maps':maps,'trials':trials,'declared_domain_only':True}) return {'step':'C349','fields':fields,'expected_relations':expected,'counts':{'fields':2,'nodes_per_field':11,'map_input_trials':132,'exact_matches_including_fixed_and_inverse':32,'nonidentity_matches_including_inverse':20},'claim':'Partial invertible comparison relations on the explicitly bounded field; not a total source-state group action.','diagnostic_nonmatches_adopted':False}