Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the tree-building functionality for Newick strings by switching from recursive ancestry‐based construction to a more efficient iterative pairs‐based approach, leading to improved performance.
- Refactored build_newick functions to use pairs instead of ancestry arrays
- Eliminated recursion in favor of iterative caching methods
- Updated associated API calls and tests accordingly
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| py-phylo2vec/src/lib.rs | Updated build_newick to accept pairs instead of ancestry triples |
| py-phylo2vec/phylo2vec/base/to_newick.py | Removed the legacy _build_newick function |
| phylo2vec/src/tree_vec/ops/newick/mod.rs | Replaced recursive Newick string construction with an iterative, cache‑based method and updated build_newick_with_bls |
| phylo2vec/src/tree_vec/ops/mod.rs | Modified to_newick_from_vector/from_matrix functions to use get_pairs |
Comments suppressed due to low confidence (3)
phylo2vec/src/tree_vec/ops/newick/mod.rs:229
- [nitpick] Consider renaming the 'cache' variable (used to collect node strings) to a more descriptive name (e.g., 'node_strings') for improved code clarity.
for (i, &(c1, c2)) in pairs.iter().enumerate() {
py-phylo2vec/src/lib.rs:42
- The function signature now uses 'input_pairs' instead of 'input_ancestry'. Please ensure that all downstream calls and documentation are updated to reflect this change.
fn build_newick(input_pairs: Vec<(usize, usize)>) -> String {
phylo2vec/src/tree_vec/ops/mod.rs:22
- Switching from 'get_ancestry' to 'get_pairs' simplifies the tree construction process; ensure that the related documentation and in-code comments are updated accordingly.
let pairs: Pairs = get_pairs(v);
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
New functions are proposed to build a Newick string from get_pairs() instead of get_ancestry(), thus eliminating an extra step. Moreover, we get rid of recursion, which incurs a higher overload for a large number of leaves.
0003_8e8e0117f2b02383612646152fb193e9042e4b09_20250501_112011.json