Concrete field types for every parametric law (breaking: type parameter) - #140
Open
alecloudenback wants to merge 1 commit into
Open
alecloudenback wants to merge 1 commit into
alecloudenback wants to merge 1 commit into
Conversation
Each law is now a parametric struct with a single T<:Real field type and an explicit keyword constructor that promotes its arguments, so every default law is isbits and hazard infers as Float64. Weibull and InverseWeibull defaults are spelled as floats (same values) so they too construct as Float64. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JFnc6pvofuNXTW2xdCcewT
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## refactor/04-split-parametric #140 +/- ##
=============================================================
Coverage 90.62% 90.62%
=============================================================
Files 10 10
Lines 384 384
=============================================================
Hits 348 348
Misses 36 36 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
All 25 laws were
Base.@kwdef structwith untyped fields, so no law wasisbitsand everyhazardcall boxed its parameters. Twenty of the 25 laws integratehazardwith quadgk, so this dominates the parametric path.Measured here after the change:
survival(Siler(), 20, 65)runs in 270 ns with 0 allocations (3.57 μs and 421 allocations onmaster).Changes
struct Law{T<:Real} <: ParametricMortalitywithfield::Tmembers and an explicit keyword constructorLaw(; a=..., b=...) = Law(promote(a, b)...), so mixed keyword types promote (Makeham(a=1, b=0.5, c=0)is aMakeham{Float64};Gompertz()is aMakeham{Float64}).T<:Realkeeps ForwardDiff duals working for fitting.Law{Int}; they are spelled as floats now so every default law isFloat64.Testing
ParametricMortality:L()isisbits, isL{Float64}, andhazard(L(), 50.0)infers asFloat64.Stacked on #139 (base branch
refactor/04-split-parametric). Merge the stack in order; once the base PR is merged and its branch deleted, GitHub retargets this PR tomaster.🤖 Generated with Claude Code
https://claude.ai/code/session_01JFnc6pvofuNXTW2xdCcewT