Skip to content
This repository was archived by the owner on Jan 18, 2025. It is now read-only.

Commit acc653c

Browse files
RNG: rename get_local_rng => default_rng (JuliaLang/julia#32641)
1 parent ddcbd70 commit acc653c

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/Test.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export TestSetException
2727
import Distributed: myid
2828

2929
using Random
30-
using Random: AbstractRNG, get_local_rng
30+
using Random: AbstractRNG, default_rng
3131
using InteractiveUtils: gen_call_with_extracted_types
3232
using Core.Compiler: typesubtract
3333

@@ -1106,7 +1106,7 @@ function testset_beginend(args, tests, source)
11061106
# we reproduce the logic of guardseed, but this function
11071107
# cannot be used as it changes slightly the semantic of @testset,
11081108
# by wrapping the body in a function
1109-
local RNG = get_local_rng()
1109+
local RNG = default_rng()
11101110
oldrng = copy(RNG)
11111111
try
11121112
# RNG is re-seeded with its own seed to ease reproduce a failed test
@@ -1196,7 +1196,7 @@ function testset_forloop(args, testloop, source)
11961196
arr = Vector{Any}()
11971197
local first_iteration = true
11981198
local ts
1199-
local RNG = get_local_rng()
1199+
local RNG = default_rng()
12001200
local oldrng = copy(RNG)
12011201
Random.seed!(RNG.seed)
12021202
local tmprng = copy(RNG)
@@ -1650,7 +1650,7 @@ Base.similar(A::GenericArray, s::Integer...) = GenericArray(similar(A.a, s...))
16501650

16511651
"`guardseed(f)` runs the function `f()` and then restores the
16521652
state of the global RNG as it was before."
1653-
function guardseed(f::Function, r::AbstractRNG=get_local_rng())
1653+
function guardseed(f::Function, r::AbstractRNG=default_rng())
16541654
old = copy(r)
16551655
try
16561656
f()

test/runtests.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ end
672672

673673
@testset "test guarded Random.seed!" begin
674674
seed = rand(UInt)
675-
orig = copy(Random.get_local_rng())
675+
orig = copy(Random.default_rng())
676676
@test guardseed(()->rand(), seed) == guardseed(()->rand(), seed)
677677
@test guardseed(()->rand(Int), seed) == guardseed(()->rand(Int), seed)
678678
r1, r2 = MersenneTwister(0), MersenneTwister(0)
@@ -686,7 +686,7 @@ end
686686
end::Tuple{Float64,Int}
687687
@test a == c == rand(r1) == rand(r2)
688688
@test b == d == rand(r1, Int) == rand(r2, Int)
689-
@test orig == Random.get_local_rng()
689+
@test orig == Random.default_rng()
690690
@test rand(orig) == rand()
691691
end
692692

0 commit comments

Comments
 (0)