Skip to content

TST: seed test_subsample to remove flaky failure - #1007

Merged
wasade merged 1 commit into
masterfrom
test/seed-subsample
Oct 12, 2026
Merged

wasade merged 1 commit into
masterfrom
test/seed-subsample

Conversation

@wasade

@wasade wasade commented Oct 5, 2026

Copy link
Copy Markdown
Member

SparseTableTests.test_subsample checks that all four possible outcomes for O1 appear across 100 unseeded subsample(3) draws. (3, 0, 0) requires both S2 and S3 to drop their single O1 read, which has p = 1/4 × 1/4 = 1/16 per draw. Across 100 draws the outcome is missing with probability (15/16)^100 ≈ 0.16%, about 1 run in 640. This happened on the master push of afffa0c (run 37349225586), after the same commit passed all checks in #1006.

This PR passes seed=i in the loop. Each iteration gets a different seed, so the test still checks that all four outcomes occur, but the result is now the same on every run. A single seed shared by all iterations would make every draw identical, which would break the test.

Checked with the 2.1.18 wheels: seeds 0–99 produce the same outcome counts, {(3,0,0): 6, (3,0,1): 26, (3,1,0): 22, (3,1,1): 46}, on numpy 1.26.4, 2.0.2, 2.2.6, 2.3.5 and 2.5.3 (Python 3.9–3.14), which covers the CI matrix. numpy doesn't promise identical random output across versions, so a future numpy could change this. If that drops an outcome, the test would fail every time, not intermittently.

The other randomized subsample tests in the file have chances of missing an outcome around 10⁻¹² or smaller, so they're left as is.

🤖 Generated with Claude Code

test_subsample expects all four outcomes for O1 across 100 unseeded
draws. (3, 0, 0) occurs with p=1/16 per draw, so the test fails
~0.16% of the time ((15/16)**100). It failed on the master push of
afffa0c (run 37349225586) after passing on the same commit in #1006.

Seed each iteration with its index so the draws are deterministic
while still covering every outcome.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wasade
wasade merged commit 0cc6527 into master Oct 12, 2026
63 checks passed
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.

1 participant