Skip to content

Commit

Permalink
add missing method for rand(::_GLOBAL_RNG) (#41123)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jun 9, 2021
1 parent 91598c4 commit 482d0ac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions stdlib/Random/src/RNGs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ rand(::_GLOBAL_RNG, sp::SamplerBoolBitInteger) = rand(default_rng(), sp)
for T in (:(SamplerTrivial{UInt52Raw{UInt64}}),
:(SamplerTrivial{UInt2x52Raw{UInt128}}),
:(SamplerTrivial{UInt104Raw{UInt128}}),
:(SamplerTrivial{CloseOpen01_64}),
:(SamplerTrivial{CloseOpen12_64}),
:(SamplerUnion(Int64, UInt64, Int128, UInt128)),
:(SamplerUnion(Bool, Int8, UInt8, Int16, UInt16, Int32, UInt32)),
Expand Down
7 changes: 7 additions & 0 deletions stdlib/Random/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,13 @@ end
# issue #33170
@test Sampler(GLOBAL_RNG, 2:4, Val(1)) isa SamplerRangeNDL
@test Sampler(GLOBAL_RNG, 2:4, Val(Inf)) isa SamplerRangeNDL

rng = copy(GLOBAL_RNG)
# make sure _GLOBAL_RNG and the underlying implementation use the same code path
@test rand(rng) == rand(GLOBAL_RNG)
@test rand(rng) == rand(GLOBAL_RNG)
@test rand(rng) == rand(GLOBAL_RNG)
@test rand(rng) == rand(GLOBAL_RNG)
end

@testset "RNGs broadcast as scalars: T" for T in (MersenneTwister, RandomDevice)
Expand Down

0 comments on commit 482d0ac

Please sign in to comment.