Skip to content

Revamp rust core#82

Merged
Neclow merged 4 commits intosbhattlab:mainfrom
Neclow:revamprust
Jun 30, 2025
Merged

Revamp rust core#82
Neclow merged 4 commits intosbhattlab:mainfrom
Neclow:revamprust

Conversation

@Neclow
Copy link
Collaborator

@Neclow Neclow commented Jun 30, 2025

I propose a refactoring of the codebase with a stronger separation of concerns based what each functions does:

  • converting a vector/matrix to another tree representation
  • Newick processing utilies
  • Operations on vectors
  • Common graph/tree theory objects (e.g., cophenetic distance matrix, and soon adjacency/precision/incidence/vcov matrices)

As tree_vec is not used, it makes sense (for me, at least) to isolate it somewhere else instead of making it the "super-class". The current structure also mimicks a bit more the current python API, so it should be easier to parse.

Features

Includes #81, which ports matrix operations to ndarray/numpy. See the issue for more details.

Side effects:

  • Added tests on all public functions in rust
  • Fix test naming in python

Diagram

Previous architecture:
image

New proposed architecture:
image

Closed issues

closes #81 and closes #80

@Neclow Neclow changed the base branch from revamp_rust to main June 30, 2025 13:32
@Neclow Neclow requested a review from Copilot June 30, 2025 13:45
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 refactors the core Rust components of the library by reorganizing module structures, splitting functionality into dedicated modules (e.g. vector, matrix, newick, tree_vec), and updating conversions and validations. Key changes include:

  • Moving and renaming utility functions from the old “utils” module into more targeted modules (e.g. vector::base, matrix::base, newick).
  • Updating conversion functions between matrix and Newick representations with improved use of ndarray views and error handling.
  • Adjusting benchmarks and Python demo assets to work with the revised module structure.

Reviewed Changes

Copilot reviewed 28 out of 30 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/lib.rs Updates module re-exports and refactors dependency on the old utils.
src/newick/mod.rs Renames and refactors Newick parsing and formatting functions.
src/matrix/convert.rs Adds conversion functions from Newick to matrix and vice versa.
src/vector/convert.rs Refactors vector conversion functions (e.g. to_newick, from_newick).
src/tree_vec/mod.rs Updates TreeVec methods to delegate to the new convert functions.
benches/benchmarks/core.rs Adjusts benchmarks to use the refactored functions.
Cargo.toml Updates dependency on ndarray and other revisions.
docs/demo.ipynb Updates demo cells to reflect new function signatures and type casts.

@Neclow Neclow merged commit 6dc3ed7 into sbhattlab:main Jun 30, 2025
13 checks passed
@Neclow Neclow deleted the revamprust branch October 16, 2025 12:36
@Neclow Neclow restored the revamprust branch October 16, 2025 12:36
@Neclow Neclow deleted the revamprust branch October 16, 2025 12:36
@Neclow Neclow restored the revamprust branch October 16, 2025 12:37
@Neclow Neclow deleted the revamprust branch October 16, 2025 13:02
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