Repository navigation
TST: seed test_subsample to remove flaky failure - #1007
Merged
Merged
Conversation
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>
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.
SparseTableTests.test_subsamplechecks that all four possible outcomes forO1appear across 100 unseededsubsample(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 themasterpush ofafffa0c(run 37349225586), after the same commit passed all checks in #1006.This PR passes
seed=iin 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