Fix extended battery rejecting correct samplers on its default path - #7
Merged
Conversation
UnivariateSamples.run_extended_battery() called without an explicit `samples=`
argument rebuilt the sample list from the histogram:
samples = [z for z in self.histogram for _ in range(self.histogram[z])]
which is *sorted*. The three sequence tests -- Ljung-Box, runs, block
homogeneity -- measure ordering, so they saw a perfectly monotone stream and
rejected at p ~ 0. Any correct sampler therefore failed the default battery
(all_pass=False, is_valid_extended=False).
The class already receives the ordered samples in __init__ and threw them away.
Keep them (by reference, no memory cost) and use them as the default.
Verified on 20k samplerz draws: default path went from ljung_box/runs/
block_homogeneity all at p=0.0000 to p=0.26/0.72/0.90, all_pass=True.
The suite never caught this because every test passed `samples=` explicitly, so
the default path was unexercised -- the same blind spot as the earlier nan bug.
Added test_extended_battery_default_samples, which exercises the default path
and fails on all six good vectors without this fix.
Co-Authored-By: Claude Opus 4.8 <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.
Found while answering "how do I run the univariate battery?" — the documented, default way to call it gives a guaranteed false alarm.
The bug
UnivariateSamples.run_extended_battery()without an explicitsamples=rebuilds the sample list from the histogram:That list is sorted. The three sequence tests — Ljung-Box, runs, block homogeneity — measure ordering, so they see a perfectly monotone stream and reject at p ≈ 0. Every correct sampler fails the default battery.
Measured on 20 000
samplerzdraws:samples=ljung_boxruns_testblock_homogeneityall_passThe fix
The class already receives the ordered samples in
__init__and discards them. Keep them (by reference — no memory cost,MultivariateSamplespasses a pandas Series view) and use them as the default.Why CI missed it
Every existing test passes
samples=explicitly, so the default path was never exercised — the same blind spot as the earliernanbug. Addedtest_extended_battery_default_samples, which exercises it. Verified: that test fails on all six good vectors without this fix, passes with it.Suite: 140 passed, 1 skipped.
🤖 Generated with Claude Code