Repository navigation
fix: add minimum input length guards to all test modules - #34
Merged
Merged
Conversation
Addresses issue #13. Tests that received short inputs either crashed (division by zero, IndexError) or silently returned the magic value -1.0, giving users no indication of why the test failed. Changes per file: - Matrix.py: replace (-1.0, False) with descriptive error tuple - Complexity.py: replace (-1.0, False) with descriptive error tuple - Spectral.py: add n < 1000 guard (NIST SP 800-22 minimum) - TemplateMatching.non_overlapping_test: add guard for n < block*pattern_size to prevent division by zero when block_size=0 - TemplateMatching.overlapping_patterns: add guard for n < block_size to prevent division by zero at xObs computation - RandomExcursions.random_excursions_test: add guard for num_cycles=0 to prevent division by zero in xObs = sum(.../ inner_term) All error returns follow the existing (0.0, False, 'Error: ...') pattern established by RunTest.longest_one_block_test and Universal.statistical_test. Closes #13 Co-Authored-By: Claude Sonnet 4.6 <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.
Summary
Matrix.py: replace silent(-1.0, False)with descriptive error tuple when input < 1024 bitsComplexity.py: replace silent(-1.0, False)with descriptive error tuple when input < 2×block_sizeSpectral.py: add guard for n < 1000 (NIST SP 800-22 minimum)TemplateMatching.non_overlapping_test: add guard for n < block×pattern_size to prevent division by zero when block_size=0TemplateMatching.overlapping_patterns: add guard for n < block_size to prevent division by zero in xObs computationRandomExcursions.random_excursions_test: add guard for num_cycles=0 to prevent division by zeroAll error returns follow the existing
(0.0, False, 'Error: ...')pattern already established byRunTest.longest_one_block_testandUniversal.statistical_test.Related Issues
Closes #13
Related to #10 (users getting confusing results with short inputs)
Test plan
python3 test_e.pyand confirm all results are unchanged (1,000,000 bit input well above all minimums)-1.0🤖 Generated with Claude Code