Skip to content

feat: port matrix operations to ndarray + rust-numpy#81

Merged
Neclow merged 2 commits intosbhattlab:revamp_rustfrom
Neclow:ndarray2
Jun 29, 2025
Merged

feat: port matrix operations to ndarray + rust-numpy#81
Neclow merged 2 commits intosbhattlab:revamp_rustfrom
Neclow:ndarray2

Conversation

@Neclow
Copy link
Collaborator

@Neclow Neclow commented Jun 26, 2025

closes #80

@Neclow Neclow requested review from Copilot and lsetiawan June 26, 2025 15:21
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

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>> with Array2<f32> and ArrayView2<f32> throughout core operations and tests.
  • Update R (extendr) and Python (pyo3 + numpy) glue code to accept and return ndarray types.
  • Add ndarray dependency 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>
@Neclow Neclow changed the base branch from main to revamp_rust June 29, 2025 08:21
@Neclow Neclow merged commit 69ce418 into sbhattlab:revamp_rust Jun 29, 2025
7 checks passed
@Neclow Neclow deleted the ndarray2 branch June 29, 2025 08:21
@Neclow Neclow mentioned this pull request Jun 30, 2025
Neclow added a commit that referenced this pull request Jun 30, 2025
* feat: port matrix operations to ndarray + rust-numpy

* refactor: re-vamp rust core

* Trigger Pre-Commit CI

* fix(demo): fix matrix dtype to float32
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.

Speed of Vec<Vec<f32>> binding to numpy.ndarray

2 participants