From 6f237f5cb587972466437977073d3ddfbe11c46d Mon Sep 17 00:00:00 2001 From: Alec Loudenback Date: Fri, 11 Sep 2026 17:47:00 -0600 Subject: [PATCH 1/4] Interpolate the missing table name into the get_SOA_table error The error message contained the literal text `table_name` because the interpolation sigil was missing. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01JFnc6pvofuNXTW2xdCcewT --- src/get_SOA_table.jl | 2 +- test/get_SOA_tables.jl | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/get_SOA_table.jl b/src/get_SOA_table.jl index 44af651..54428b9 100644 --- a/src/get_SOA_table.jl +++ b/src/get_SOA_table.jl @@ -15,7 +15,7 @@ function get_SOA_table(table_name::String; source_map = table_source_map) if entry === nothing search_method = StringDistances.Partial(StringDistances.Levenshtein()) suggestion, _ = StringDistances.findnearest(table_name,collect(keys(source_map)), search_method) - throw(ArgumentError("table name \"table_name\" not found in table set; " * + throw(ArgumentError("table name \"$table_name\" not found in table set; " * "most similar available name is: \"$suggestion\"")) end readXTbML(joinpath(artifact"mort.soa.org", "t$entry.xml")) diff --git a/test/get_SOA_tables.jl b/test/get_SOA_tables.jl index 239da4e..a323f07 100644 --- a/test/get_SOA_tables.jl +++ b/test/get_SOA_tables.jl @@ -19,4 +19,14 @@ @test tbl isa MortalityTable @test_throws ArgumentError get_SOA_table("hello") + + # the error message should name the table that was not found + err = try + get_SOA_table("no such table") + nothing + catch e + e + end + @test err isa ArgumentError + @test occursin("no such table", err.msg) end From aadda76cf08a273b4f1099eb1dfa657bd2ef5b37 Mon Sep 17 00:00:00 2001 From: Alec Loudenback Date: Fri, 11 Sep 2026 17:47:12 -0600 Subject: [PATCH 2/4] =?UTF-8?q?Make=20the=20=CF=89=20and=20table=20aliases?= =?UTF-8?q?=20const?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both were non-const global bindings, so every call through them was type-unstable. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01JFnc6pvofuNXTW2xdCcewT --- src/MortalityTable.jl | 2 +- src/get_SOA_table.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MortalityTable.jl b/src/MortalityTable.jl index fad1b4b..97172dc 100644 --- a/src/MortalityTable.jl +++ b/src/MortalityTable.jl @@ -307,7 +307,7 @@ function omega(x) return lastindex(x) end -ω = omega +const ω = omega """ diff --git a/src/get_SOA_table.jl b/src/get_SOA_table.jl index 54428b9..501395d 100644 --- a/src/get_SOA_table.jl +++ b/src/get_SOA_table.jl @@ -29,4 +29,4 @@ Given the id or name of a `mort.SOA.org` table, grab it and return it as a `Mort !!! Remember that not all tables have been tested to work. """ -table = get_SOA_table \ No newline at end of file +const table = get_SOA_table \ No newline at end of file From 3680b8133b40065c0fecd27b31af30827d1212a6 Mon Sep 17 00:00:00 2001 From: Alec Loudenback Date: Fri, 11 Sep 2026 17:47:13 -0600 Subject: [PATCH 3/4] Delete the unused table_dirs global It was referenced nowhere and evaluated the artifact path at precompile time, baking an absolute depot path into the image. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01JFnc6pvofuNXTW2xdCcewT --- src/MortalityTables.jl | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/MortalityTables.jl b/src/MortalityTables.jl index 1bc1e9f..428b5a1 100644 --- a/src/MortalityTables.jl +++ b/src/MortalityTables.jl @@ -19,10 +19,6 @@ include("get_SOA_table.jl") include("parameterized_models.jl") include("life_expectancy.jl") -table_dirs = Dict( - "mort.soa.org" => artifact"mort.soa.org", -) - export MortalityTable, survival, decrement, From d268440787d489689131b5a84d923592339ab1ee Mon Sep 17 00:00:00 2001 From: Alec Loudenback Date: Fri, 11 Sep 2026 17:47:38 -0600 Subject: [PATCH 4/4] Only print the mort.SOA.org id and link when the table has an id Custom tables printed a broken link ending in TableIdentity=nothing. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01JFnc6pvofuNXTW2xdCcewT --- src/MortalityTable.jl | 51 ++++++++++++++++++++++++++++--------------- test/basic.jl | 11 ++++++++++ 2 files changed, 44 insertions(+), 18 deletions(-) diff --git a/src/MortalityTable.jl b/src/MortalityTable.jl index 97172dc..35ac1ed 100644 --- a/src/MortalityTable.jl +++ b/src/MortalityTable.jl @@ -128,24 +128,39 @@ function MortalityTable(ultimate; metadata = TableMetaData()) end -Base.show(io::IO, ::MIME"text/plain", mt::MortalityTable) = print( - io, - """ - MortalityTable ($(mt.metadata.content_type)): - Name: - $(mt.metadata.name) - Fields: - $(fieldnames(typeof(mt))) - Provider: - $(mt.metadata.provider) - mort.SOA.org ID: - $(mt.metadata.id) - mort.SOA.org link: - https://mort.soa.org/ViewTable.aspx?&TableIdentity=$(mt.metadata.id) - Description: - $(mt.metadata.description) - """, -) +function Base.show(io::IO, ::MIME"text/plain", mt::MortalityTable) + print( + io, + """ + MortalityTable ($(mt.metadata.content_type)): + Name: + $(mt.metadata.name) + Fields: + $(fieldnames(typeof(mt))) + Provider: + $(mt.metadata.provider) + """, + ) + # only mort.SOA.org sourced tables have an id and a link + if mt.metadata.id !== nothing + print( + io, + """ + mort.SOA.org ID: + $(mt.metadata.id) + mort.SOA.org link: + https://mort.soa.org/ViewTable.aspx?&TableIdentity=$(mt.metadata.id) + """, + ) + end + print( + io, + """ + Description: + $(mt.metadata.description) + """, + ) +end """ diff --git a/test/basic.jl b/test/basic.jl index 472401f..7faa24e 100644 --- a/test/basic.jl +++ b/test/basic.jl @@ -85,6 +85,17 @@ @test d.name == "test" end + @testset "show" begin + # a custom table has no mort.SOA.org id, so no link should be printed + s = sprint(show, MIME"text/plain"(), MortalityTable(UltimateMortality([0.1, 0.2]))) + @test !occursin("TableIdentity=nothing", s) + @test !occursin("mort.SOA.org ID", s) + @test occursin("Description", s) + + s = sprint(show, MIME"text/plain"(), MortalityTable(UltimateMortality([0.1, 0.2]), metadata = TableMetaData(id = "42"))) + @test occursin("TableIdentity=42", s) + end + @testset "mortality_vector" begin v = [i for i = 3:10] q = mortality_vector(v, start_age = 3)