feat: port matrix operations to ndarray + rust-numpy#81
Merged
Neclow merged 2 commits intosbhattlab:revamp_rustfrom Jun 29, 2025
Merged
feat: port matrix operations to ndarray + rust-numpy#81Neclow merged 2 commits intosbhattlab:revamp_rustfrom
Neclow merged 2 commits intosbhattlab:revamp_rustfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
Port matrix handling to use ndarray in Rust core and update R and Python bindings to interoperate via rust-numpy/extendr.
- Replace
Vec<Vec<f32>>withArray2<f32>andArrayView2<f32>throughout core operations and tests. - Update R (
extendr) and Python (pyo3 + numpy) glue code to accept and returnndarraytypes. - Add
ndarraydependency and remove legacy conversion code.
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| r-phylo2vec/src/rust/src/lib.rs | Swapped R matrix conversion for Array2<f32>, added dimension checks and manual fill loop |
| r-phylo2vec/src/rust/Cargo.toml | Added ndarray dependency |
| py-phylo2vec/src/lib.rs | Changed Python functions to use PyArray2<f32> and PyReadonlyArray2<f32> |
| py-phylo2vec/phylo2vec/utils/matrix.py | Removed unnecessary .tolist() conversion and direct float32 return |
| py-phylo2vec/phylo2vec/io/reader.py | Explicitly cast matrices to float32 before validation |
| py-phylo2vec/Cargo.toml | Bumped pyo3, added numpy and ndarray deps |
| phylo2vec/src/utils.rs | Swapped Vec<Vec<f32>> sample_matrix to Array2<f32>, updated check_m and tests |
| phylo2vec/src/tree_vec/ops/vector.rs | Changed cophenetic distance functions to return Array2<f32> and updated indexing |
| phylo2vec/src/tree_vec/ops/newick/mod.rs | Updated to_newick_from_matrix calls to use ArrayView2<f32> |
| phylo2vec/src/tree_vec/ops/matrix/mod.rs | Ported matrix parsing and generation to use Array2/ArrayView2 |
| phylo2vec/Cargo.toml | Added ndarray dependency |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Merged
Neclow
added a commit
that referenced
this pull request
Jun 30, 2025
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.
closes #80