Skip to content

Add input-validation and deterministic edge-case tests - #31

Merged
aarmey merged 1 commit into
mainfrom
test/coverage-and-quality
Aug 26, 2026
Merged

Add input-validation and deterministic edge-case tests#31
aarmey merged 1 commit into
mainfrom
test/coverage-and-quality

Conversation

@aarmey

@aarmey aarmey commented Aug 26, 2026

Copy link
Copy Markdown
Member

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 (mismatched Rtot/Kav shapes, non-2D Kav/Cplx, mismatched LigC/Ctheta sizes) raise AssertionError from commonChecks()/polyfc()/polyc().
  • valentbind/test/test_edge_cases.py — pins polyfc() at f=1 against the closed-form Langmuir isotherm, adds a fixed-input regression check, and checks Rbound is monotonic in Rtot.

Bug fix found along the way: commonChecks() checked Rtot.size == Kav.shape[1] before Kav.ndim == 2, so passing a non-2D Kav raised an opaque IndexError instead of the intended AssertionError. 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% coverage
  • uv run ruff check . / uv run ruff format --check . pass
  • uvx ty check valentbind passes

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.
@aarmey
aarmey merged commit 2c46a6a into main Aug 26, 2026
0 of 2 checks passed
@aarmey
aarmey deleted the test/coverage-and-quality branch August 26, 2026 13:41
aarmey pushed a commit that referenced this pull request Aug 26, 2026
Resolves conflicts from #26-#31/#33 landing on main first: kept both
the ruff and mkdocs additions to the dev dependency group, and
regenerated uv.lock from scratch rather than hand-editing it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant