Skip to content

feat: bound class sampler#253

Draft
selmanozleyen wants to merge 4 commits into
scverse:mainfrom
selmanozleyen:feat/bound-class-sampler
Draft

feat: bound class sampler#253
selmanozleyen wants to merge 4 commits into
scverse:mainfrom
selmanozleyen:feat/bound-class-sampler

Conversation

@selmanozleyen

Copy link
Copy Markdown
Member

Putting it here to share my WIP only. Will fill the body. I tried to split this into nice 3 commits for easier review

Move the shared run-length/slice/mask machinery out of ClassSampler into a new _RunClassSampler base (subclassing BaseClassSampler) and relocate the reusable helpers into _utils. Pure relocation; ClassSampler behavior is unchanged.
Bind an inner class sampler's per-batch class schedule onto another obs table, matching classes by label (optionally on a subset of tuple positions via `on`) with optional secondary within-class weighting. Adds the supporting _utils helpers (project_index, grouped_weighted_choice, to_level_arrays, _as_multiindex) and exports BoundClassSampler.
Cover construction/validation, per-batch class replay, subset binding via `on`, within-class weighting, chaining, mask, and pickle/deepcopy round-trips for 100% line coverage of the sampler. Shared batch-iteration helpers keep the coherence checks deduplicated.
@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.80702% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.08%. Comparing base (56127d5) to head (be22c7a).

Files with missing lines Patch % Lines
src/annbatch/samplers/_class_sampler.py 92.18% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #253      +/-   ##
==========================================
- Coverage   93.43%   92.08%   -1.36%     
==========================================
  Files          15       17       +2     
  Lines        1432     1604     +172     
==========================================
+ Hits         1338     1477     +139     
- Misses         94      127      +33     
Files with missing lines Coverage Δ
src/annbatch/abc/__init__.py 100.00% <100.00%> (ø)
src/annbatch/abc/base_class_sampler.py 100.00% <100.00%> (ø)
src/annbatch/samplers/__init__.py 100.00% <100.00%> (ø)
src/annbatch/samplers/_bound_class_sampler.py 100.00% <100.00%> (ø)
src/annbatch/samplers/_utils.py 99.06% <100.00%> (-0.94%) ⬇️
src/annbatch/samplers/_class_sampler.py 95.10% <92.18%> (-4.15%) ⬇️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant