Skip to content

refactor: unify newick --> matrix conversion in rust and tests in python#32

Merged
Neclow merged 1 commit intosbhattlab:mainfrom
Neclow:unify_to_matrix_rs
May 14, 2025
Merged

refactor: unify newick --> matrix conversion in rust and tests in python#32
Neclow merged 1 commit intosbhattlab:mainfrom
Neclow:unify_to_matrix_rs

Conversation

@Neclow
Copy link
Collaborator

@Neclow Neclow commented May 14, 2025

Current Python API fails when calling from_newick when a Newick string has branch lengths but no parents. This commit unifies to_matrix/to_matrix_no_parents in Rust under one function (similar to to_vector) and adds relevant matrix tests in Python.

@Neclow Neclow requested a review from Copilot May 14, 2025 20:17
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 unifies the conversion of Newick strings to matrices in Rust for both cases (with and without parent nodes) and updates the corresponding Python tests accordingly. Key changes include:

  • Merging the to_matrix and to_matrix_no_parents functionality into a single function.
  • Adding tests in Python to verify correct behavior in both scenarios.
  • Bumping the version in Cargo.toml and removing a now-unused dev dependency.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
py-phylo2vec/tests/test_base.py Added new test (test_m2newick2m) to validate conversion logic.
phylo2vec/src/tree_vec/ops/matrix/mod.rs Refactored to merge parent and no parent cases into one function.
phylo2vec/Cargo.toml Version bump and removal of ndarray from dev-dependencies.
Comments suppressed due to low confidence (1)

phylo2vec/Cargo.toml:17

  • [nitpick] Since the ndarray dev dependency has been removed, consider updating any accompanying documentation or comments to reflect this change and ensure consistency.
ndarray = "*"

@Neclow Neclow merged commit 529b432 into sbhattlab:main May 14, 2025
7 checks passed
@Neclow Neclow deleted the unify_to_matrix_rs branch May 14, 2025 20:24
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