Skip to content

Handle empty SNP/AA results in allele frequency tests - #1066

Draft
adilraza99 wants to merge 7 commits into
malariagen:masterfrom
adilraza99:GH-1064-fix-empty-dataframe-test
Draft

Handle empty SNP/AA results in allele frequency tests#1066
adilraza99 wants to merge 7 commits into
malariagen:masterfrom
adilraza99:GH-1064-fix-empty-dataframe-test

Conversation

@adilraza99

Copy link
Copy Markdown
Contributor

Summary

Fix a transient failure in allele frequency tests caused by random parameter combinations producing empty results.

Changes

  • add guards for ValueError when random parameters yield:
    • no variant SNPs
    • no amino acid change SNPs
  • update two tests:
    • test_allele_frequencies_with_str_cohorts_and_sample_query
    • test_allele_frequencies_with_str_cohorts_and_sample_query_options

Rationale

The functions snp_allele_frequencies() and aa_allele_frequencies() correctly raise
ValueError when no variants remain after filtering. Randomized test inputs can
legitimately trigger this case, causing intermittent failures.

The tests now return early when this situation occurs, following the existing
pattern already used elsewhere in the test suite.

Impact

No changes to library behaviour.
This only stabilizes the test suite by handling valid edge cases.

Closes #1064

@adilraza99
adilraza99 marked this pull request as draft March 19, 2026 04:37
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.

Transient test failure in test_allele_frequencies_with_str_cohorts_and_sample_query

2 participants