#!/usr/bin/env python3 """Job #1007 — the return's summary table, generated from splits.json (no recomputation). Groups the attaining positions of each level by their ancestry pattern and prints, per level, the multiplicity, merge depth L, the multiplicity-weighted interior share, the within-level min/max spread and the witness classes with their counts. Writes job1007/table.out with LF endings so the sha256 matches on any platform. """ import json from collections import defaultdict d = json.load(open('job1007/splits.json', encoding='utf-8')) lines = [] def say(s): print(s) lines.append(s) say('%-3s %-5s %-4s %-14s %-10s %-9s %-9s %s' % ('x', 'A_1', 'mult', 'L', 'weighted', 'min', 'max', 'witness classes (share x count, ancestry patterns)')) tot = 0 for x in sorted(d, key=lambda s: int(s)): L = d[x] tot += L['mult'] byshare = defaultdict(lambda: defaultdict(int)) for r in L['rows']: byshare[round(r['share'], 3)][tuple(r['gaps'])] += 1 desc = [] for sh in sorted(byshare, reverse=True): pats = byshare[sh] desc.append('%.3f x%d %s' % (sh, sum(pats.values()), ' | '.join('%s:%d' % (list(k), v) for k, v in sorted(pats.items())))) say('%-3s %-5d %-4d %-14s %-10.3f %-9.3f %-9.3f %s' % (x, L['G2'], L['mult'], str(L['Ls']), L['weighted'], L['min'], L['max'], ' ;; '.join(desc))) say('') say('attaining positions split at x <= 31: %d (+4 single witnesses at 37/41/43 = %d)' % (tot, tot + 4)) with open('job1007/table.out', 'w', encoding='utf-8', newline='\n') as fh: fh.write('\n'.join(lines) + '\n')