From 4286f09669477445d3f734af22153a14aa53016e Mon Sep 17 00:00:00 2001 From: mosesmakola Date: Wed, 9 Jul 2025 10:06:15 +0100 Subject: [PATCH 1/5] removed all upper bounds of inf when truncated method is called --- test/varinfo.jl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/varinfo.jl b/test/varinfo.jl index 7439869cf..a72dd0f6f 100644 --- a/test/varinfo.jl +++ b/test/varinfo.jl @@ -69,6 +69,8 @@ end # Test Base functions: # string, Symbol, ==, hash, in, keys, haskey, isempty, push!!, empty!!, # getindex, setindex!, getproperty, setproperty! + + #= It's just this that needs to go I believe. Everything else is already gone csym = gensym() vn1 = @varname x[1][2] @test string(vn1) == "x[1][2]" @@ -77,6 +79,7 @@ end vn2 = @varname x[1][2] @test vn2 == vn1 @test hash(vn2) == hash(vn1) + =# function test_base(vi_original) vi = deepcopy(vi_original) From 5d166192aa2b03b1401319c53cc679fd5ddd72a4 Mon Sep 17 00:00:00 2001 From: mosesmakola Date: Wed, 9 Jul 2025 10:17:50 +0100 Subject: [PATCH 2/5] removed all upper bounds of inf for truncated method call --- src/test_utils/models.jl | 6 +++--- test/compiler.jl | 2 +- test/varinfo.jl | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/test_utils/models.jl b/src/test_utils/models.jl index e29614982..c44024863 100644 --- a/src/test_utils/models.jl +++ b/src/test_utils/models.jl @@ -14,12 +14,12 @@ A model with variables `m` and `x` with `x` having support depending on `m`. """ @model function demo_dynamic_constraint() m ~ Normal() - x ~ truncated(Normal(), m, Inf) + x ~ truncated(Normal(); lower=m) return (m=m, x=x) end function logprior_true(model::Model{typeof(demo_dynamic_constraint)}, m, x) - return logpdf(Normal(), m) + logpdf(truncated(Normal(), m, Inf), x) + return logpdf(Normal(), m) + logpdf(truncated(Normal(); lower=m), x) end function loglikelihood_true(model::Model{typeof(demo_dynamic_constraint)}, m, x) return zero(float(eltype(m))) @@ -30,7 +30,7 @@ end function logprior_true_with_logabsdet_jacobian( model::Model{typeof(demo_dynamic_constraint)}, m, x ) - b_x = Bijectors.bijector(truncated(Normal(), m, Inf)) + b_x = Bijectors.bijector(truncated(Normal(); lower=m)) x_unconstrained, Δlogp = Bijectors.with_logabsdet_jacobian(b_x, x) return (m=m, x=x_unconstrained), logprior_true(model, m, x) - Δlogp end diff --git a/test/compiler.jl b/test/compiler.jl index a0286d405..e3b15ab69 100644 --- a/test/compiler.jl +++ b/test/compiler.jl @@ -501,7 +501,7 @@ module Issue537 end @model function demo(y) α ~ Uniform() μ ~ Normal() - σ ~ truncated(Normal(), 0, Inf) + σ ~ truncated(Normal(), lower=0) num_steps = length(y[1]) num_obs = length(y) @inbounds for i in 1:num_obs diff --git a/test/varinfo.jl b/test/varinfo.jl index a72dd0f6f..f922bc2ee 100644 --- a/test/varinfo.jl +++ b/test/varinfo.jl @@ -182,14 +182,14 @@ end @testset "setval! & setval_and_resample!" begin @model function testmodel(x) n = length(x) - s ~ truncated(Normal(), 0, Inf) + s ~ truncated(Normal(); lower=0) m ~ MvNormal(zeros(n), I) return x ~ MvNormal(m, s^2 * I) end @model function testmodel_univariate(x, ::Type{TV}=Vector{Float64}) where {TV} n = length(x) - s ~ truncated(Normal(), 0, Inf) + s ~ truncated(Normal(); lower=0) m = TV(undef, n) for i in eachindex(m) @@ -447,10 +447,10 @@ end end @testset "istrans" begin - @model demo_constrained() = x ~ truncated(Normal(), 0, Inf) + @model demo_constrained() = x ~ truncated(Normal(); lower=0) model = demo_constrained() vn = @varname(x) - dist = truncated(Normal(), 0, Inf) + dist = truncated(Normal(); lower=0) ### `VarInfo` # Need to run once since we can't specify that we want to _sample_ From 044f2bf15547ad5e93a48459bc2c34cc2a4f8d17 Mon Sep 17 00:00:00 2001 From: Moses Makola <71711105+mosesmakola@users.noreply.github.com> Date: Wed, 9 Jul 2025 10:20:29 +0100 Subject: [PATCH 3/5] Removed tests from abstract.jl --- test/varinfo.jl | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/test/varinfo.jl b/test/varinfo.jl index f922bc2ee..bd0ba508f 100644 --- a/test/varinfo.jl +++ b/test/varinfo.jl @@ -70,17 +70,6 @@ end # string, Symbol, ==, hash, in, keys, haskey, isempty, push!!, empty!!, # getindex, setindex!, getproperty, setproperty! - #= It's just this that needs to go I believe. Everything else is already gone - csym = gensym() - vn1 = @varname x[1][2] - @test string(vn1) == "x[1][2]" - @test Symbol(vn1) == Symbol("x[1][2]") - - vn2 = @varname x[1][2] - @test vn2 == vn1 - @test hash(vn2) == hash(vn1) - =# - function test_base(vi_original) vi = deepcopy(vi_original) @test getlogp(vi) == 0 From 30686b933ded8950dc089fcc7dc89e88a5049259 Mon Sep 17 00:00:00 2001 From: Moses Makola <71711105+mosesmakola@users.noreply.github.com> Date: Wed, 9 Jul 2025 10:24:07 +0100 Subject: [PATCH 4/5] Update test/compiler.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- test/compiler.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/compiler.jl b/test/compiler.jl index e3b15ab69..58e8c3efc 100644 --- a/test/compiler.jl +++ b/test/compiler.jl @@ -501,7 +501,7 @@ module Issue537 end @model function demo(y) α ~ Uniform() μ ~ Normal() - σ ~ truncated(Normal(), lower=0) + σ ~ truncated(Normal(); lower=0) num_steps = length(y[1]) num_obs = length(y) @inbounds for i in 1:num_obs From b5f3345feff54c406423e01307231151d6f2edfe Mon Sep 17 00:00:00 2001 From: Moses Makola <71711105+mosesmakola@users.noreply.github.com> Date: Wed, 9 Jul 2025 16:00:33 +0100 Subject: [PATCH 5/5] Update test/varinfo.jl Co-authored-by: Markus Hauru --- test/varinfo.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/varinfo.jl b/test/varinfo.jl index bd0ba508f..444a88875 100644 --- a/test/varinfo.jl +++ b/test/varinfo.jl @@ -67,7 +67,7 @@ end @testset "Base" begin # Test Base functions: - # string, Symbol, ==, hash, in, keys, haskey, isempty, push!!, empty!!, + # in, keys, haskey, isempty, push!!, empty!!, # getindex, setindex!, getproperty, setproperty! function test_base(vi_original)