test: add hypothesis property-based tests for analysis invariants#42
Merged
Conversation
Property-based testing dependency for analysis invariant tests (#17). Lockfile regenerated with uv lock for CI's --locked sync. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
New tests/test_invariants.py covering algorithmic invariants that must hold for any valid input (issue #17): - integrated LUFS shifts by exactly 20*log10(scale) under amplitude scaling - identical L/R channels: correlation 1.0, width 0, balance 0, no polarity flag - polarity-flipped right channel: correlation -1.0, polarity flag set - time reversal preserves octave-band energies, centroid, and stereo correlation - DC offset above threshold is always flagged by detect_problems - leading silence is excluded by EBU R128 gating (integrated LUFS and true peak unchanged) Hypothesis profiles registered in conftest.py: default "ci" profile is derandomized for reproducibility; "nightly" (HYPOTHESIS_PROFILE=nightly) runs randomized with 200 examples for broader coverage. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Scheduled daily run of tests/test_invariants.py with the randomized "nightly" hypothesis profile (200 examples) for broader coverage than the derandomized default used in CI (#17). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Match the checkout version bumped repo-wide by #39. Co-Authored-By: Claude Fable 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.
Summary
Adds property-based invariant tests with hypothesis, per the plan in #17.
hypothesis>=6.0added to thedevextra;uv.lockregenerated for CI'suv sync --locked.tests/conftest.py:ci(default): derandomized, 20 examples — fully deterministic in CI and locally, satisfying the reproducibility requirement without any pytest flag changes.nightly: randomized, 200 examples — selected viaHYPOTHESIS_PROFILE=nightly.tests/test_invariants.py(7 property tests):20*log10(scale)(±0.1 LU).1.0, width0.0, balance0.0, no polarity flag.-1.0,polarity_invertedset.5e-4threshold is always flagged bydetect_problems..github/workflows/nightly-hypothesis.yml: daily scheduled + manual-dispatch run of the invariant tests with the randomized nightly profile (permissions: contents: read, no untrusted input interpolation).All invariants pass on the current implementation — no bugs revealed, so no follow-up issues or xfails were needed. Tolerances were tuned empirically (time-reversal signal lengthened to 2 s to keep frame-boundary effects well below tolerance; worst observed deviation across 40 random seeds is 0.2 dB against the 1.0 dB bound).
Closes #17
Test plan
uv run pytest tests/test_invariants.py -q— 7 passeduv run pytest tests/ -x -q— 1043 passed, 47 skippeduv tool run ruff check src/ tests/andruff format --check— cleanHYPOTHESIS_PROFILE🤖 Generated with Claude Code