Skip to content

Commit

Permalink
added tests for merge with different distributions
Browse files Browse the repository at this point in the history
  • Loading branch information
torfjelde committed Nov 16, 2023
1 parent 76611d2 commit 2cc6a61
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/varinfo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,30 @@ DynamicPPL.getspace(::DynamicPPL.Sampler{MySAlg}) = (:s,)
end
end
end

@testset "different models" begin
@model function demo_merge_different_y()
x ~ Uniform()
y ~ Normal()
end
@model function demo_merge_different_z()
x ~ Normal()
z ~ Normal()
end
model_left = demo_merge_different_y()
model_right = demo_merge_different_z()

varinfo_left = VarInfo(model_left)
varinfo_right = VarInfo(model_right)

varinfo_merged = merge(varinfo_left, varinfo_right)
vns = [@varname(x), @varname(y), @varname(z)]
check_varinfo_keys(varinfo_merged, vns)

# Right has precedence.
@test varinfo_merged[@varname(x)] == varinfo_right[@varname(x)]
@test DynamicPPL.getdist(varinfo_merged, @varname(x)) isa Normal
end
end

@testset "VarInfo with selectors" begin
Expand Down

0 comments on commit 2cc6a61

Please sign in to comment.