Skip to content

Group examples by data type and fix the index - #40

Merged
afloresep merged 2 commits into
masterfrom
tidy-examples
Aug 22, 2026
Merged

Group examples by data type and fix the index#40
afloresep merged 2 commits into
masterfrom
tidy-examples

Conversation

@afloresep

Copy link
Copy Markdown
Owner

Follow-up to #39, which is unrelated in content — this branch is off master and touches no source code.

examples/ had grown to 19 files in one flat directory. Two things were wrong with it.

The index was mostly fiction

examples/README.md listed four examples that were never committedsar_egfr.py, afdb_clusters_tmap.py, singlecell_trajectory_tmap.py, singlecell_reprogramming_tmap.py. There are no deletion records in git history; they never existed. Meanwhile it omitted eleven files that do exist, including every image example except two.

So the index advertised 8 examples, half of them imaginary, and hid most of the real ones. The README is rewritten and now lists all thirteen with what each actually does.

New layout

examples/
  README.md
  cluster_65053.csv
  chemistry/   molecules_tmap.py  smiles_tmap.py  molecules_tmap_legacy.py
  images/      pet_breed_audit.py  mnist_cosine_tmap.py  emnist_characters_tmap.py
               flowers_tmap.py  cub200_birds_tmap.py  wikiart_tmap.py
  proteins/    esm_atlas_tmap.py
  text/        word_embeddings_tmap.py  word_embeddings_50k.py
  layout/      untangle_demo.py
  data/        (gitignored download cache, unchanged)

cluster_65053.csv deliberately stays at the root. It is referenced from 3 docs, 4 scripts and 5 notebooks — moving it would churn 13 files including notebook JSON, and break any snippet a user has already copied out of the docs.

Removed: 10 MB and a tuning experiment

adaptive_coef_exp_3panel.py is an 8×8 sweep of layout coefficients across 2k/64k/200k molecules with a --probe flag to "time risky 200k corners". That's how the defaults were chosen, not something a user runs.

Its only dataset, chembl_200k.csv (10 MB), was used by nothing else in the repository. Both are gone, which takes roughly 72% of the tracked weight of examples/ out of every clone. Still in git history if it's ever wanted back.

untangle_demo.py is kept, under layout/ — it's the only documentation of what UntangleMode does.

Paths

Every script anchored its data, cache and output at Path(__file__).parent, which breaks when the script moves one level deeper — including against the gitignored examples/data/ cache that may already hold gigabytes of downloads. Each moved script now anchors at

EXAMPLES_DIR = Path(__file__).resolve().parents[1]

so the shared CSV and the existing cache keep resolving, and outputs still land in examples/. Usage lines in the docstrings are updated to the new paths.

mnist_cosine_tmap.py was writing to a cwd-relative "examples/mnist_tmap.html", so it only worked from the repository root. It uses the same anchor now.

Also

  • cazyme_analysis.ipynb moves to notebooks/14_cazyme_analysis.ipynb, next to the other thirteen. The root README's notebook table gains rows 13 and 14 — 13 was already missing.
  • Four docs updated for the moved script paths (docs/molecule_tutorial.md, lshforest_guide.md, layout_guide.md, minhash_guide.md).

Checked

  • Ran examples/chemistry/molecules_tmap.py from /tmp: it found the CSV and wrote output back to examples/, confirming the anchoring is cwd-independent.
  • All 13 scripts parse; every README link resolves; every script appears in the README.
  • 454 passed, 33 skipped. ruff check src/ tests/ clean, which is what CI gates.
  • ruff check examples/ goes from 26 errors to 20. The remaining 20 are pre-existing in esm_atlas_tmap.py (long lines, trailing whitespace) and left alone — examples/ is not linted by CI, and fixing them would bury the move in unrelated churn.

The examples folder had grown to 19 files in one flat directory, and its
README had drifted badly: it listed four examples that were never committed
(sar_egfr.py, afdb_clusters_tmap.py and two single-cell scripts) while
omitting eleven that exist, including every image example but two.

Scripts now sit under chemistry/, images/, proteins/, text/ and layout/,
and the README lists all thirteen with what each one actually does.

cluster_65053.csv stays at examples/ root. It is referenced from three
docs, four scripts and five notebooks, so moving it would have churned
thirteen files including notebook JSON for no real gain.

Dropped adaptive_coef_exp_3panel.py: an 8x8 sweep of layout coefficients
used to pick defaults, not something a user would run. Its only dataset,
chembl_200k.csv, was used by nothing else, so 10 MB leaves every clone
with it.

cazyme_analysis.ipynb moves to notebooks/, where the other thirteen
notebooks live. The root README's notebook table now also lists notebook
13, which was already missing.

Each moved script anchors its data, cache and output at EXAMPLES_DIR
rather than Path(__file__).parent, so the gitignored examples/data/ cache
and the shared CSV keep resolving from the new depth. mnist_cosine_tmap.py
used a cwd-relative output path and now uses the same anchor, so it no
longer depends on being run from the repository root.
@afloresep
afloresep merged commit 9e69fcb into master Aug 22, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant