Skip to content

Speed-up build newick#26

Closed
Neclow wants to merge 2 commits intosbhattlab:mainfrom
Neclow:fix_build_newick
Closed

Speed-up build newick#26
Neclow wants to merge 2 commits intosbhattlab:mainfrom
Neclow:fix_build_newick

Conversation

@Neclow
Copy link
Collaborator

@Neclow Neclow commented May 12, 2025

No description provided.

@Neclow Neclow requested a review from Copilot May 12, 2025 16:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the build newick functionality by exposing new edges‐processing functions and integrating them into both the Rust and Python APIs. Key changes include:

  • Adding new functions get_edges and from_edges in the Rust library and exposing them via Python bindings.
  • Introducing a new module in Python for converting between Phylo2Vec vectors and edge lists.
  • Updating TreeVec with a new get_edges method and improving tests and benchmarks for stability.

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
py-phylo2vec/src/lib.rs Added get_edges and from_edges functions wrapping ops calls.
py-phylo2vec/phylo2vec/base/edges.py New module to convert vectors to edge lists and vice versa.
py-phylo2vec/phylo2vec/init.py Exported the new edges conversion functions.
phylo2vec/src/tree_vec/ops/vector.rs Added get_edges_from_pairs, get_edges, and from_edges implementations.
phylo2vec/src/tree_vec/mod.rs TreeVec now supports get_edges with accompanying tests.
phylo2vec/src/profile_main.rs Updated to use a fixed vector for improved stability in main().
phylo2vec/benches/benchmarks/core.rs Minor updates to benchmark comments for newick generation.


pub fn from_edges(edges: &[(usize, usize)]) -> Vec<usize> {
let mut ancestry: Ancestry = Vec::with_capacity(edges.len() / 2);

Copy link

Copilot AI May 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clarify in a comment that the implementation of from_edges assumes adjacent pairs of edges belong together to form an ancestry triplet. This helps maintainers understand the invariant behind the pairing logic.

Suggested change
// The implementation assumes that every two consecutive edges in the input array
// belong together to form an ancestry triplet. Specifically, edges[i] and edges[i + 1]
// represent the two child nodes, and edges[i].1 represents their common parent.

Copilot uses AI. Check for mistakes.
DEFAULT_N_LEAVES
};
let v = sample_vector(n_leaves, true);
// Fore more stability, we use a fixed vector
Copy link

Copilot AI May 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct the comment typo from 'Fore more stability' to 'For more stability' for clarity.

Suggested change
// Fore more stability, we use a fixed vector
// For more stability, we use a fixed vector

Copilot uses AI. Check for mistakes.
@Neclow Neclow changed the title Fix build newick Speed-up build newick May 13, 2025
@Neclow Neclow mentioned this pull request May 13, 2025
@Neclow
Copy link
Collaborator Author

Neclow commented May 13, 2025

Superseded by #27

@Neclow Neclow closed this May 13, 2025
@Neclow Neclow deleted the fix_build_newick branch May 14, 2025 10:11
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.

2 participants