Skip to content

Commit 9f8bfb7

Browse files
kunal-10-cloudkhushthecoder
authored andcommitted
fix: guard against empty allele count array in test_snp_allele_counts
When a randomly selected region has no SNP sites after applying the site mask, the allele count array is empty and calling .max() on it raises ValueError. Skip the max assertion for zero-size arrays. This fixes a pre-existing flaky test failure: ValueError: zero-size array to reduction operation maximum which has no identity
1 parent 5a7afa8 commit 9f8bfb7

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

tests/anoph/test_snp_data.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,8 @@ def check_snp_allele_counts(
11341134
assert ac.shape == (pos.shape[0], 4)
11351135
assert np.all(ac >= 0)
11361136
an = ac.sum(axis=1)
1137-
assert an.max() <= 2 * n_samples
1137+
if an.size > 0:
1138+
assert an.max() <= 2 * n_samples
11381139

11391140
# Run again to ensure loading from results cache produces the same result.
11401141
ac2 = api.snp_allele_counts(

0 commit comments

Comments
 (0)