Datasets:
Download scripts/verify_app.py from integMET/edge-ML-metabolomics-graph: direct link, hf CLI and curl.
- Browser
- Download file 1.98 kB
-
https://huggingface.co/datasets/integMET/edge-ML-metabolomics-graph/resolve/main/scripts/verify_app.py
- Command line
-
hf download hf://datasets/integMET/edge-ML-metabolomics-graph/scripts/verify_app.py
-
curl -L -o verify_app.py https://huggingface.co/datasets/integMET/edge-ML-metabolomics-graph/resolve/main/scripts/verify_app.py
1.98 kB
| """Check the app's figure without a browser: trace structure, palette, axes.""" | |
| import umap_app as app | |
| PALETTE = set(app.THEMES["light"]["series"] + app.THEMES["dark"]["series"] | |
| + [app.THEMES["light"]["other"], app.THEMES["dark"]["other"], | |
| app.THEMES["light"]["grid"], app.THEMES["dark"]["grid"]]) | |
| df = app.load_nodes() | |
| print(f"nodes {len(df):,} · coords x[{df.x.min():.1f},{df.x.max():.1f}] " | |
| f"y[{df.y.min():.1f},{df.y.max():.1f}]") | |
| CASES = { | |
| "top 3, light": dict(mode="light"), | |
| "top 3, dark": dict(mode="dark"), | |
| "highlight Homo sapiens": dict(highlight="Homo sapiens"), | |
| "restrict to 2 species": dict(shown=("Bos taurus", "Mus musculus")), | |
| "colour by tissue1": dict(group_by="tissue1"), | |
| } | |
| for name, kwargs in CASES.items(): | |
| fig, visible = app.build_figure(df, **kwargs) | |
| hues = {t.marker.color for t in fig.data} | |
| drawn = sum(len(t.x) for t in fig.data) | |
| coloured = sum(len(t.x) for t in fig.data if t.marker.color | |
| not in (app.THEMES["light"]["other"], app.THEMES["dark"]["other"], | |
| app.THEMES["light"]["grid"], app.THEMES["dark"]["grid"])) | |
| assert hues <= PALETTE, f"{name}: off-palette colour {hues - PALETTE}" | |
| assert drawn == len(df), f"{name}: {drawn} points drawn, expected {len(df)}" | |
| assert len([t for t in fig.data if t.showlegend is not False]) <= 4 | |
| assert fig.layout.xaxis.visible is False and fig.layout.yaxis.visible is False | |
| assert fig.layout.xaxis.scaleanchor == "y", "aspect ratio not locked" | |
| assert all("customdata" in t.hovertemplate for t in fig.data) | |
| print(f"\n{name}") | |
| print(f" traces {len(fig.data)} · all {drawn:,} nodes drawn · " | |
| f"{coloured:,} in a series hue") | |
| for t in fig.data: | |
| print(f" {(t.name or '—'):<34} {len(t.x):>7,} {t.marker.color}") | |
| print("\nall figure checks passed: palette clean, every node drawn, " | |
| "axes hidden, aspect locked, hover wired") | |