Skip to content

feat(samplers): add BoundClassSampler (merge after 304,309,314) - #309

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

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

Conversation

@selmanozleyen

@selmanozleyen selmanozleyen commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Fixes: #308

disclaimer: opus 5.5 was used in writing this code

…ase instead of a subclass, since its batches mix classes and so break ClassSampler's one-class-per-batch contract. Seeded output of both samplers is unchanged.
…mber generator, and track open passes in a shared mixin that resets them when a sampler or Loader is deep-copied or pickled. A ClassSampler, DistributedSampler or Loader copied mid-pass no longer refuses mask changes or datasets, or miscounts its shard's batches.
…r from its own generator, derived from one draw of rng with the renamed _derive_rng helper, so a pass cut short no longer changes later passes. Seeded output differs from 0.3.1.
@selmanozleyen selmanozleyen added the skip-gpu-ci Whether gpu ci should be skipped label Nov 12, 2026
@codecov

codecov Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.30%. Comparing base (c8091f0) to head (356d78f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #309      +/-   ##
==========================================
+ Coverage   91.70%   92.30%   +0.60%     
==========================================
  Files          18       19       +1     
  Lines        1519     1638     +119     
==========================================
+ Hits         1393     1512     +119     
  Misses        126      126              
Files with missing lines Coverage Δ
src/annbatch/abc/sampler.py 100.00% <100.00%> (ø)
src/annbatch/loader.py 87.76% <100.00%> (-0.12%) ⬇️
src/annbatch/samplers/__init__.py 100.00% <100.00%> (ø)
src/annbatch/samplers/_chunk_sampler.py 100.00% <100.00%> (ø)
src/annbatch/samplers/_class_samplers/__init__.py 100.00% <100.00%> (ø)
...h/samplers/_class_samplers/_bound_class_sampler.py 100.00% <100.00%> (ø)
...nnbatch/samplers/_class_samplers/_class_sampler.py 100.00% <100.00%> (ø)
.../annbatch/samplers/_class_samplers/_rle_manager.py 97.18% <100.00%> (-0.41%) ⬇️
...amplers/_class_samplers/_weighted_class_sampler.py 100.00% <100.00%> (ø)
src/annbatch/samplers/_distributed_sampler.py 98.41% <100.00%> (+0.05%) ⬆️
... and 2 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@selmanozleyen selmanozleyen changed the title feat(samplers): add BoundClassSampler feat(samplers): add BoundClassSampler (ready after 304 -> 309) Nov 12, 2026
@selmanozleyen selmanozleyen changed the title feat(samplers): add BoundClassSampler (ready after 304 -> 309) feat(samplers): add BoundClassSampler (ready after 304 and 309) Nov 12, 2026
…te copy of a ClassSampler or BoundClassSampler each pass and draws each batch from its own classes matching the inner batch's class on the label columns paired by on. Pairing survives a primary pass that is cut short, and restored pickles start a fresh paired pass.
@selmanozleyen
selmanozleyen force-pushed the feat/bound-class-sampler-v2 branch from f324409 to 356d78f Compare November 12, 2026 15:17
@selmanozleyen selmanozleyen changed the title feat(samplers): add BoundClassSampler (ready after 304 and 309) feat(samplers): add BoundClassSampler (merge after 304,309,314) Nov 13, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-gpu-ci Whether gpu ci should be skipped

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a BoundClassSampler to connect samplers with class pure batches

1 participant