Skip to content

Commit b0c4603

Browse files
committed
fix: handle zero-cohort edge case in allele frequency test
1 parent 4338780 commit b0c4603

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

tests/anoph/test_snp_frq.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -378,11 +378,6 @@ def test_allele_frequencies_with_str_cohorts(
378378
api.snp_allele_frequencies(**params)
379379
return
380380

381-
# Run the function under test.
382-
df_snp = api.snp_allele_frequencies(**params)
383-
384-
check_plot_frequencies_heatmap(api, df_snp)
385-
386381
# Figure out expected cohort labels.
387382
df_samples = api.sample_metadata(sample_sets=sample_sets)
388383
if "cohort_" + cohorts in df_samples:
@@ -392,6 +387,18 @@ def test_allele_frequencies_with_str_cohorts(
392387
cohort_counts = df_samples[cohort_column].value_counts()
393388
cohort_labels = cohort_counts[cohort_counts >= min_cohort_size].index.to_list()
394389

390+
if len(cohort_labels) == 0:
391+
with pytest.raises(ValueError):
392+
api.snp_allele_frequencies(**params)
393+
with pytest.raises(ValueError):
394+
api.aa_allele_frequencies(**params)
395+
return
396+
397+
# Run the function under test.
398+
df_snp = api.snp_allele_frequencies(**params)
399+
400+
check_plot_frequencies_heatmap(api, df_snp)
401+
395402
# Standard checks.
396403
check_snp_allele_frequencies(
397404
api=api,

0 commit comments

Comments
 (0)