Skip to content

Polish & robustness: validation guards, __all__, coverage gate, viz tests - #47

Merged
davidkhjo merged 4 commits into
mainfrom
polish-robustness
Aug 19, 2026
Merged

davidkhjo merged 4 commits into
mainfrom
polish-robustness

Conversation

@davidkhjo

Copy link
Copy Markdown
Owner

Polish & robustness (non-breaking)

Second half of the cleanup — small correctness, consistency, and tooling wins from the API audit. No API changes, no version bump.

Robustness guards (each previously could NaN silently while peer methods guarded):

  • DenoisingScoreMatching rejects sigma <= 0; SlicedScoreMatching rejects n_projections < 1; classifier_two_sample_test validates test_frac ∈ (0,1) and ≥2 samples/set.
  • @torch.no_grad() on ood_auroc for parity with the other eval metrics.

Consistency & docs:

  • One-line docstrings for eight_gaussians / checkerboard / rings / spirals (parity with two_moons).
  • Explicit __all__ on datasets and viz (matching eval / nets).

Dev tooling:

  • Coverage gate fail_under = 90 (actual 97.6%) so the badge is enforced against regressions.
  • ruff extended with C4/PIE/PERF/RUF (ignoring the ambiguous-Unicode rules — the library uses σ/ε/ρ math notation on purpose) + per-file-ignores for test lambdas; fixed the few real nits (itertools.pairwise, unused unpack, dict-literals).
  • Gitignore the stray ebmkit-blog-post.txt.

Tests: added coverage for energy_contour / plot_samples / energy_histogram (the one coverage hole) and the new guards.

Verification: ruff + format + mypy clean; 157 tests pass; coverage 97.6%.

🤖 Generated with Claude Code

DenoisingScoreMatching sigma>0, SlicedScoreMatching n_projections>=1, and
classifier_two_sample_test (test_frac in (0,1), >=2 samples/set) — each
previously could NaN silently while peer methods guarded. @torch.no_grad on
ood_auroc to match the other eval metrics.
One-line docstrings for eight_gaussians/checkerboard/rings/spirals (parity with
two_moons); explicit __all__ on datasets and viz to document the public surface
(matching eval/nets).
Enforce coverage fail_under=90 (currently 96%); extend ruff to C4/PIE/PERF/RUF
(ignoring the ambiguous-Unicode rules — the library uses σ/ε/ρ math notation on
purpose) + per-file E731 for test lambdas; fix the handful of real lint nits
(itertools.pairwise, unused unpack, dict-literals). Add tests for
energy_contour/plot_samples/energy_histogram (the one coverage hole). Gitignore
the stray ebmkit-blog-post.txt.
@davidkhjo
davidkhjo merged commit 5f4bc45 into main Aug 19, 2026
5 checks passed
@davidkhjo davidkhjo mentioned this pull request Aug 21, 2026
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