Skip to content

Commit 9cf72a0

Browse files
committed
added testing for `getranges
1 parent 23d561f commit 9cf72a0

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/varinfo.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,4 +813,21 @@ DynamicPPL.getspace(::DynamicPPL.Sampler{MySAlg}) = (:s,)
813813
@test DynamicPPL.istrans(varinfo2, vn)
814814
end
815815
end
816+
817+
@testset "getranges" begin
818+
@testset "$(model.f)" for model in DynamicPPL.TestUtils.DEMO_MODELS
819+
vns = DynamicPPL.TestUtils.varnames(model)
820+
varinfo = DynamicPPL.typed_varinfo(model)
821+
x = values_as(varinfo, Vector)
822+
823+
# Let's just check all the subsets of `vns`.
824+
@testset "$(convert(Vector{Any},vns_subset))" for vns_subset in combinations(vns)
825+
ranges = DynamicPPL.getranges(varinfo, vns_subset)
826+
@test length(ranges) == length(vns_subset)
827+
for (r, vn) in zip(ranges, vns_subset)
828+
@test x[r] == DynamicPPL.tovec(varinfo[vn])
829+
end
830+
end
831+
end
832+
end
816833
end

0 commit comments

Comments
 (0)