Skip to content

Allow a function as lengths in tree-generation functions#273

Merged
ms609 merged 1 commit into
mainfrom
claude/suspicious-haibt-68c253
Jun 1, 2026
Merged

Allow a function as lengths in tree-generation functions#273
ms609 merged 1 commit into
mainfrom
claude/suspicious-haibt-68c253

Conversation

@ms609

@ms609 ms609 commented Jun 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • RandomTree(), YuleTree(), PectinateTree(), BalancedTree(), StarTree(), and SingleTaxonTree() now accept a function as the lengths argument; the function is called with the number of edges as its sole argument.
  • This allows e.g. RandomTree(8, lengths = runif) instead of RandomTree(8, lengths = runif(14)).
  • A private helper .EdgeLengths(lengths, nEdge) consolidates the dispatch (function vs vector) across all six functions.
  • Docs updated (both GenerateTree.Rd and TrivialTree.Rd regenerated); example RandomTree(8, lengths = runif) added.
  • Tests extended with seq_len-based assertions that verify the function is called with the exact edge count.

Test plan

  • devtools::test(filter = "tree_generation") — 121 tests, 0 failures
  • Inspect man/GenerateTree.Rd and man/TrivialTree.Rd for updated lengths description

🤖 Generated with Claude Code

`RandomTree()`, `YuleTree()`, `PectinateTree()`, `BalancedTree()`,
`StarTree()`, and `SingleTaxonTree()` now accept a function for the
`lengths` argument; the function is called with the number of edges as
its sole argument, e.g. `RandomTree(8, lengths = runif)`.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.18%. Comparing base (49179ea) to head (de710c1).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #273      +/-   ##
==========================================
- Coverage   96.19%   96.18%   -0.01%     
==========================================
  Files          81       81              
  Lines        6039     6033       -6     
==========================================
- Hits         5809     5803       -6     
  Misses        230      230              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown

Performance benchmark results

Call Status Change Time (ms)
as.Splits(bigTrees) ⚪ NSD -16.51% 22.2 →
27.8, 22.7
as.Splits(someTrees) ⚪ NSD -3.16% 11.5 →
11.9, 11.5
Consensus(forest1k.888, check = FALSE) ⚪ NSD 3.45% 106 →
100, 105
Consensus(forest201.80, check = FALSE) ⚪ NSD -5.38% 4.12 →
4.45, 4.21
Consensus(forest21.260, 0.5, FALSE) ⚪ NSD 0.45% 1.24 →
1.24, 1.23
Consensus(forest21.260) ⚪ NSD 0.62% 1.25 →
1.25, 1.25
Consensus(forestMaj, 0.5, FALSE) ⚪ NSD 0.27% 3.24 →
3.27, 3.23
DropTip(tr2000, 5) ⚪ NSD -2.87% 16.8 →
17.6, 17
DropTip(tr80, 5) ⚪ NSD -0.47% 0.106 →
0.107, 0.106
DropTip(unlen2k, 5) ⚪ NSD 0.53% 0.21 →
0.213, 0.206
DropTip(unlen80, 5) ⚪ NSD -0.79% 0.0408 →
0.0415, 0.0407
lapply(bigSplits, as.phylo) ⚪ NSD -0.31% 29.5 →
29.6, 29.5
lapply(someSplits, as.phylo) ⚪ NSD -1.04% 14 →
14.3, 13.9
PathLengths(tr2000, full = TRUE) ⚪ NSD -1.8% 16.5 →
17, 16.5
PathLengths(tr80, full = TRUE) ⚪ NSD -0.76% 0.102 →
0.104, 0.102
PathLengths(tr80Unif, full = TRUE) ⚪ NSD -1.12% 0.104 →
0.106, 0.104
RootTree(tr2000, 5) ⚪ NSD -1.06% 0.4 →
0.406, 0.403
RootTree(tr80, c("t3", "t36")) ⚪ NSD -3.53% 0.0713 →
0.0748, 0.0729
RootTree(tr80, "t3") ⚪ NSD -3.05% 0.051 →
0.0533, 0.0516
RootTree(tr80, "t30") ⚪ NSD -2.15% 0.0511 →
0.0527, 0.0517
RootTree(unlen2k, 5) ⚪ NSD 7.11% 0.357 →
0.334, 0.33
RootTree(unlen80, c("t3", "t36")) ⚪ NSD -0.3% 0.0676 →
0.0682, 0.0675
RootTree(unlen80, "t3") ⚪ NSD 0.67% 0.0452 →
0.0451, 0.0447
RootTree(unlen80, "t30") ⚪ NSD 0.72% 0.0457 →
0.0458, 0.045
TreeDist::RobinsonFoulds(forest201.80) ⚪ NSD -2.36% 16.8 →
17.6, 16.5
TreeDist::RobinsonFoulds(forest21.888) ⚪ NSD -1.21% 3.55 →
3.64, 3.42
TreeTools:::path_lengths(tr80$edge, tr80$edge.length, FALSE) ⚪ NSD -0.68% 0.0924 →
0.0943, 0.0918
TreeTools:::postorder_order(bal40) ⚪ NSD -0.06% 0.00169 →
0.0017, 0.00169
TreeTools:::postorder_order(bal40k) ⚪ NSD -0.07% 0.548 →
0.549, 0.548
TreeTools:::postorder_order(dbal40) ⚪ NSD 1.08% 0.00176 →
0.00174, 0.00175
TreeTools:::postorder_order(dbal40k) ⚪ NSD 1.15% 2.16 →
2.12, 2.14
TreeTools:::postorder_order(dpec40) ⚪ NSD 0.35% 0.00257 →
0.00256, 0.00257
TreeTools:::postorder_order(dpec40k) ⚪ NSD -0.06% 3300 →
3300, 3300
TreeTools:::postorder_order(drnd80) ⚪ NSD 0.24% 0.0041 →
0.00413, 0.00406
TreeTools:::postorder_order(nbal40) ⚪ NSD 0.43% 0.00209 →
0.00207, 0.00208
TreeTools:::postorder_order(nbal40k) ⚪ NSD -1.34% 2.2 →
2.23, 2.22
TreeTools:::postorder_order(npec40) ⚪ NSD -1.05% 0.00286 →
0.00288, 0.00289
TreeTools:::postorder_order(npec40k) ⚪ NSD -0.08% 3320 →
3330, 3320
TreeTools:::postorder_order(nrnd80) ⚪ NSD 0.65% 0.00465 →
0.00461, 0.00463
TreeTools:::postorder_order(pec40) ⚪ NSD 0.59% 0.00168 →
0.00167, 0.00167
TreeTools:::postorder_order(pec40k) ⚪ NSD 19.17% 0.547 →
0.548, 0.435
TreeTools:::postorder_order(rnd80) ⚪ NSD 1.4% 0.00214 →
0.00213, 0.0021

@ms609 ms609 merged commit b001697 into main Jun 1, 2026
35 of 36 checks passed
@ms609 ms609 deleted the claude/suspicious-haibt-68c253 branch June 1, 2026 09:59
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