Skip to content

test: replace shape-only assertions with value checks (Modified/Weighted, #100) - #149

Merged
seabbs merged 1 commit into
mainfrom
test/depth-modified-weighted-100
Aug 12, 2026
Merged

seabbs merged 1 commit into
mainfrom
test/depth-modified-weighted-100

Conversation

@seabbs-bot

Copy link
Copy Markdown
Collaborator

Summary

Closes test-depth gaps 4-6 from #100, scoped to test/Modified.jl and test/Weighted.jl.

  • Gap 4 (Modified.jl "effect surface" test): the five bare @test modify(...) isa UnivariateDistribution{...} assertions now each carry a value check — the scalar log/identity links compare against their closed forms, the constant callable effect is checked against the scalar log-link result (a constant β(t) = 0.5 is the same proportional-hazards model), and the discrete per-bin cases compare against an inline, independently written hazard→link→PMF reconstruction rather than calling into the package's own helper.
  • Gap 5 (ForwardDiff gradient test): the two @test isfinite(g_lp) / @test isfinite(g_cdf) checks now compare the AD derivative against a central finite difference of the same closed form, for every (base, beta) combination in the loop (previously only one combination was spot-checked this way). Evaluation moved off a shared x = 3.0 to each base's own 90th-percentile point, since a fixed x fell inside a clamped-to-zero density band for one combination, where logpdf is -Inf and naive finite differences produce NaN.
  • Also strengthened while in the neighbourhood, since the pattern is the same:
    • The numeric-quadrature-path callable-effect test replaced isfinite/bounds/tautological pdf >= 0.0 checks with a brute-force trapezoidal integral of the modified hazard and the pdf(x) = hazard(x) * survival(x) identity.
    • A HazardLink (cloglog) construction check now also asserts it round-trips.
    • Weighted's scalar and batch rand "delegates to the base distribution" tests now assert bit-for-bit equality against an identically-seeded direct call to the base distribution, rather than isa Real / all(>(0)).

No source changes. All existing and new assertions pass (2195 tests, full suite, fresh process).

Bugs found

None. No source-level issues were found while deriving the reference values — every closed form and cross-check matched the existing implementation to numerical tolerance.

Test plan

  • julia --project=test test/runtests.jl skip_quality — 2195 passed, 0 failed, fresh process
  • Filtered Modified.jl/Weighted.jl run — 1398 passed
  • JuliaFormatter via pre-commit hook — passed

This was opened by a bot. Please ping @seabbs for any questions.

Closes test-depth gaps 4-6 from #100 in Modified.jl and Weighted.jl:
the five bare `isa` checks in the "effect surface" test now compare
against closed forms and an inline hazard-reconstruction reference;
the two isfinite-only gradient checks now compare ForwardDiff against
central finite differences of the same closed form; the isfinite/
tautological-pdf>=0 checks on the numeric quadrature path now compare
against a brute-force trapezoidal integral and the pdf = hazard *
survival identity; and several bare `isa`/weak-bound checks (a
HazardLink round trip, Weighted's scalar and batch rand delegation)
now assert exact values instead of type or sign alone.

No source changes; all existing and new assertions pass.
@github-actions

Copy link
Copy Markdown
Contributor

Try this Pull Request!

Option 1: Julia Package Manager

Open Julia and type:

import Pkg
Pkg.activate(temp=true)
Pkg.add(url="https://github.com/EpiAware/ModifiedDistributions.jl", rev="test/depth-modified-weighted-100")
using ModifiedDistributions

Option 2: Local Checkout

If you have the repo locally:

git checkout test/depth-modified-weighted-100
julia --project=. -e "using Pkg; Pkg.instantiate()"

@codecov

codecov Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
ad-enzyme-forward 27.14% <ø> (ø)
ad-enzyme-reverse 27.14% <ø> (ø)
ad-forwarddiff 16.16% <ø> (ø)
ad-mooncake-forward 16.16% <ø> (ø)
ad-mooncake-reverse 16.16% <ø> (ø)
ad-reversediff 16.16% <ø> (ø)
unit 97.42% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown
Contributor

📖 Documentation preview is ready!

View the docs for this PR at: https://EpiAware.github.io/ModifiedDistributions.jl/previews/PR149/

This preview will be updated automatically when you push new commits.

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.

2 participants