Skip to content

refactor: extract AnophelesDiversityAnalysis into anoph/Diversity.py#1153

Open
Srivatsanray wants to merge 5 commits intomalariagen:masterfrom
Srivatsanray:refactor/diversity-analysis
Open

refactor: extract AnophelesDiversityAnalysis into anoph/Diversity.py#1153
Srivatsanray wants to merge 5 commits intomalariagen:masterfrom
Srivatsanray:refactor/diversity-analysis

Conversation

@Srivatsanray
Copy link

Overview

Relates to #366

This PR continues the anopheles.py refactoring effort by extracting the diversity analysis code into a dedicated module, following the same pattern used for AnophelesFstAnalysis, and AnophelesHetAnalysis.

Changes Made

New: Diversity.py

  • Created AnophelesDiversityAnalysis class inheriting from AnophelesSnpData
  • Moved 4 methods: _block_jackknife_cohort_diversity_stats, cohort_diversity_stats, diversity_stats and plot_diversity_stats

Modified: anopheles.py

  • Removed the extracted methods
  • Added AnophelesDiversityAnalysis to the inheritance chain

New: tests/anoph/test_diversity.py

  • Added tests for cohort_diversity_stats, diversity_stats and plot_diversity_stats
  • Parametrized across all 4 species simulators (ag3, af1, adir1, amin1)

Impact

  • No changes to public API — all existing methods remain available via AnophelesDataResource
  • Existing tests pass without modification, confirming MRO integrity
  • 20 new tests all passing

@Srivatsanray Srivatsanray changed the title Refactor/diversity analysis refactor: extract AnophelesDiversityAnalysis into anoph/Diversity.py Mar 18, 2026
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