Skip to content

Commit

Permalink
Update make_model_deterministic.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
Tortar authored Dec 23, 2024
1 parent 46c71df commit be55c2e
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions test/deterministic/make_model_deterministic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,18 @@ import Random: shuffle!, rand, randn
import StatsBase: wsample
using Distributions

function allinds(s::DynamicSampler)
return sort!(reduce(vcat, s.level_buckets))
function allinds(sp::DynamicSampler)
inds = collect(Iterators.Flatten((Iterators.map(x -> x[1], b) for b in sp.level_buckets)))
return sort!(inds)
end

function randn()
return 0.0
end

function rand(s::DynamicSampler)
idx = minimum(minimum.(s.level_buckets; init=typemax(Int)))
weight = s.weights[idx]
level = ceil(Int, log2(weight)) - s.info.level_min + 1
idx_in_level = findfirst(x -> x == idx, s.level_buckets[level])
return idx
function rand(sp::DynamicSampler)
inds = collect(Iterators.Flatten((Iterators.map(x -> x[1], b) for b in sp.level_buckets)))
return minimum(inds)
end
function rand(n::UnitRange)
return 1
Expand Down

0 comments on commit be55c2e

Please # to comment.