Guard _mirrored_baf against all-NaN median to fix 3.11-min CI (gh#407)#1080
Merged
Conversation
PR #407 keeps alt_freq NaN when a VCF lacks allele counts, so a bin whose het SNPs all lack frequencies hands _mirrored_baf an all-NaN slice. It then calls vals.median(), which under older (min-pinned) numpy warns "Mean of empty slice"; with pytest's filterwarnings=["error"] that warning becomes a failure -- breaking test_call_filter and test_read_vcf_het_no_alt_count in the 3.11-min job only (newer numpy doesn't warn). #407 guarded the outer summarize() but missed this inner median. Short-circuit _mirrored_baf for an all-NaN slice before calling median; the mirrored result is all-NaN regardless of direction. Add a unit test (VATests.test_mirrored_baf_all_nan) asserting no warning under warnings-as-error plus correct mirroring of a partially-NaN slice. No change to numeric output for VCFs that do have allele counts. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1080 +/- ##
=======================================
Coverage 67.80% 67.81%
=======================================
Files 74 74
Lines 7684 7686 +2
Branches 1365 1366 +1
=======================================
+ Hits 5210 5212 +2
Misses 2034 2034
Partials 440 440
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
master is currently red on the
3.11-minCI job (e.g. the merge of #1077, run26365341592), and every PR branched off master inherits the failure (#1078, #1079). This fixes the root cause.Root cause
PR #407 keeps
alt_freqas NaN when a VCF lacks allele counts. A bin whose heterozygous SNPs all lack frequencies then hands_mirrored_bafan all-NaN slice, where it calls:Under the min-pinned (older) numpy,
pd.Series.median()on an all-NaN slice routes throughnp.nanmedian→np.nanmeanof an empty slice, which emitsRuntimeWarning: "Mean of empty slice". Becausepyproject.tomlsetsfilterwarnings = ["error"], that warning becomes a test failure. Newer numpy (the regular jobs) doesn't warn, so only3.11-minfails.#407 added an all-NaN guard in the outer
summarize()(protectingsummary_func), but the innermedian()in_mirrored_bafruns first and was left unguarded.Affected tests (both via
baf_by_ranges → summarize → _mirrored_baf):test/test_commands.py::CallTests::test_call_filtertest/test_io.py::IOTests::test_read_vcf_het_no_alt_countFix
Short-circuit
_mirrored_baffor an all-NaN slice before calling.median(); the mirrored result is all-NaN regardless of mirroring direction:Tests
VATests::test_mirrored_baf_all_nan(test/test_cnvlib.py): underwarnings.simplefilter("error"), asserts an all-NaN input mirrors to all-NaN without warning, and that a partially-NaN slice still mirrors correctly (median taken over the real values).test_cnvlib.py+test_io.py+test_commands.py= 119 passed;mypyandruffclean. The warning is numpy-version-dependent, so the warnings-as-error assertion is the guard that bites in the3.11-minenvironment.Clinical-impact note
Behavior is unchanged for VCFs that do carry allele counts (the
median()path is untouched there). For the no-allele-count case the BAF was already meant to be NaN (#407); this only stops a spurious warning/crash. No change to.cnr/.cns/.cnn/SEG/VCF numeric output.Refs #407.
🤖 Generated with Claude Code