Add input-validation and deterministic edge-case tests - #31
Merged
Conversation
Line/branch coverage was already 100%, but that only meant every assert's success path had run — nothing exercised the failure path of commonChecks()/polyfc()/polyc()'s shape checks, and every existing test used random fuzzed inputs with no fixed-point regression check or valency=1 boundary case. - test_validation.py: confirms malformed inputs (mismatched Rtot/Kav shapes, non-2D Kav/Cplx, mismatched LigC/Ctheta sizes) raise AssertionError from commonChecks()/polyfc()/polyc(). - test_edge_cases.py: pins polyfc() at f=1 to the closed-form Langmuir isotherm, adds a fixed-input regression check, and checks Rbound is monotonic in Rtot. While adding the shape-mismatch tests, found that commonChecks() checked `Rtot.size == Kav.shape[1]` before `Kav.ndim == 2`, so a non-2D Kav raised an opaque IndexError instead of the intended AssertionError. Reordered the checks so malformed input fails on the assertion that actually describes the problem.
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
Line/branch coverage was already 100%, but that only meant every assert's success path had run, and every existing test used randomized inputs with no fixed-point regression or boundary-value check. Added:
valentbind/test/test_validation.py— confirms malformed inputs (mismatchedRtot/Kavshapes, non-2DKav/Cplx, mismatchedLigC/Cthetasizes) raiseAssertionErrorfromcommonChecks()/polyfc()/polyc().valentbind/test/test_edge_cases.py— pinspolyfc()atf=1against the closed-form Langmuir isotherm, adds a fixed-input regression check, and checksRboundis monotonic inRtot.Bug fix found along the way:
commonChecks()checkedRtot.size == Kav.shape[1]beforeKav.ndim == 2, so passing a non-2DKavraised an opaqueIndexErrorinstead of the intendedAssertionError. Reordered the two checks so malformed input fails on the assertion that actually explains the problem.Test plan
uv run pytest --cov=valentbind --cov-branch— 14 passed, 100% coverageuv run ruff check ./uv run ruff format --check .passuvx ty check valentbindpasses