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..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(), 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 7439869cf..444a88875 100644 --- a/test/varinfo.jl +++ b/test/varinfo.jl @@ -67,16 +67,8 @@ 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! - 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) @@ -179,14 +171,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) @@ -444,10 +436,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_