Skip to content

Commit

Permalink
try stablerng(1)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tortar authored Jan 1, 2024
1 parent 1e9c9ec commit 2a4683c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions test/sampling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,16 @@ test_rng_use(direct_sample!, 1:10, zeros(Int, 6))
a = sample(3:12, n)
check_sample_wrep(a, (3, 12), 5.0e-3; ordered=false)

rng = StableRNG(1)
for rev in (true, false), T in (Int, Int16, Float64, Float16, BigInt, ComplexF64, Rational{Int})
r = rev ? reverse(3:12) : (3:12)
r = T===Int ? r : T.(r)
aa = Int.(sample(r, n; ordered=true))
aa = Int.(sample(rng, r, n; ordered=true))
check_sample_wrep(aa, (3, 12), 5.0e-3; ordered=true, rev=rev)

aa = Int[]
for i in 1:Int(n/10)
bb = Int.(sample(r, 10; ordered=true))
bb = Int.(sample(rng, r, 10; ordered=true))
append!(aa, bb)
end
check_sample_wrep(sort!(aa, rev=rev), (3, 12), 5.0e-3; ordered=true, rev=rev)
Expand Down

0 comments on commit 2a4683c

Please sign in to comment.