Skip to content

docs: add a notebooks section and split the demo notebook - #222

Merged
Neclow merged 6 commits into
sbhattlab:mainfrom
Neclow:docs/notebooks-section
Nov 2, 2026
Merged

Neclow merged 6 commits into
sbhattlab:mainfrom
Neclow:docs/notebooks-section

Conversation

@Neclow

@Neclow Neclow commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

Moves the notebooks into a docs/notebooks/ section and splits the single demo notebook by topic. Related to #170.

The "Notebooks" section of the docs now contains:

  1. Getting started: sampling, Newick conversion, the matrix format, other tree formats (edges, ancestry, pairs), saving/loading files, and the built-in datasets
  2. Tree operations: common ancestors and node depths, removing/adding leaves, rerooting, Queue Shuffle, Newick and taxon label utilities
  3. Statistics: cophenetic distances, covariance/precision matrices, incidence matrices, balance indices, Robinson-Foulds distance
  4. Optimisation: the former demo_opt.ipynb

A core concepts notebook (how the vector encodes a tree) is planned as a follow-up, between getting started and tree operations.

Notebook changes

  • Content from demo.ipynb is kept, and the notebooks now also cover reroot, queue_shuffle, remove_branch_lengths, cov, precision, incidence, the balance indices (with a link to Khurana et al. 2024) and load_alignment
  • Fixes: the get_pairs description (it returns pairs, not triplets), a cell that printed the wrong variable, list_models → list_methods, the "column-wise" argmax (it is row-wise), and the GradME score description
  • The notebooks no longer os.chdir into py-phylo2vec or call the private _phylo2vec_core; the optimisation notebook downloads its data to a temporary directory instead of the package folder
  • All notebooks were re-run, so every cell has up-to-date outputs. The optimisation notebook previously showed a FutureWarning and a local path in its output

Code fixes found while re-running the optimisation notebook

  • HillClimbing used the deprecated reorder_v; it now calls queue_shuffle directly (results are identical, checked on 1,000 random trees)
  • GradME.fit crashed at the end with recent jax (0.12), which requires a boolean where mask in jax.nn.softmax

Other changes

  • .gitignore: the experimental notebooks/ rule is anchored to the root, as it also ignored docs/notebooks/
  • CI: the notebook job executes getting started, tree operations and statistics. Optimisation is skipped, as it needs the [opt] extras, RAxML-NG and R
  • README.md and installation.md point to the new optimisation page

The notebooks are moved unchanged in a separate commit, so that git records the renames. Merging with a merge commit rather than squashing keeps that history (git log --follow) for both notebooks.

Neclow and others added 6 commits November 2, 2026 09:02
…mbing

HillClimbing called the deprecated `reorder_v`, so every fit emitted a
FutureWarning. Call `queue_shuffle` directly and remap the labels, as
GradME already does. Results are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Recent jax versions only accept a boolean `where` in jax.nn.softmax, so
GradME.fit failed at the end of optimisation with "jnp.max: where must
be None or a boolean array" (seen with jax 0.12). Older versions treated
the float mask as truthy, so results are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move demo.ipynb and demo_opt.ipynb unchanged (as getting-started.ipynb
and optimisation.ipynb), so that git records the renames. Their content
and the paths they use are updated in the next commit.

- List them under a "Notebooks" caption in _toc.yml
- Point README.md and installation.md to the new optimisation page
- Only ignore the root-level experimental notebooks/ folder, so that
  docs/notebooks/ is tracked

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd statistics

getting-started.ipynb keeps the sampling, Newick, matrix, other formats
and I/O sections of the former demo, plus the built-in datasets. Tree
operations and statistics move to their own notebooks, which also cover
functions the demo did not: reroot, queue_shuffle, remove_branch_lengths,
cov, precision, incidence and the balance indices.

Also:
- Fix the get_pairs description (pairs, not triplets) and a cell that
  printed the wrong variable; drop the os.chdir and private core calls
- optimisation.ipynb: fix list_models -> list_methods, the argmax
  wording and the GradME score description; download the data to a
  temporary directory instead of the package folder; re-run with the
  HillClimbing and GradME fixes (no more FutureWarning or local paths)
- Re-run all notebooks so that every cell has up-to-date outputs
- CI: execute getting-started, tree-operations and statistics
  (optimisation needs the [opt] extras, RAxML-NG and R)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Neclow
Neclow merged commit d38a660 into sbhattlab:main Nov 2, 2026
9 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