junidude14 commited on
Commit
516cdbe
·
verified ·
1 Parent(s): 67d10c6

Archive 4 checkpoints (1-4)

Browse files
paper-releases/pbisc-diffusion/updates/20260930T065633Z-summary-deck-scsemi-final/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/README.md ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # PBISC-Diffusion paper summary deck (2026-09-30, r00)
2
+
3
+ 29-slide English summary of the PBISC-Diffusion (Model 8) paper experiments: title,
4
+ outline, 10 sections (24 content slides), then a Backup divider and 3 backup slides.
5
+ Short keyword lines only; the figures carry the results. Section 10 is planned work.
6
+
7
+ - `PBISC-Diffusion_paper_summary_20260930.pptx`: the deck
8
+ - `PBISC-Diffusion_paper_summary_20260930.pdf`: LibreOffice PDF of the deck
9
+ - `data/slides_spec.json`: slide order, titles, keywords, footnotes, speaker-note text
10
+ - `generate_deck.py`: builds the pptx from `data/slides_spec.json` only (python-pptx)
11
+ - `figures/`: all slide figures (PNG + PDF), made by `tools/sec*.py`
12
+ - `data/sec*.csv`, `data/sec09_slide_text.json`: every plotted or quoted number with its source path
13
+ - `render/`: PDF and 70-dpi slide JPGs for checking
14
+
15
+ ## Rebuild
16
+
17
+ Everything is CPU only; no GPU or checkpoint is touched.
18
+
19
+ ```bash
20
+ cd /home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/presentations/2026-09-30--paper-summary--r00
21
+ # figures + data tables (sec03_common.py and style.py are shared helpers, not run directly)
22
+ for f in sec01_overview sec02_backbone sec03_width_loss sec03_width_bench sec03_panel \
23
+ sec04_sle_benchmark sec04_immicro sec05_condition_space sec05_cells_offmanifold \
24
+ sec05_behcet_direction sec05_shift_cohorts sec06_finetune_method sec07_ft_modes \
25
+ sec07_k_aug sec08_pairs_needed sec09_paired_validation sec10_paired_subset_cohorts; do
26
+ python3 "tools/$f.py" || break
27
+ done
28
+ python3 tools/sync_sec09_text.py # copy regenerated section 9 text into data/slides_spec.json
29
+ python3 generate_deck.py # -> PBISC-Diffusion_paper_summary_20260930.pptx
30
+ soffice --headless --convert-to pdf --outdir render PBISC-Diffusion_paper_summary_20260930.pptx
31
+ pdftoppm -jpeg -r 70 render/PBISC-Diffusion_paper_summary_20260930.pdf render/slide
32
+ cp render/PBISC-Diffusion_paper_summary_20260930.pdf .
33
+ ```
34
+
35
+ `generate_deck.py` stops with an error if a figure is missing, a title does not fit on one
36
+ line, a footnote needs more than 2 lines, or any text contains Korean or placeholder words.
37
+
38
+ ## Notes
39
+
40
+ - Section 9 (few-pair scSemiProfiler comparison) uses all 25 scSemiProfiler draws
41
+ (5 cohorts x 5 draws). If scores change, rerun `tools/sec09_paired_validation.py`, then
42
+ `tools/sync_sec09_text.py`, then check the short footnotes it lists and rebuild.
43
+ - On-slide footnotes are one short line; the full source and method text is in the speaker
44
+ notes (`footnote_full` in the spec).
45
+ - `DRAFT_1150_*`: frozen copy shown at the 2026-09-30 12:00 meeting (23/25 scSemiProfiler
46
+ draws, long footnotes). Superseded by the files above.
47
+ - The ImMicro external-reference slide (made by `tools/sec04_immicro.py`) sits at the end of
48
+ section 5, after refcal is introduced.
49
+
50
+ ## Sources
51
+
52
+ Final model: `runs/f01_6k_1x_seed20260627` (epoch 16, EMA). Scores and receipts come from
53
+ `plans/utility_studies_final6k_20260925/`, `plans/paired_finetune_intradataset_20260927/`,
54
+ `plans/immicro_scsemi_comparison_20260927/`, `plans/floor01_campaign_20260923/`,
55
+ `analysis/scsemi_benchmark_diffusion_20260913/` and the run folders named in each
56
+ `data/sec*.csv`. Manuscript: `/home/sj_server_1/PBISC/paper-release-20260928/manuscript/`.
paper-releases/pbisc-diffusion/updates/20260930T065633Z-summary-deck-scsemi-final/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/generate_deck.py ADDED
@@ -0,0 +1,340 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Build the PBISC-Diffusion paper-summary deck.
3
+
4
+ Reads data/slides_spec.json only and writes
5
+ PBISC-Diffusion_paper_summary_20260930.pptx next to this script.
6
+ Rerunnable; CPU only.
7
+
8
+ Design rules (user request: plain, clean, no decoration):
9
+ 16:9 13.333 x 7.5 in, white background, Arial only.
10
+ Text #1A1A1A, footnotes / labels #6E6E6E. Colour only inside figures.
11
+ Title 26 pt bold at (0.45, 0.30); section label 11 pt grey, top right.
12
+ Figures fill x 0.45-12.9, y 1.05-6.75, aspect kept, never cropped.
13
+ Keywords 16 pt, max 3 lines of content, beside or below the figure.
14
+ Footnote 9 pt grey from y 7.0, at most 2 lines; slide number bottom right.
15
+
16
+ The script measures text with the Arial TrueType metrics and fails loudly
17
+ if a title, keyword block or footnote would not fit.
18
+ """
19
+ from __future__ import annotations
20
+
21
+ import json
22
+ import re
23
+ import sys
24
+ from pathlib import Path
25
+
26
+ from PIL import Image, ImageFont
27
+ from pptx import Presentation
28
+ from pptx.dml.color import RGBColor
29
+ from pptx.enum.text import MSO_ANCHOR, PP_ALIGN
30
+ from pptx.util import Emu, Inches, Pt
31
+
32
+ DECK = Path(__file__).resolve().parent
33
+ SPEC = DECK / "data" / "slides_spec.json"
34
+
35
+ # ---------------------------------------------------------------- geometry
36
+ SLIDE_W, SLIDE_H = 13.333, 7.5
37
+ X0, X1 = 0.45, 12.9 # content left / right
38
+ Y0, YFIG1 = 1.05, 6.75 # figure top / bottom limit
39
+ KW_BOTTOM = 6.85 # keywords below a figure must end here
40
+ FOOT_Y = 7.0 # footnote top
41
+ FOOT_W = 11.6 # leaves room for the slide number
42
+ GAP_BELOW = 0.20 # figure -> keywords (below)
43
+ GAP_RIGHT = 0.35 # figure -> keyword column (right)
44
+ MIN_COL = 2.9 # narrowest keyword column
45
+ FIG_GAP = 0.25 # between two figures
46
+
47
+ INK = RGBColor(0x1A, 0x1A, 0x1A)
48
+ GREY = RGBColor(0x6E, 0x6E, 0x6E)
49
+ WHITE = RGBColor(0xFF, 0xFF, 0xFF)
50
+ FONT = "Arial"
51
+
52
+ TITLE_PT, LABEL_PT, KW_PT, FOOT_PT, NUM_PT = 26, 11, 16, 9, 9
53
+ AGENDA_PT, COVER_PT, COVER_SUB_PT = 18, 36, 18
54
+ LINE = 1.2 # line height / font size used for layout
55
+ KW_PARA_GAP_PT = 6
56
+
57
+ _FONT_FILES = {
58
+ False: "/usr/share/fonts/truetype/msttcorefonts/Arial.ttf",
59
+ True: "/usr/share/fonts/truetype/msttcorefonts/arialbd.ttf",
60
+ }
61
+ _font_cache: dict = {}
62
+
63
+ HANGUL = re.compile("[ᄀ-ᇿ㄰-㆏가-힣]")
64
+
65
+
66
+ def text_w_in(text: str, pt: float, bold: bool = False) -> float:
67
+ """Rendered width of one line in inches (Arial metrics)."""
68
+ key = bold
69
+ if key not in _font_cache:
70
+ _font_cache[key] = ImageFont.truetype(_FONT_FILES[bold], 1000)
71
+ return _font_cache[key].getlength(text) * pt / 1000.0 / 72.0
72
+
73
+
74
+ def wrap(text: str, pt: float, width_in: float, bold: bool = False) -> list[str]:
75
+ words, lines, cur = text.split(" "), [], ""
76
+ for w in words:
77
+ trial = w if not cur else cur + " " + w
78
+ if text_w_in(trial, pt, bold) <= width_in:
79
+ cur = trial
80
+ else:
81
+ if cur:
82
+ lines.append(cur)
83
+ cur = w
84
+ if cur:
85
+ lines.append(cur)
86
+ return lines
87
+
88
+
89
+ def line_h(pt: float) -> float:
90
+ return pt * LINE / 72.0
91
+
92
+
93
+ def kw_block_h(keywords: list[str], width_in: float) -> float:
94
+ n_lines = sum(len(wrap(k, KW_PT, width_in)) for k in keywords)
95
+ return n_lines * line_h(KW_PT) + (len(keywords) - 1) * KW_PARA_GAP_PT / 72.0
96
+
97
+
98
+ # ---------------------------------------------------------------- helpers
99
+ def check_text(s: str, where: str) -> None:
100
+ if HANGUL.search(s):
101
+ sys.exit(f"Korean text in {where}: {s!r}")
102
+ for bad in ("TODO", "TBD", "lorem", "xxxx", "PLACEHOLDER"):
103
+ if bad.lower() in s.lower():
104
+ sys.exit(f"placeholder text {bad!r} in {where}: {s!r}")
105
+
106
+
107
+ def white_bg(slide) -> None:
108
+ fill = slide.background.fill
109
+ fill.solid()
110
+ fill.fore_color.rgb = WHITE
111
+
112
+
113
+ def add_text(slide, x, y, w, h, paras, pt, color=INK, bold=False,
114
+ align=PP_ALIGN.LEFT, anchor=MSO_ANCHOR.TOP, wrap_text=True,
115
+ space_before_pt=0):
116
+ """paras: list of strings, one paragraph each."""
117
+ tb = slide.shapes.add_textbox(Inches(x), Inches(y), Inches(w), Inches(h))
118
+ tf = tb.text_frame
119
+ tf.word_wrap = wrap_text
120
+ tf.auto_size = None
121
+ tf.margin_left = tf.margin_right = tf.margin_top = tf.margin_bottom = Emu(0)
122
+ tf.vertical_anchor = anchor
123
+ for i, text in enumerate(paras):
124
+ p = tf.paragraphs[0] if i == 0 else tf.add_paragraph()
125
+ p.alignment = align
126
+ p.line_spacing = 1.0
127
+ if i > 0 and space_before_pt:
128
+ p.space_before = Pt(space_before_pt)
129
+ r = p.add_run()
130
+ r.text = text
131
+ f = r.font
132
+ f.name = FONT
133
+ f.size = Pt(pt)
134
+ f.bold = bold
135
+ f.color.rgb = color
136
+ return tb
137
+
138
+
139
+ def add_title(slide, title: str, label: str | None) -> None:
140
+ label_w = text_w_in(label, LABEL_PT) if label else 0.0
141
+ room = (X1 - X0) - (label_w + 0.3 if label else 0.0)
142
+ tw = text_w_in(title, TITLE_PT, bold=True)
143
+ if tw > room:
144
+ sys.exit(f"title too long ({tw:.2f} > {room:.2f} in): {title!r}")
145
+ # title box stops short of the section label so the two never overlap
146
+ add_text(slide, X0, 0.30, min(12.4, room), 0.5, [title], TITLE_PT,
147
+ bold=True, wrap_text=False)
148
+ if label:
149
+ # baseline of the label aligned with the title baseline
150
+ asc = 0.905
151
+ y = 0.30 + asc * TITLE_PT / 72.0 - asc * LABEL_PT / 72.0
152
+ add_text(slide, X1 - label_w - 0.05, y, label_w + 0.05, 0.25, [label],
153
+ LABEL_PT,
154
+ color=GREY, align=PP_ALIGN.RIGHT, wrap_text=False)
155
+
156
+
157
+ def add_footer(slide, footnote: str | None, number: int) -> None:
158
+ if footnote:
159
+ lines = wrap(footnote, FOOT_PT, FOOT_W)
160
+ if len(lines) > 2:
161
+ sys.exit(f"footnote needs {len(lines)} lines (max 2): {footnote!r}")
162
+ add_text(slide, X0, FOOT_Y, FOOT_W, 2 * line_h(FOOT_PT) + 0.02,
163
+ [footnote], FOOT_PT, color=GREY)
164
+ add_text(slide, X1 - 0.6, FOOT_Y, 0.6, line_h(NUM_PT), [str(number)],
165
+ NUM_PT, color=GREY, align=PP_ALIGN.RIGHT, wrap_text=False)
166
+
167
+
168
+ def add_notes(slide, s: dict) -> None:
169
+ parts = []
170
+ if s.get("say"):
171
+ parts.append(s["say"])
172
+ full = s.get("footnote_full")
173
+ if full and full != s.get("footnote"):
174
+ parts.append("Full footnote: " + full)
175
+ if s.get("sources"):
176
+ parts.append("Sources: " + s["sources"])
177
+ if parts:
178
+ slide.notes_slide.notes_text_frame.text = "\n\n".join(parts)
179
+
180
+
181
+ # ---------------------------------------------------------------- layout
182
+ def aspect(path: Path) -> float:
183
+ with Image.open(path) as im:
184
+ w, h = im.size
185
+ return w / h
186
+
187
+
188
+ def fit(total_aspect: float, extra_w: float, wmax: float, hmax: float):
189
+ """Largest (w, h) with w = h * total_aspect + extra_w inside the box."""
190
+ h = min(hmax, (wmax - extra_w) / total_aspect)
191
+ return h * total_aspect + extra_w, h
192
+
193
+
194
+ def plan(aspects: list[float], keywords: list[str], layout: str):
195
+ """Return dict with figure height/width and keyword placement."""
196
+ n = len(aspects)
197
+ tot = sum(aspects)
198
+ extra = FIG_GAP * (n - 1)
199
+ full_w, full_h = X1 - X0, YFIG1 - Y0
200
+ options = []
201
+ if not keywords:
202
+ w, h = fit(tot, extra, full_w, full_h)
203
+ return {"mode": "none", "w": w, "h": h}
204
+ # keywords below
205
+ kh = kw_block_h(keywords, full_w)
206
+ hmax = min(full_h, KW_BOTTOM - GAP_BELOW - kh - Y0)
207
+ w, h = fit(tot, extra, full_w, hmax)
208
+ kh = kw_block_h(keywords, full_w) # keywords sit at the text margin X0
209
+ if Y0 + h + GAP_BELOW + kh <= KW_BOTTOM + 1e-6:
210
+ options.append({"mode": "below", "w": w, "h": h, "area": w * h,
211
+ "kw_w": full_w, "kw_h": kh})
212
+ # keywords right
213
+ w, h = fit(tot, extra, full_w - GAP_RIGHT - MIN_COL, full_h)
214
+ col = X1 - (X0 + w) - GAP_RIGHT
215
+ kh = kw_block_h(keywords, col)
216
+ if kh <= full_h:
217
+ options.append({"mode": "right", "w": w, "h": h, "area": w * h,
218
+ "kw_w": col, "kw_h": kh})
219
+ if not options:
220
+ sys.exit(f"no layout fits keywords {keywords!r}")
221
+ best = max(options, key=lambda o: o["area"])
222
+ if layout == "figure_keywords":
223
+ right = [o for o in options if o["mode"] == "right"]
224
+ if right and right[0]["area"] * 1.15 >= best["area"]:
225
+ best = right[0]
226
+ return best
227
+
228
+
229
+ def build_content(prs, s: dict, number: int) -> None:
230
+ slide = prs.slides.add_slide(prs.slide_layouts[6])
231
+ white_bg(slide)
232
+ for fld in ("title", "footnote", "section_label"):
233
+ if s.get(fld):
234
+ check_text(s[fld], f"slide {number} {fld}")
235
+ kws = s.get("keywords", [])
236
+ if len(kws) > 3:
237
+ sys.exit(f"slide {number}: more than 3 keywords")
238
+ for k in kws:
239
+ check_text(k, f"slide {number} keyword")
240
+ add_title(slide, s["title"], s.get("section_label"))
241
+
242
+ paths = [DECK / f for f in s["figures"]]
243
+ for p in paths:
244
+ if not p.is_file():
245
+ sys.exit(f"slide {number}: missing figure {p}")
246
+ asp = [aspect(p) for p in paths]
247
+ L = plan(asp, kws, s.get("layout", "full"))
248
+ w, h = L["w"], L["h"]
249
+ if L["mode"] == "below":
250
+ fx = X0 + ((X1 - X0) - w) / 2.0 # centred; keywords at the text margin
251
+ else:
252
+ fx = X0
253
+ fy = Y0
254
+ x = fx
255
+ for p, a in zip(paths, asp):
256
+ pw = h * a
257
+ slide.shapes.add_picture(str(p), Inches(x), Inches(fy),
258
+ Inches(pw), Inches(h))
259
+ x += pw + FIG_GAP
260
+ assert fy + h <= YFIG1 + 1e-6 and fx + w <= X1 + 1e-6, s["title"]
261
+
262
+ if L["mode"] == "below":
263
+ add_text(slide, X0, fy + h + GAP_BELOW, L["kw_w"], L["kw_h"] + 0.05,
264
+ kws, KW_PT, space_before_pt=KW_PARA_GAP_PT)
265
+ elif L["mode"] == "right":
266
+ kx = fx + w + GAP_RIGHT
267
+ add_text(slide, kx, fy + 0.15, L["kw_w"], L["kw_h"] + 0.05, kws,
268
+ KW_PT, space_before_pt=KW_PARA_GAP_PT)
269
+ add_footer(slide, s.get("footnote"), number)
270
+ add_notes(slide, s)
271
+ print(f"{number:>2} {L['mode']:<5} fig {w:5.2f}x{h:4.2f} in {s['title']}")
272
+
273
+
274
+ def build_title(prs, s: dict) -> None:
275
+ slide = prs.slides.add_slide(prs.slide_layouts[6])
276
+ white_bg(slide)
277
+ check_text(s["title"] + s.get("subtitle", ""), "title slide")
278
+ if text_w_in(s["title"], COVER_PT, bold=True) > X1 - X0:
279
+ sys.exit("cover title too long")
280
+ add_text(slide, X0, 2.95, X1 - X0, 0.7, [s["title"]], COVER_PT, bold=True,
281
+ wrap_text=False)
282
+ if s.get("subtitle"):
283
+ add_text(slide, X0, 3.8, X1 - X0, 0.4, [s["subtitle"]], COVER_SUB_PT,
284
+ color=GREY, wrap_text=False)
285
+
286
+
287
+ def build_agenda(prs, s: dict, number: int) -> None:
288
+ slide = prs.slides.add_slide(prs.slide_layouts[6])
289
+ white_bg(slide)
290
+ add_title(slide, s["title"], None)
291
+ items = s["items"]
292
+ if len(items) != 10:
293
+ sys.exit("agenda must list 10 sections")
294
+ step = 0.52
295
+ for i, item in enumerate(items):
296
+ check_text(item, "agenda")
297
+ y = 1.3 + i * step
298
+ add_text(slide, X0, y, 0.45, 0.35, [str(i + 1)], AGENDA_PT, color=GREY,
299
+ align=PP_ALIGN.RIGHT, wrap_text=False)
300
+ add_text(slide, X0 + 0.65, y, 10.5, 0.35, [item], AGENDA_PT,
301
+ wrap_text=False)
302
+ add_footer(slide, None, number)
303
+
304
+
305
+ def build_divider(prs, s: dict, number: int) -> None:
306
+ slide = prs.slides.add_slide(prs.slide_layouts[6])
307
+ white_bg(slide)
308
+ check_text(s["title"], "divider")
309
+ add_text(slide, X0, 2.95, X1 - X0, 0.7, [s["title"]], COVER_PT, bold=True,
310
+ wrap_text=False)
311
+ add_footer(slide, None, number)
312
+
313
+
314
+ def main() -> None:
315
+ spec = json.loads(SPEC.read_text())
316
+ out = DECK / spec["deck"]["output_pptx"]
317
+ prs = Presentation()
318
+ prs.slide_width = Inches(SLIDE_W)
319
+ prs.slide_height = Inches(SLIDE_H)
320
+ for i, s in enumerate(spec["slides"], start=1):
321
+ kind = s["kind"]
322
+ if kind == "title":
323
+ build_title(prs, s)
324
+ print(f"{i:>2} title {s['title']}")
325
+ elif kind == "agenda":
326
+ build_agenda(prs, s, i)
327
+ print(f"{i:>2} agenda {s['title']}")
328
+ elif kind == "divider":
329
+ build_divider(prs, s, i)
330
+ print(f"{i:>2} divider {s['title']}")
331
+ elif kind == "content":
332
+ build_content(prs, s, i)
333
+ else:
334
+ sys.exit(f"unknown slide kind {kind!r}")
335
+ prs.save(out)
336
+ print(f"wrote {out} ({len(spec['slides'])} slides)")
337
+
338
+
339
+ if __name__ == "__main__":
340
+ main()
paper-releases/pbisc-diffusion/updates/20260930T065633Z-summary-deck-scsemi-final/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/tools/build_archive_request.py ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Archive-maintenance request for the paper summary deck (PBISC-Diffusion paper, pbisc-diffusion).
3
+
4
+ Follows paper-release-20260928/maintenance/POLICY.md. Payloads: the deck (pptx + PDF, final and the frozen
5
+ 12:00 draft), its builder, section figure scripts, figures, the number tables every figure and quoted value
6
+ reads, the slide spec and the copied server_2 run-status snapshots used for the loss curves.
7
+ Not uploaded: data/refs (third-party paper text and upstream SDD code kept only for checking the backbone
8
+ table) and render/ (contact-sheet JPGs; the PDF is the rendered record).
9
+
10
+ Optionally merges another request (for example the paired fine-tuning request) so both go out as one delta.
11
+ usage: build_archive_request.py OUT.json [OTHER_REQUEST.json]
12
+ """
13
+ from __future__ import annotations
14
+
15
+ import glob
16
+ import json
17
+ import sys
18
+ from pathlib import Path
19
+
20
+ D = Path(__file__).resolve().parents[1]
21
+
22
+
23
+ def files(patterns):
24
+ out = set()
25
+ for p in patterns:
26
+ for f in glob.glob(str(D / p), recursive=True):
27
+ q = Path(f)
28
+ if q.is_file() and not q.is_symlink() and "__pycache__" not in q.parts:
29
+ out.add(str(q))
30
+ return sorted(out)
31
+
32
+
33
+ def main(out: str, other: str | None = None) -> int:
34
+ assets = []
35
+
36
+ def add(paths, kind):
37
+ for p in paths:
38
+ assets.append({"host": "server_1", "source": p, "kind": kind, "state": "completed"})
39
+
40
+ add(files(["*.pptx", "*.pdf"]), "report")
41
+ add(files(["README.md"]), "document")
42
+ add(files(["generate_deck.py", "tools/*.py"]), "code")
43
+ add(files(["figures/*.png", "figures/*.pdf", "figures/*.svg"]), "figure")
44
+ add(files(["data/*.csv"]), "table")
45
+ add(files(["data/*.json"]), "config")
46
+ add(files(["data/sec03_server2_snapshots/**/*.json"]), "log")
47
+ req = {
48
+ "project_id": "pbisc-diffusion",
49
+ "summary": (
50
+ "Paper summary deck 2026-09-30 (presentations/2026-09-30--paper-summary--r00): 29 English slides over the "
51
+ "ten paper sections (model, backbone, width/context/panel ablation, SLE vs scSemiProfiler, real bulk vs "
52
+ "pseudobulk, paired fine-tuning, LoRA and K ablations, pairs needed, five-cohort validation with all 25 "
53
+ "scSemiProfiler draws, planned paired-subset cohorts). Deck, PDF, frozen 12:00 draft, builder, figure "
54
+ "scripts, figures and every plotted/quoted number table. CPU only; no new checkpoint or inference."),
55
+ "assets": assets,
56
+ "inference_locations": [],
57
+ }
58
+ if other:
59
+ o = json.loads(Path(other).read_text())
60
+ assert o["project_id"] == "pbisc-diffusion"
61
+ req["summary"] = req["summary"] + " || " + o["summary"]
62
+ req["assets"] += o["assets"]
63
+ req["inference_locations"] += o.get("inference_locations", [])
64
+ Path(out).write_text(json.dumps(req, indent=1))
65
+ kinds = {}
66
+ for a in req["assets"]:
67
+ kinds[a["kind"]] = kinds.get(a["kind"], 0) + 1
68
+ print(json.dumps({"assets": len(req["assets"]), "by_kind": kinds,
69
+ "locations": len(req["inference_locations"])}, indent=1))
70
+ return 0
71
+
72
+
73
+ if __name__ == "__main__":
74
+ sys.exit(main(*sys.argv[1:3]))
paper-releases/pbisc-diffusion/updates/20260930T065633Z-summary-deck-scsemi-final/diffusion/dataset/server_1/model8/presentations/2026-09-30--paper-summary--r00/tools/sec01_overview.py ADDED
@@ -0,0 +1,628 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Section 1 (model overview) figures for the 2026-09-30 paper-summary deck.
2
+
3
+ Outputs (deck folder only):
4
+ figures/sec01_fig1a_denoiser.{svg,png,pdf} deck redraw of manuscript Fig. 1a with slide-size labels
5
+ figures/sec01_fig1b_inference.{svg,png,pdf} deck redraw of manuscript Fig. 1b with slide-size labels
6
+ figures/sec01_corpus.{png,pdf} pretraining corpus: cells per dataset + recipes per K
7
+ figures/sec01_slide_a.{png,pdf} slide (a) composite, exactly 12.3 in wide
8
+ data/sec01_corpus_datasets.csv, data/sec01_recipe_k.csv, data/sec01_model_numbers.csv,
9
+ data/sec01_fig1_label_pt.csv (on-slide point size of every text line in the two redraws)
10
+
11
+ The manuscript SVG is only read. The deck copies change label sizes, drop the panel letters and the
12
+ legend row, widen a few boxes so the larger labels fit, and (panel b) say that cells differ by x_T and by
13
+ the Bernoulli support draw (drawn read-out, manuscript Methods). CPU only; every number is read from the
14
+ source files named below.
15
+ """
16
+ import html
17
+ import json
18
+ import re
19
+ import sys
20
+ from collections import defaultdict
21
+ from pathlib import Path
22
+
23
+ DECK = Path("/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion/presentations/2026-09-30--paper-summary--r00")
24
+ sys.path.insert(0, str(DECK / "tools"))
25
+ import style # noqa: E402
26
+
27
+ import cairosvg # 2.9.1, the renderer recorded in fig01_architecture.provenance.json # noqa: E402
28
+ import fitz # PyMuPDF, only to check page sizes # noqa: E402
29
+ import matplotlib.pyplot as plt # noqa: E402
30
+ import numpy as np # noqa: E402
31
+ import pandas as pd # noqa: E402
32
+ from PIL import ImageFont # noqa: E402
33
+
34
+ FIG = DECK / "figures"
35
+ DATA = DECK / "data"
36
+
37
+ MS = Path("/home/sj_server_1/PBISC/paper-release-20260928/manuscript")
38
+ FIG1_SVG = MS / "figures/fig01_architecture.svg"
39
+ METHODS = MS / "sections/methods.tex"
40
+ SRC_MANIFEST = Path("/home/sj_server_1/PBISC/immun-pbmc-fm/model_7_no_annotation_sh_hwang/data/e2_full_source/dataset_manifest.json")
41
+ IDX_MANIFEST = Path("/home/sj_server_1/PBISC/immun-pbmc-fm/model_7_no_annotation_sh_hwang/data/e2_full_index/dataset_manifest.json")
42
+ M8 = Path("/home/sj_server_1/PBISC/immun-pbmc-fm/model_8_sparse_data_diffusion")
43
+ RUN = M8 / "runs/f01_6k_1x_seed20260627"
44
+ CFG = RUN / "effective_config.json"
45
+ STATUS = RUN / "RUN_STATUS.json"
46
+ CONTRACT = RUN / "ALLCELL_DATA_CONTRACT.json"
47
+ PLAN = M8 / "plans/full_recipe_allcells_6k_broad_20260909"
48
+ TOPUP_CSV = PLAN / "topup_v1/topup_recipes.csv"
49
+ SHARD_OFFSETS = PLAN / "topup_v1/shard_offsets.csv"
50
+ COVERAGE = PLAN / "coverage_v1/summary.json"
51
+ MODEL_PY = M8 / "src/pbisc_sdd/model.py"
52
+
53
+ # Short readable labels for the 22 corpus datasets (text only; counts come from the manifest).
54
+ LABELS = {
55
+ "001": "Perez SLE", "005": "OneK1K", "006": "AIDA", "007": "Miao RA", "009": "AIFI Health Atlas",
56
+ "010": "ScaleBio PBMC", "053": "Hao CITE-seq", "058": "COVID immunodeficiency",
57
+ "061": "RA at-risk (Savage)", "065": "Sound Life", "071": "JDM CITE-seq", "074": "COMBAT",
58
+ "081": "COVID atlas (Seq-Well)", "093": "SARS-CoV-2 local/systemic", "200": "Immunobiology of Aging",
59
+ "202": "Fatal COVID time course", "203": "Indonesia diversity", "204": "cHSPC aging / MDS",
60
+ "300b": "DRESS / DiHS", "301": "SLE B-cell study", "302": "SLE IL-36 stim", "304": "Parse 10M cytokine",
61
+ }
62
+
63
+ # On-slide sizes (inches). Slide (b): one keyword line under the diagram leaves about 5.25 in.
64
+ A_HEIGHT_IN = 5.25
65
+ SLIDE_A_H = 5.30 # composite height: leaves room for one keyword line in the 5.7-in content area
66
+ W_FULL = style.FULL[0] # 12.3 in
67
+
68
+ # ============================================================== SVG copy with slide-size labels
69
+ FONT_R = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 100)
70
+ FONT_B = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 100)
71
+ LS = 0.5 # letter-spacing set on the outer <g> of the figure
72
+ SKEW = 0.2126
73
+
74
+
75
+ def text_w(s, fs, bold=False):
76
+ s = html.unescape(s)
77
+ return (FONT_B if bold else FONT_R).getlength(s) * fs / 100.0 + LS * len(s)
78
+
79
+
80
+ def attr(a, name):
81
+ m = re.search(rf'(?<![\w-]){name}="([^"]*)"', a)
82
+ return m.group(1) if m else None
83
+
84
+
85
+ def set_attr(a, name, val):
86
+ new, n = re.subn(rf'(?<![\w-]){name}="[^"]*"', f'{name}="{val}"', a, count=1)
87
+ assert n == 1, (name, a)
88
+ return new
89
+
90
+
91
+ def fmt(v):
92
+ return f"{v:.2f}".rstrip("0").rstrip(".")
93
+
94
+
95
+ def map_d(d, fx, fy):
96
+ """Map absolute M/L/H/V/Z path data (one coordinate group per command, as in the manuscript SVG)."""
97
+ segs = []
98
+ for cmd, args in re.findall(r"([MLHVZ])([^MLHVZ]*)", d):
99
+ nums = [float(v) for v in re.findall(r"-?\d+(?:\.\d+)?", args)]
100
+ if cmd in "ML":
101
+ assert len(nums) == 2, d
102
+ segs.append(f"{cmd}{fmt(fx(nums[0]))},{fmt(fy(nums[1]))}")
103
+ elif cmd == "H":
104
+ assert len(nums) == 1, d
105
+ segs.append(f"H{fmt(fx(nums[0]))}")
106
+ elif cmd == "V":
107
+ assert len(nums) == 1, d
108
+ segs.append(f"V{fmt(fy(nums[0]))}")
109
+ else:
110
+ segs.append("Z")
111
+ return " ".join(segs)
112
+
113
+
114
+ def d_xs(d):
115
+ toks = re.findall(r"[MLHVZ]|-?\d+(?:\.\d+)?", d)
116
+ xs, cmd, i = [], None, 0
117
+ while i < len(toks):
118
+ t = toks[i]
119
+ if t in "MLHVZ":
120
+ cmd = t
121
+ i += 1
122
+ elif cmd in "ML":
123
+ xs.append(float(t))
124
+ i += 2
125
+ elif cmd == "H":
126
+ xs.append(float(t))
127
+ i += 1
128
+ else:
129
+ i += 1
130
+ return xs
131
+
132
+
133
+ def piecewise(knots):
134
+ xs = np.array([k[0] for k in knots], float)
135
+ ys = np.array([k[1] for k in knots], float)
136
+
137
+ def X(x):
138
+ if x <= xs[0]:
139
+ return x + (ys[0] - xs[0])
140
+ if x >= xs[-1]:
141
+ return x + (ys[-1] - xs[-1])
142
+ return float(np.interp(x, xs, ys))
143
+ return X
144
+
145
+
146
+ # Panel a: widen the Expression column (+36) and the Conditioning column (+20); the main column only shifts.
147
+ X_A = piecewise([(24, 24), (232, 268), (1184, 1220), (1416, 1472)])
148
+ X_ID = piecewise([(0, 0), (1, 1)])
149
+
150
+ TOKEN = re.compile(
151
+ r'<g transform="matrix\(1,0,-0\.2126,1,(?P<gtx>[-\d.]+),0\)">(?P<ginner>.*?)</g>'
152
+ r'|<text (?P<tattrs>[^>]*)>(?P<tbody>.*?)</text>'
153
+ r'|<path (?P<pattrs>[^>]*)/>')
154
+ INNER_TEXT = re.compile(r'<text (?P<attrs>[^>]*)>(?P<body>.*?)</text>')
155
+ INNER_PATH = re.compile(r'<path (?P<attrs>[^>]*)/>')
156
+
157
+
158
+ def process_text_line(line, X, target=None, mode="c", dy=0.0, ax_fixed=None):
159
+ """Rescale one visual text line (several runs, skew groups, hat paths) about its anchor.
160
+ target: new main font size (None keeps it); mode 'c' centres on the old centre, 'l' keeps the left edge;
161
+ ax_fixed: old-coordinate centre to use instead of the measured one (re-centres a line in its box)."""
162
+ runs = []
163
+ for m in TOKEN.finditer(line):
164
+ if m.group("gtx") is not None:
165
+ t = INNER_TEXT.search(m.group("ginner"))
166
+ runs.append(dict(attrs=t.group("attrs"), body=t.group("body")))
167
+ elif m.group("tattrs") is not None:
168
+ runs.append(dict(attrs=m.group("tattrs"), body=m.group("tbody")))
169
+ for r in runs:
170
+ a = r["attrs"]
171
+ r.update(x=float(attr(a, "x")), y=float(attr(a, "y")), fs=float(attr(a, "font-size")),
172
+ bold=attr(a, "font-weight") == "700", anchor=attr(a, "text-anchor") or "start")
173
+ r["w"] = text_w(r["body"], r["fs"], r["bold"])
174
+ fs0 = max(r["fs"] for r in runs)
175
+ yb = next(r["y"] for r in runs if r["fs"] == fs0)
176
+ if any(r["anchor"] in ("middle", "end") for r in runs):
177
+ assert len(runs) == 1, line
178
+ ax_old = runs[0]["x"]
179
+ extent = (runs[0]["x"] - runs[0]["w"] / 2, runs[0]["x"] + runs[0]["w"] / 2) if runs[0]["anchor"] == "middle" \
180
+ else (runs[0]["x"] - runs[0]["w"], runs[0]["x"])
181
+ else:
182
+ x0 = min(r["x"] for r in runs)
183
+ x1 = max(r["x"] + r["w"] for r in runs)
184
+ extent = (x0, x1)
185
+ ax_old = x0 if mode == "l" else (x0 + x1) / 2
186
+ f = (target / fs0) if target else 1.0
187
+ # the measured centre goes to the mapped box centre when one is given
188
+ ax_new = X(ax_fixed) if ax_fixed is not None else X(ax_old)
189
+ yb_new = yb + dy
190
+ fx = lambda x: ax_new + (x - ax_old) * f # noqa: E731
191
+ fy = lambda y: yb_new + (y - yb) * f # noqa: E731
192
+
193
+ def fix_text(a):
194
+ x, y, fs = float(attr(a, "x")), float(attr(a, "y")), float(attr(a, "font-size"))
195
+ a = set_attr(a, "x", fmt(fx(x)))
196
+ a = set_attr(a, "y", fmt(fy(y)))
197
+ return set_attr(a, "font-size", fmt(fs * f)), fy(y)
198
+
199
+ def fix_path(a):
200
+ return set_attr(a, "d", map_d(attr(a, "d"), fx, fy))
201
+
202
+ def repl(m):
203
+ if m.group("gtx") is not None:
204
+ inner = m.group("ginner")
205
+ t = INNER_TEXT.search(inner)
206
+ ta, ynew = fix_text(t.group("attrs"))
207
+ inner = inner.replace(t.group(0), f'<text {ta}>{t.group("body")}</text>')
208
+ inner = INNER_PATH.sub(lambda p: f'<path {fix_path(p.group("attrs"))}/>', inner)
209
+ return f'<g transform="matrix(1,0,-0.2126,1,{fmt(SKEW * ynew)},0)">{inner}</g>'
210
+ if m.group("tattrs") is not None:
211
+ ta, _ = fix_text(m.group("tattrs"))
212
+ return f'<text {ta}>{m.group("tbody")}</text>'
213
+ return f'<path {fix_path(m.group("pattrs"))}/>'
214
+
215
+ new = TOKEN.sub(repl, line)
216
+ w_new = (extent[1] - extent[0]) * f
217
+ info = dict(fs_old=fs0, fs_new=fs0 * f, width_new=w_new, center_new=fx((extent[0] + extent[1]) / 2),
218
+ text=" ".join(html.unescape(r["body"]) for r in runs))
219
+ return new, info
220
+
221
+
222
+ def process_geometry_line(line, X):
223
+ def rect(m):
224
+ a = m.group(1)
225
+ x, w = float(attr(a, "x")), float(attr(a, "width"))
226
+ a = set_attr(a, "x", fmt(X(x)))
227
+ a = set_attr(a, "width", fmt(X(x + w) - X(x)))
228
+ return f"<rect {a}/>"
229
+
230
+ def circ(m):
231
+ a = m.group(1)
232
+ return f'<circle {set_attr(a, "cx", fmt(X(float(attr(a, "cx")))))}/>'
233
+
234
+ def path(m):
235
+ a = m.group(1)
236
+ d = attr(a, "d")
237
+ rigid = attr(a, "stroke") == "#FFFFFF" or d.count("M") > 1 # bar rulings and plus signs keep their size
238
+ if rigid:
239
+ xs = d_xs(d)
240
+ c = (min(xs) + max(xs)) / 2
241
+ dx = X(c) - c
242
+ return f'<path {set_attr(a, "d", map_d(d, lambda x: x + dx, lambda y: y))}/>'
243
+ return f'<path {set_attr(a, "d", map_d(d, X, lambda y: y))}/>'
244
+
245
+ line = re.sub(r"<rect ([^>]*)/>", rect, line)
246
+ line = re.sub(r"<circle ([^>]*)/>", circ, line)
247
+ line = re.sub(r"<path ([^>]*)/>", path, line)
248
+ return line
249
+
250
+
251
+ def run_line(y, parts, fill, cx, fs=19.0):
252
+ """Build a centred text line from (text, style, space_before) parts at font fs.
253
+ style: 'n' upright, 'i' italic (skew group, as in the manuscript), 'sub' upright subscript at 0.7 fs."""
254
+ fsub = round(fs * 0.7, 2)
255
+ sp = text_w(" ", fs)
256
+ widths = [text_w(t, fsub if s == "sub" else fs) for t, s, _ in parts]
257
+ total = sum(widths) + sp * sum(1 for *_, g in parts if g)
258
+ x = cx - total / 2
259
+ out = []
260
+ for (t, s, gap), w in zip(parts, widths):
261
+ x += sp if gap else 0.0
262
+ size, yy = (fsub, y + round(fs * 0.17, 1)) if s == "sub" else (fs, y)
263
+ el = (f'<text x="{fmt(x)}" y="{fmt(yy)}" font-size="{fmt(size)}" font-weight="400" fill="{fill}" '
264
+ f'letter-spacing="0.5" text-anchor="start">{t}</text>')
265
+ if s == "i":
266
+ el = f'<g transform="matrix(1,0,-0.2126,1,{fmt(SKEW * yy)},0)">{el}</g>'
267
+ out.append(el)
268
+ x += w
269
+ return "".join(out), total
270
+
271
+
272
+ # Line-specific geometry edits (1-based line numbers of the manuscript SVG); each old string must occur once.
273
+ EDITS = {
274
+ 126: [("M677.5,548 H657", "M677.5,548 H663")],
275
+ 132: [('<rect x="577" y="511" width="80" height="73"', '<rect x="571" y="511" width="92" height="73"')],
276
+ 135: [('<rect x="404" y="480" width="130" height="48"', '<rect x="398" y="480" width="142" height="48"')],
277
+ 137: [('<rect x="404" y="551" width="130" height="48"', '<rect x="398" y="548" width="142" height="60"')],
278
+ 140: [("M577,548 H560 V504 H542", "M571,548 H560 V504 H549")],
279
+ 141: [("M560,548 V575 H542", "M560,548 V578 H549")],
280
+ 142: [("M404,504 H366", "M398,504 H366")],
281
+ 143: [("M404,575 H366 V539", "M398,578 H366 V539")],
282
+ 190: [('<rect x="658" y="694" width="266" height="58"', '<rect x="658" y="694" width="266" height="64"')],
283
+ # panel b: wider reverse-sampling box for the longer last line
284
+ 262: [("H782", "H772")], 264: [("H782", "H772")], 266: [("H782", "H772")],
285
+ 270: [('<rect x="790" y="1000" width="276" height="164"', '<rect x="780" y="1000" width="296" height="164"')],
286
+ 275: [("M1066,1082 H1098", "M1076,1082 H1098")],
287
+ }
288
+ # Text lines: (new main font size, anchor mode, baseline shift in SVG units)
289
+ TEXT_A = {
290
+ 31: (21, "c", 0), 32: (21, "c", 0), 33: (21, "c", 0), 37: (21, "c", 0), 38: (21, "c", 1),
291
+ 42: (21, "c", -3), 44: (21, "c", -2),
292
+ 43: (21, "c", -5, 128.0), # manuscript line sits ~5 units right of its box centre (128); re-centred
293
+ 59: (20, "c", 0), 60: (20, "c", 0),
294
+ 61: (21, "l", 0), 75: (21, "c", 0), 76: (21, "c", 0), 77: (21, "l", 0), 83: (21, "c", 0),
295
+ 89: (21, "c", 0), 130: (21, "c", 3), 133: (21, "c", -1), 134: (21, "c", 1), 138: (21, "c", -2),
296
+ 139: (21, "c", 4), 158: (21, "c", 0), 159: (21, "c", 0), 160: (21, "l", 0), 162: (21, "l", 0),
297
+ 176: (21, "c", 0), 177: (21, "c", 0), 178: (21, "l", 0), 182: (21, "l", 0), 191: (21, "c", -1),
298
+ 192: (21, "c", 4), 195: (21, "c", -3), 198: (21, "c", 0), 199: (21, "c", 0), 208: (21, "c", 0),
299
+ 214: (21, "c", 0), 217: (21, "c", 0), 221: (21, "c", 0), 222: (21, "c", 0),
300
+ }
301
+ TEXT_B = {
302
+ 234: (19, "c", 0), 251: (19, "c", 0), 256: (19, "c", 0), 257: (19, "c", 0), 259: (19, "c", -2),
303
+ 260: (19, "c", 2), 278: (19, "c", 0), 287: (19, "c", 0), 295: (19, "c", 0), 303: (19, "c", 0),
304
+ 311: (19, "c", 0), 312: (19, "c", 0), 314: (19, "c", 0),
305
+ }
306
+ # panel a: lines 17-223 (drop the letter "a" 14-16 and the legend 224-229); panel b: 232-315 (drop letter "b")
307
+ A_LINES = list(range(17, 224))
308
+ B_LINES = [230] + list(range(232, 316)) # 230 opens the panel-b group, 315 closes it
309
+ CROP_A = (18, 110, 1478, 777) # after widening; boxes span y 116-771
310
+ CROP_B = (18, 918, 1422, 1216) # connector lines at y 926 and 1208
311
+
312
+
313
+ def build_svg(lines, rng, X, text_cfg, crop, width_in, drop_bg=True):
314
+ head = lines[:12] # xml decl .. defs .. outer <g>
315
+ x0, y0, x1, y1 = crop
316
+ vw, vh = x1 - x0, y1 - y0
317
+ h_in = width_in * vh / vw
318
+ head[1] = re.sub(r'width="[^"]*" height="[^"]*" viewBox="[^"]*"',
319
+ f'width="{width_in:.4f}in" height="{h_in:.4f}in" viewBox="{x0} {y0} {vw} {vh}"', head[1])
320
+ body = [f'<rect x="{x0}" y="{y0}" width="{vw}" height="{vh}" fill="#FFFFFF" stroke="none"/>']
321
+ infos = []
322
+ for ln in rng:
323
+ s = lines[ln - 1]
324
+ for old, new in EDITS.get(ln, []):
325
+ assert s.count(old) == 1, (ln, old)
326
+ s = s.replace(old, new)
327
+ if ln == 274: # panel b: cells differ by x_T and by the Bernoulli support draw (drawn read-out)
328
+ assert "the draw of" in s and 'font-size="18"' in s
329
+ s, w = run_line(1138.0, [("x", "i", False), ("T", "sub", False), ("and support draw differ", "n", True)],
330
+ "#5C6C74", 928.0)
331
+ infos.append(dict(line=ln, fs_old=18.0, fs_new=19.0, width_new=w, center_new=928.0,
332
+ text="x T and support draw differ (deck wording; manuscript: the draw of x T differs)"))
333
+ elif "<text" in s:
334
+ tgt, mode, dy, *fixed = text_cfg.get(ln, (None, "c", 0))
335
+ s, info = process_text_line(s, X, tgt, mode, dy, fixed[0] if fixed else None)
336
+ info["line"] = ln
337
+ infos.append(info)
338
+ elif X is not X_ID:
339
+ s = process_geometry_line(s, X)
340
+ body.append(s)
341
+ svg = "\n".join(head + body + ["</g></svg>"])
342
+ return svg, infos, h_in
343
+
344
+
345
+ def render(svg, stem, width_in):
346
+ p_svg = FIG / f"{stem}.svg"
347
+ p_svg.write_text(svg)
348
+ cairosvg.svg2png(bytestring=svg.encode(), write_to=str(FIG / f"{stem}.png"), dpi=300)
349
+ cairosvg.svg2pdf(bytestring=svg.encode(), write_to=str(FIG / f"{stem}.pdf"), dpi=72)
350
+ doc = fitz.open(FIG / f"{stem}.pdf")
351
+ wpt = doc[0].rect.width
352
+ doc.close()
353
+ assert abs(wpt - width_in * 72) < 1.0, (stem, wpt, width_in * 72)
354
+ return FIG / f"{stem}.png"
355
+
356
+
357
+ # ============================================================== corpus tables
358
+ def fmt_cells(v):
359
+ if v >= 1e7:
360
+ return f"{v / 1e6:.1f}M"
361
+ if v >= 1e6:
362
+ return f"{v / 1e6:.2f}M"
363
+ return f"{v / 1e3:.0f}K"
364
+
365
+
366
+ def corpus_tables():
367
+ src = json.loads(SRC_MANIFEST.read_text())
368
+ idx = json.loads(IDX_MANIFEST.read_text())
369
+ cov = json.loads(COVERAGE.read_text())
370
+ con = json.loads(CONTRACT.read_text())
371
+ base, over, raw, nsrc = (defaultdict(int) for _ in range(4))
372
+ for s in src["source_audit"]:
373
+ d = s["dataset_id"]
374
+ base[d] += int(s["base_rows"])
375
+ over[d] += int(s["overlay_rows"])
376
+ raw[d] += int(s["raw_rows"])
377
+ nsrc[d] += 1
378
+ ds = pd.DataFrame({"dataset_id": list(base)})
379
+ ds["base_rows"] = ds["dataset_id"].map(base)
380
+ ds["overlay_rows"] = ds["dataset_id"].map(over)
381
+ ds["cells"] = ds["base_rows"] + ds["overlay_rows"]
382
+ assert (ds["cells"] == ds["dataset_id"].map(raw)).all()
383
+ # cross-check against the index shards used by the run (base + overlay shards)
384
+ sh = pd.read_csv(SHARD_OFFSETS).groupby("dataset_id")["n_cells"].sum()
385
+ assert (ds.set_index("dataset_id")["cells"] == sh.reindex(ds["dataset_id"]).values).all()
386
+ ds["n_source_files"] = ds["dataset_id"].map(nsrc)
387
+ ds["label"] = ds["dataset_id"].str.split("_").str[0].map(LABELS)
388
+ assert ds["label"].notna().all()
389
+ ds = ds.sort_values("cells", ascending=False).reset_index(drop=True)
390
+ ds["rank"] = np.arange(1, len(ds) + 1)
391
+ ds["source"] = (f"{SRC_MANIFEST} :: source_audit[].base_rows + overlay_rows (= raw_rows) summed by dataset_id; "
392
+ f"equals {SHARD_OFFSETS} n_cells by dataset_id")
393
+ total = int(ds["cells"].sum())
394
+ assert len(ds) == src["n_datasets"] == idx["n_datasets"] == 22
395
+ assert total == src["logical_cells"] == idx["n_cells"] == cov["source_cells_all_splits"]
396
+ assert int(ds["base_rows"].sum()) == src["base_cells"] and int(ds["overlay_rows"].sum()) == src["overlay_cells"]
397
+ ds[["rank", "label", "cells", "base_rows", "overlay_rows", "n_source_files", "dataset_id", "source"]].to_csv(
398
+ DATA / "sec01_corpus_datasets.csv", index=False)
399
+
400
+ kq = idx["k_quotas_per_epoch"]
401
+ kk = pd.DataFrame({"K": [f"{k:,}" for k in idx["k_values"]], "k_weight": idx["k_weights"],
402
+ "recipes_per_epoch": [float(kq[str(k)]) for k in idx["k_values"]],
403
+ "recipes_per_epoch_min": [int(kq[str(k)]) for k in idx["k_values"]],
404
+ "recipes_per_epoch_max": [int(kq[str(k)]) for k in idx["k_values"]],
405
+ "kind": "registered K grid"})
406
+ kk["source"] = f"{IDX_MANIFEST} :: k_values, k_weights, k_quotas_per_epoch"
407
+ assert int(kk["recipes_per_epoch"].sum()) == idx["train_recipes_per_epoch"]
408
+
409
+ pairing = con["pairing"]
410
+ cat = con["coverage_after_topup"]
411
+ reg = pairing["registered_recipes_per_epoch"]
412
+ per_ep = np.array(pairing["total_recipe_counts_by_epoch"]) - reg
413
+ slot = pd.DataFrame(cat["slot_coverage"])
414
+ assert (np.sort(per_ep) == np.sort(slot["topup_recipes"].values)).all()
415
+ assert int(per_ep.sum()) == cat["topup_recipes"]
416
+ tu = pd.read_csv(TOPUP_CSV)
417
+ assert len(tu) == cat["topup_recipes"] and tu["is_topup"].all() and (tu["split"] == "train").all()
418
+ topup = dict(n=int(len(tu)), k_min=int(tu["k"].min()), k_max=int(tu["k"].max()),
419
+ k_median=float(tu["k"].median()), n_k_below_250=int((tu["k"] < 250).sum()),
420
+ per_epoch_mean=float(per_ep.mean()), per_epoch_min=int(per_ep.min()), per_epoch_max=int(per_ep.max()),
421
+ target_cells=int(cat["topup_target_cells"]), train_cells=int(cat["train_universe_cells"]),
422
+ coverage=float(cat["train_cell_coverage_after_topup"]),
423
+ recipes_by_epoch_min=int(min(pairing["total_recipe_counts_by_epoch"])),
424
+ recipes_by_epoch_max=int(max(pairing["total_recipe_counts_by_epoch"])))
425
+ kk = pd.concat([kk, pd.DataFrame([{
426
+ "K": "top-up", "k_weight": np.nan, "recipes_per_epoch": topup["per_epoch_mean"],
427
+ "recipes_per_epoch_min": topup["per_epoch_min"], "recipes_per_epoch_max": topup["per_epoch_max"],
428
+ "kind": f"top-up, K {topup['k_min']}-{topup['k_max']:,} (mean over 16 epochs)",
429
+ "source": f"{CONTRACT} :: pairing.total_recipe_counts_by_epoch - registered_recipes_per_epoch; {TOPUP_CSV} :: k"}])],
430
+ ignore_index=True)
431
+ kk.to_csv(DATA / "sec01_recipe_k.csv", index=False)
432
+ meta = {"n_datasets": src["n_datasets"], "cells": total, "base_cells": src["base_cells"],
433
+ "overlay_cells": src["overlay_cells"], "train_recipes_per_epoch": idx["train_recipes_per_epoch"],
434
+ "train_recipe_pool_size": idx["train_recipe_pool_size"], "max_disjoint_epochs": idx["max_disjoint_epochs"],
435
+ "split_unit": idx["split_unit"], "split_fractions": idx["split_fractions"],
436
+ "corpus_fingerprint": idx["corpus_fingerprint"], "topup": topup,
437
+ "all_members_targets": cov["all_k_member_occurrences_become_targets"],
438
+ "original_target_exposures": con["coverage_after_topup"]["original_target_exposures"],
439
+ "observed_target_cells_by_epoch": con["observed_target_cells_by_epoch"]}
440
+ return ds, kk, meta
441
+
442
+
443
+ def overlaps(fig, texts):
444
+ fig.canvas.draw()
445
+ r = fig.canvas.get_renderer()
446
+ bbs = [(t.get_text(), t.get_window_extent(r)) for t in texts if t.get_text()]
447
+ bad = []
448
+ for i in range(len(bbs)):
449
+ for j in range(i + 1, len(bbs)):
450
+ if bbs[i][1].overlaps(bbs[j][1]):
451
+ bad.append((bbs[i][0], bbs[j][0]))
452
+ return bad
453
+
454
+
455
+ def draw_corpus(fig, W, H, y0, h, ds, kk, meta, fs=12):
456
+ """Corpus panels placed in inches: two sorted dataset columns on one shared log scale (values printed,
457
+ no axis), then recipes per epoch by K. y0 = bottom of the bar area, h = its height (inches)."""
458
+ half = int(np.ceil(len(ds) / 2))
459
+ parts = [ds.iloc[:half], ds.iloc[half:]]
460
+ lo, hi = 1e4, 3e7
461
+ cols = [(2.2, 2.35), (7.2, 2.35)] # (left, width) in inches
462
+ texts = []
463
+ for (left, width), part in zip(cols, parts):
464
+ ax = fig.add_axes([left / W, y0 / H, width / W, h / H])
465
+ y = np.arange(len(part))
466
+ ax.barh(y, part["cells"], color=style.GREY, height=0.66)
467
+ for yi, v in zip(y, part["cells"]):
468
+ texts.append(ax.text(v * 1.2, yi, fmt_cells(v), va="center", ha="left", fontsize=fs, color=style.INK))
469
+ ax.set_xscale("log")
470
+ ax.set_xlim(lo, hi)
471
+ ax.set_ylim(half - 0.5, -0.5)
472
+ ax.set_yticks(y)
473
+ ax.set_yticklabels(part["label"], fontsize=fs)
474
+ texts += ax.get_yticklabels()
475
+ ax.tick_params(axis="y", length=0, pad=4)
476
+ ax.set_xticks([])
477
+ ax.minorticks_off()
478
+ for sp in ("left", "bottom"):
479
+ ax.spines[sp].set_visible(False)
480
+ t = meta["topup"]
481
+ texts.append(fig.text((cols[0][0] + cols[1][0] + cols[1][1]) / 2 / W, (y0 - 0.1) / H,
482
+ f"cells per dataset (log scale) · {meta['n_datasets']} datasets · "
483
+ f"{fmt_cells(meta['cells'])} cells · {fmt_cells(t['train_cells'])} in train split",
484
+ ha="center", va="top", fontsize=fs + 1))
485
+
486
+ ax = fig.add_axes([10.75 / W, y0 / H, 0.95 / W, h / H])
487
+ y = np.arange(len(kk))
488
+ is_top = (kk["K"] == "top-up").values
489
+ ax.barh(y[~is_top], kk.loc[~is_top, "recipes_per_epoch"], color=style.INK, height=0.62)
490
+ ax.barh(y[is_top], kk.loc[is_top, "recipes_per_epoch"], color=style.GREY, height=0.62)
491
+ vmax = kk["recipes_per_epoch"].max()
492
+ for yi, v, top in zip(y, kk["recipes_per_epoch"], is_top):
493
+ lab = f"~{v:.0f}" if top else f"{v:,.0f}"
494
+ texts.append(ax.text(v + vmax * 0.05, yi, lab, va="center", ha="left", fontsize=fs))
495
+ ax.set_ylim(len(kk) - 0.5, -0.5)
496
+ ax.set_yticks(y)
497
+ ax.set_yticklabels(kk["K"], fontsize=fs)
498
+ texts += ax.get_yticklabels()
499
+ ax.tick_params(axis="y", length=0, pad=4)
500
+ ax.set_xlim(0, vmax * 1.02)
501
+ ax.set_xticks([])
502
+ for sp in ("left", "bottom"):
503
+ ax.spines[sp].set_visible(False)
504
+ ax.set_ylabel("K cells / recipe", fontsize=fs + 1, labelpad=6)
505
+ texts.append(ax.yaxis.label)
506
+ texts.append(fig.text((10.75 + 0.5) / W, (y0 - 0.1) / H, "recipes / epoch", ha="center", va="top", fontsize=fs + 1))
507
+ return texts
508
+
509
+
510
+ def main():
511
+ FIG.mkdir(exist_ok=True)
512
+ DATA.mkdir(exist_ok=True)
513
+ lines = FIG1_SVG.read_text().split("\n")
514
+ assert len(lines) >= 316 and lines[230].startswith('<text x="24" y="914"') and 'y="813"' in lines[225]
515
+
516
+ # ---------- panel a (slide b) and panel b (slide a) deck copies
517
+ a_w = A_HEIGHT_IN * (CROP_A[2] - CROP_A[0]) / (CROP_A[3] - CROP_A[1])
518
+ svg_a, info_a, _ = build_svg(lines, A_LINES, X_A, TEXT_A, CROP_A, a_w)
519
+ render(svg_a, "sec01_fig1a_denoiser", a_w)
520
+ svg_b, info_b, b_h = build_svg(lines, B_LINES, X_ID, TEXT_B, CROP_B, W_FULL)
521
+ b_png = render(svg_b, "sec01_fig1b_inference", W_FULL)
522
+
523
+ # on-slide point size of every text line
524
+ pt_a = A_HEIGHT_IN * 72 / (CROP_A[3] - CROP_A[1])
525
+ pt_b = W_FULL * 72 / (CROP_B[2] - CROP_B[0])
526
+ rows = [dict(panel="a (slide b)", placed_in=f"{a_w:.2f} x {A_HEIGHT_IN:.2f}", pt_per_unit=pt_a, **i) for i in info_a]
527
+ rows += [dict(panel="b (slide a)", placed_in=f"{W_FULL:.2f} x {b_h:.3f}", pt_per_unit=pt_b, **i) for i in info_b]
528
+ lab = pd.DataFrame(rows)
529
+ lab["pt_on_slide"] = lab["fs_new"] * lab["pt_per_unit"]
530
+ lab = lab[["panel", "line", "text", "fs_old", "fs_new", "pt_on_slide", "width_new", "center_new", "placed_in", "pt_per_unit"]]
531
+ lab.to_csv(DATA / "sec01_fig1_label_pt.csv", index=False)
532
+
533
+ # ---------- corpus
534
+ ds, kk, meta = corpus_tables()
535
+ W = W_FULL
536
+ fig = plt.figure(figsize=(W, 2.75))
537
+ texts = draw_corpus(fig, W, 2.75, 0.45, 2.2, ds, kk, meta)
538
+ bad = overlaps(fig, texts)
539
+ assert not bad, bad
540
+ style.save(fig, "sec01_corpus", FIG)
541
+
542
+ # ---------- slide (a) composite: exactly 12.3 x 5.3 in, panel b redraw on top
543
+ H = SLIDE_A_H
544
+ img = plt.imread(b_png)
545
+ fig = plt.figure(figsize=(W, H))
546
+ ax_img = fig.add_axes([0, 1 - b_h / H, 1, b_h / H])
547
+ ax_img.imshow(img, interpolation="lanczos")
548
+ ax_img.set_axis_off()
549
+ y0 = 0.45
550
+ texts = draw_corpus(fig, W, H, y0, H - b_h - 0.16 - y0, ds, kk, meta)
551
+ bad = overlaps(fig, texts)
552
+ assert not bad, bad
553
+ r = fig.canvas.get_renderer()
554
+ for t in texts: # every corpus label stays on the canvas
555
+ bb = t.get_window_extent(r)
556
+ assert bb.x0 >= 0 and bb.x1 <= W * fig.dpi and bb.y0 >= 0, t.get_text()
557
+ with plt.rc_context({"savefig.bbox": "standard"}): # keep the canvas at exactly 12.3 x 5.3 in
558
+ for ext in ("png", "pdf"):
559
+ fig.savefig(FIG / f"sec01_slide_a.{ext}", dpi=300)
560
+ plt.close(fig)
561
+
562
+ # ---------- numbers used on the slides, with sources
563
+ cfg = json.loads(CFG.read_text())
564
+ st = json.loads(STATUS.read_text())
565
+ idx = json.loads(IDX_MANIFEST.read_text())
566
+ con = json.loads(CONTRACT.read_text())
567
+ hd = cfg["model"]["hidden_dims"]
568
+ blocks = hd + hd[-2::-1]
569
+ assert "descending half of the symmetric MLP" in MODEL_PY.read_text()
570
+ meth = METHODS.read_text().split("\n")
571
+ assert "Generation used EMA weights and 50 deterministic DDIM steps ($\\eta=0$)" in meth[57]
572
+ assert "The drawn read-out is implemented in the standalone sampler that generated every set scored in this paper" in meth[98]
573
+ t = meta["topup"]
574
+ nums = [
575
+ ("n_datasets", meta["n_datasets"], f"{SRC_MANIFEST} :: n_datasets (= {IDX_MANIFEST} :: n_datasets)"),
576
+ ("corpus_cells", meta["cells"], f"{SRC_MANIFEST} :: logical_cells = base_cells + overlay_cells (= {IDX_MANIFEST} :: n_cells; = {COVERAGE} :: source_cells_all_splits)"),
577
+ ("corpus_base_cells", meta["base_cells"], f"{SRC_MANIFEST} :: base_cells"),
578
+ ("corpus_overlay_cells", meta["overlay_cells"], f"{SRC_MANIFEST} :: overlay_cells"),
579
+ ("train_split_cells", t["train_cells"], f"{CONTRACT} :: coverage_after_topup.train_universe_cells"),
580
+ ("split", f"{idx['split_unit']} {idx['split_fractions']}", f"{IDX_MANIFEST} :: split_unit, split_fractions"),
581
+ ("k_values", " ".join(str(k) for k in idx["k_values"]), f"{IDX_MANIFEST} :: k_values"),
582
+ ("registered_recipes_per_epoch", idx["train_recipes_per_epoch"], f"{IDX_MANIFEST} :: train_recipes_per_epoch"),
583
+ ("train_recipe_pool_size", idx["train_recipe_pool_size"], f"{IDX_MANIFEST} :: train_recipe_pool_size"),
584
+ ("max_disjoint_epochs", idx["max_disjoint_epochs"], f"{IDX_MANIFEST} :: max_disjoint_epochs (schedule_slots)"),
585
+ ("topup_recipes_total", t["n"], f"{CONTRACT} :: coverage_after_topup.topup_recipes (= rows of {TOPUP_CSV})"),
586
+ ("topup_recipes_per_epoch_mean_min_max", f"{t['per_epoch_mean']:.1f} {t['per_epoch_min']} {t['per_epoch_max']}", f"{CONTRACT} :: pairing.total_recipe_counts_by_epoch - pairing.registered_recipes_per_epoch"),
587
+ ("recipes_per_epoch_actual_min_max", f"{t['recipes_by_epoch_min']} {t['recipes_by_epoch_max']}", f"{CONTRACT} :: pairing.total_recipe_counts_by_epoch"),
588
+ ("topup_k_min_median_max", f"{t['k_min']} {t['k_median']:.0f} {t['k_max']}", f"{TOPUP_CSV} :: k"),
589
+ ("topup_recipes_k_below_250", t["n_k_below_250"], f"{TOPUP_CSV} :: k < 250"),
590
+ ("train_cell_coverage_after_topup", t["coverage"], f"{CONTRACT} :: coverage_after_topup.train_cell_coverage_after_topup"),
591
+ ("all_member_cells_are_targets", meta["all_members_targets"], f"{COVERAGE} :: all_k_member_occurrences_become_targets"),
592
+ ("target_cells_per_epoch_min_max", f"{min(meta['observed_target_cells_by_epoch'])} {max(meta['observed_target_cells_by_epoch'])}", f"{CONTRACT} :: observed_target_cells_by_epoch"),
593
+ ("corpus_fingerprint_matches_run", idx["corpus_fingerprint"] == st["corpus_fingerprint"] == con["pairing"]["source_corpus_fingerprint"],
594
+ f"{IDX_MANIFEST} :: corpus_fingerprint vs {STATUS} :: corpus_fingerprint and {CONTRACT} :: pairing.source_corpus_fingerprint"),
595
+ ("n_genes", cfg["data"]["n_genes"], f"{CFG} :: data.n_genes (= {STATUS} :: n_genes)"),
596
+ ("condition_dim", st["condition_dim"], f"{STATUS} :: condition_dim (= 3G+6)"),
597
+ ("parameters", st["parameters"], f"{STATUS} :: parameters"),
598
+ ("hidden_dims_descending_half", "-".join(map(str, hd)), f"{CFG} :: model.hidden_dims ({MODEL_PY} SparseDenoiserConfig: descending half of a symmetric skip MLP)"),
599
+ ("denoiser_blocks", f"{len(blocks)} blocks: {'-'.join(map(str, blocks))}", f"derived: hidden_dims + reversed(hidden_dims[:-1]); matches Fig. 1a '7 blocks + skip sums'"),
600
+ ("context_dim", cfg["model"]["context_dim"], f"{CFG} :: model.context_dim"),
601
+ ("time_embedding_dim", cfg["model"]["time_embedding_dim"], f"{CFG} :: model.time_embedding_dim"),
602
+ ("sampler", "EMA weights, 50 DDIM steps, eta 0", f"{METHODS} l.58"),
603
+ ("support_readout", "drawn (Bernoulli): keep gene g if u < sigmoid(logit); used for every scored set", f"{METHODS} l.99 (Support read-out)"),
604
+ ("ema_decay", cfg["training"]["ema_decay"], f"{CFG} :: training.ema_decay"),
605
+ ("epochs_completed", st["epochs_completed"], f"{STATUS} :: epochs_completed (= 16 disjoint schedule slots; {IDX_MANIFEST} :: schedule_slots)"),
606
+ ("status", st["status"], f"{STATUS} :: status"),
607
+ ]
608
+ assert cfg["data"]["n_genes"] == st["n_genes"]
609
+ assert st["condition_dim"] == 3 * st["n_genes"] + 6
610
+ assert st["epochs_completed"] == idx["schedule_slots"] == idx["max_disjoint_epochs"] == 16
611
+ assert idx["train_recipes_per_epoch"] * idx["schedule_slots"] == idx["train_recipe_pool_size"]
612
+ assert meta["original_target_exposures"] == sum(int(k) * int(v) for k, v in zip(
613
+ idx["k_values"], [idx["k_quotas_per_epoch"][str(k)] for k in idx["k_values"]])) * idx["schedule_slots"]
614
+ pd.DataFrame(nums, columns=["key", "value", "source"]).to_csv(DATA / "sec01_model_numbers.csv", index=False)
615
+
616
+ print(f"panel a placed {a_w:.2f} x {A_HEIGHT_IN} in, {pt_a:.4f} pt/unit; panel b {W_FULL} x {b_h:.3f} in, {pt_b:.4f} pt/unit")
617
+ for p, g in lab.groupby("panel"):
618
+ g = g.sort_values("pt_on_slide")
619
+ print(p, "min label pt", round(g["pt_on_slide"].min(), 2), "|", g.iloc[0]["text"][:40])
620
+ print("datasets", meta["n_datasets"], "cells", meta["cells"], fmt_cells(meta["cells"]))
621
+ print(ds[["label", "cells"]].to_string(index=False))
622
+ print(kk[["K", "recipes_per_epoch", "recipes_per_epoch_min", "recipes_per_epoch_max"]].to_string(index=False))
623
+ for k, v, _ in nums:
624
+ print(k, v)
625
+
626
+
627
+ if __name__ == "__main__":
628
+ main()