Skip to content

Commit 084f5af

Browse files
authored
Fix stack overflow in make_chain_from_prior (#1020)
1 parent b1241b1 commit 084f5af

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

test/test_util.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,13 @@ function make_chain_from_prior(rng::Random.AbstractRNG, model::Model, n_iters::I
7474
vals = DynamicPPL.values_as(t, OrderedDict)
7575
iters = map(DynamicPPL.varname_and_value_leaves, keys(vals), values(vals))
7676
tuples = mapreduce(collect, vcat, iters)
77-
push!(varnames, map(first, tuples)...)
77+
# The following loop is a replacement for:
78+
# push!(varnames, map(first, tuples)...)
79+
# which causes a stack overflow if `map(first, tuples)` is too large.
80+
# Unfortunately there isn't a union() function for OrderedSet.
81+
for vn in map(first, tuples)
82+
push!(varnames, vn)
83+
end
7884
OrderedDict(tuples)
7985
end
8086
# Convert back to list

0 commit comments

Comments
 (0)