Skip to content

refactor(opt): update optimisation classes#62

Merged
Neclow merged 2 commits intosbhattlab:mainfrom
Neclow:update_opt
May 30, 2025
Merged

refactor(opt): update optimisation classes#62
Neclow merged 2 commits intosbhattlab:mainfrom
Neclow:update_opt

Conversation

@Neclow
Copy link
Collaborator

@Neclow Neclow commented May 30, 2025

  • base class:
    • infer an optimal number of jobs (in lieu of effective_n_jobs from joblib, which just seems to pick all jobs available)
    • add verbose argument
    • add time taken by fitting function
    • remove numba dependency for label mappings
  • hc class:
    • fix bug in loss vs. tolerance (_optimise)
    • start with lower indices of v in _optimise_single (no longer reversed)
      --> time on toy h3n2 dataset down to ~5 s (before: 60-70 s)
  • gitignore: add trees folder (created by optimisation schemes by default)
  • get rid of numba dependency

@Neclow Neclow requested a review from Copilot May 30, 2025 14:02
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 optimisation classes in Phylo2Vec to improve performance and clarity by removing the numba dependency for label mapping, introducing a verbose option with timing information, and addressing a bug in the HC class loss tolerance evaluation. Key changes include:

  • Removing the numba dependency from pyproject.toml.
  • Renaming parameters from taxa_dict to label_mapping and updating the associated logic in _hc_losses.py, _hc.py, and _base.py.
  • Refactoring the base optimizer to infer n_jobs without using effective_n_jobs and adding timing output.

Reviewed Changes

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

Show a summary per file
File Description
py-phylo2vec/pyproject.toml Removed the numba dependency and updated dependency comment
py-phylo2vec/phylo2vec/opt/_hc_losses.py Updated parameter names in raxml_loss to use label_mapping
py-phylo2vec/phylo2vec/opt/_hc.py Renamed taxa_dict to label_mapping; updated tolerance condition
py-phylo2vec/phylo2vec/opt/_base.py Modified init to accept verbose and n_jobs; added _infer_n_jobs
docs/demo.ipynb Updated documentation to reflect removal of numba dependency
Comments suppressed due to low confidence (1)

py-phylo2vec/phylo2vec/opt/_hc_losses.py:19

  • The docstring for raxml_loss still documents a parameter named 'taxa_dict'; it should be updated to 'label_mapping' to reflect the changes in the parameter name.
def raxml_loss(

@Neclow Neclow merged commit 3a5f5bb into sbhattlab:main May 30, 2025
7 checks passed
@Neclow Neclow deleted the update_opt branch May 30, 2025 14:07
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