test: coverage initiative — kernels, readers, with_* API#195
Open
d-laub wants to merge 51 commits into
Open
Conversation
Three-wave plan in a single bundled PR: numba-kernel behavior tests, user-facing readers + DataLoader, and Dataset.with_* / open/indexing API surface. Excludes numba-only modules from the coverage gate since coverage.py can't instrument them.
19 tests across with_settings, with_len, with_seqs, with_tracks, and with_insertion_fill confirming each returns a new lazy view without mutating the original, and rejects invalid input. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Omit _intervals.py (numba-only) and add exclude_lines for @nb.njit, @numba.njit, and the PyTorch ImportError guard. Saves the new coverage baseline (65% overall, _genotypes 5%→100%). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…rch imports Two findings from the test-coverage initiative folded in: 1. filter_af's 2-D geno_offsets path called lengths_to_offsets (plain numpy) from inside @nb.njit, which numba could not compile. Replaced with an inline cumulative-sum loop. Unxfails test_filter_af_2d_offsets_layout. 2. test_torch.py imported torch via pytest.importorskip before genvarloader, which caused a numpy/torch ABI abort in py310 env. Reordered to import genvarloader first (which loads numpy in the order torch expects), then importorskip torch.
…oader reproducible Adds tests/integration/dataset/test_determinism.py covering: - two opens with the same rng seed + jitter produce identical reads - jitter=0 reads are byte-identical across repeated lookups - (xfail) seeded torch.Generator should give reproducible shuffled batches. Currently broken: get_sampler() builds RandomSampler without forwarding the DataLoader's generator, so the sampler uses the global torch RNG. Note: also surfaced that with_settings(rng=...) is broken in _impl.py (line 271 writes "rng" into to_evolve but the dataclass field is _rng), so the seed-equality test seeds via Dataset.open(..., rng=...) instead.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…r for reproducible shuffle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three-wave test-coverage initiative.
Wave 1 — numba kernel behavior tests (coverage.py can't instrument numba):
reconstruct_haplotype_from_sparsecase matrix (ref-only, deletion spanning region end, overlapping variants)get_diffs_sparsetests covering both fast and slow pathsfilter_aftests across min/max/both/no-op + 2-D offsets layout (xfail — see Findings)choose_exonic_variantsscenario gaps (spans start/end, entirely before/after)intervals_to_trackstestsWave 2 — user-facing readers + DataLoader:
_fasta.py: missing contig, protocol attrs, zero-length range_bigwig.py: read smoke, protocol attrs, missing path raisesRuntimeError_torch.py: 6 smoke tests forget_dataloader/get_sampler/to_dataloader(skip cleanly viaimportorskipwhen torch missing; verified passing inpy310/py311/py312/py313envs)Wave 3 — API surface:
Dataset.with_*matrix:with_settings,with_len,with_seqs,with_tracks,with_insertion_fillDataset.openerror paths: missing dir, missing metadata, missing input_regions, ploidy mismatch, empty dataset_indexing.pyedge cases: negative indices, OOB, step slices, boolean masks, empty selectionsCoverage config (
pyproject.toml):_dataset/_intervals.py(numba-only)@nb.njit/@numba.njit/ PyTorch ImportError toexclude_linesCoverage impact
Overall: 63% → 74%. Key modules:
_genotypes.py: 5% → 100% (numba exclusion working)_intervals.py: 12% → omitted_bigwig.py: 47% → 61%_open.py: 80% → 87%_tracks.py: 41% → 79%_torch.py: stays 31% indevenv (torch not installed); fully exercised inpy3xxenvsFull report:
docs/superpowers/specs/2026-05-25-test-coverage-after.txt.Findings worth surfacing
filter_af2-D offsets layout is broken — kernel callslengths_to_offsets(plain numpy) from within@nb.njit, which raises aTypingError. Test isxfail(strict=True); fix would be@nb.njit-decoratinglengths_to_offsetsin_utils.py._torch.pyABI quirk — mustimport numpybeforepytest.importorskip("torch")in py310 env to avoid a Fatal Python error during torch import. Documented in the test file with a noqa.Test plan
pixi run -e dev pytest tests— 413 passed, 4 skipped, 3 xfailedpixi run -e dev cargo test --release— 4 passedpixi run -e py310 pytest tests/unit/test_torch.py— 6 passedpixi run -e dev ruff check python/ tests/— cleanpixi run -e dev typecheck— 0 errorsSpec:
docs/superpowers/specs/2026-05-25-test-coverage-design.mdPlan:
docs/superpowers/plans/2026-05-25-test-coverage-implementation.md🤖 Generated with Claude Code