Skip to content

Commit a8a06ed

Browse files
authored
Use Random.default_rng() (#1967)
1 parent b365de7 commit a8a06ed

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "Turing"
22
uuid = "fce5fe82-541a-59a6-adf8-730c64b5f9a0"
3-
version = "0.24.2"
3+
version = "0.24.3"
44

55
[deps]
66
AbstractMCMC = "80f14c24-f653-4e6a-9b94-39d6b0f70001"

docs/src/for-developers/compiler.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ A `model::Model` is a callable struct that one can sample from by calling
3030
```julia
3131
(model::Model)([rng, varinfo, sampler, context])
3232
```
33-
where `rng` is a random number generator (default: `Random.GLOBAL_RNG`), `varinfo` is a data structure that stores information
33+
where `rng` is a random number generator (default: `Random.default_rng()`), `varinfo` is a data structure that stores information
3434
about the random variables (default: `DynamicPPL.VarInfo()`), `sampler` is a sampling algorithm (default: `DynamicPPL.SampleFromPrior()`),
3535
and `context` is a sampling context that can, e.g., modify how the log probability is accumulated (default: `DynamicPPL.DefaultContext()`).
3636

docs/src/using-turing/performancetips.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ model = tmodel(1.0)
116116
model,
117117
Turing.VarInfo(model),
118118
Turing.SamplingContext(
119-
Random.GLOBAL_RNG, Turing.SampleFromPrior(), Turing.DefaultContext(),
119+
Random.default_rng(), Turing.SampleFromPrior(), Turing.DefaultContext(),
120120
),
121121
model.args...,
122122
)

src/inference/Inference.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ function AbstractMCMC.sample(
133133
N::Integer;
134134
kwargs...
135135
)
136-
return AbstractMCMC.sample(Random.GLOBAL_RNG, model, alg, N; kwargs...)
136+
return AbstractMCMC.sample(Random.default_rng(), model, alg, N; kwargs...)
137137
end
138138

139139
function AbstractMCMC.sample(
@@ -190,7 +190,7 @@ function AbstractMCMC.sample(
190190
n_chains::Integer;
191191
kwargs...
192192
)
193-
return AbstractMCMC.sample(Random.GLOBAL_RNG, model, alg, ensemble, N, n_chains;
193+
return AbstractMCMC.sample(Random.default_rng(), model, alg, ensemble, N, n_chains;
194194
kwargs...)
195195
end
196196

@@ -397,7 +397,7 @@ function save(c::MCMCChains.Chains, spl::Sampler, model, vi, samples)
397397
end
398398

399399
function resume(chain::MCMCChains.Chains, args...; kwargs...)
400-
return resume(Random.GLOBAL_RNG, chain, args...; kwargs...)
400+
return resume(Random.default_rng(), chain, args...; kwargs...)
401401
end
402402

403403
function resume(rng::Random.AbstractRNG, chain::MCMCChains.Chains, args...;
@@ -530,7 +530,7 @@ true
530530
```
531531
"""
532532
function predict(model::Model, chain::MCMCChains.Chains; kwargs...)
533-
return predict(Random.GLOBAL_RNG, model, chain; kwargs...)
533+
return predict(Random.default_rng(), model, chain; kwargs...)
534534
end
535535
function predict(rng::AbstractRNG, model::Model, chain::MCMCChains.Chains; include_all = false)
536536
# Don't need all the diagnostics
@@ -617,7 +617,7 @@ function transitions_from_chain(
617617
chain::MCMCChains.Chains;
618618
kwargs...
619619
)
620-
return transitions_from_chain(Random.GLOBAL_RNG, model, chain; kwargs...)
620+
return transitions_from_chain(Random.default_rng(), model, chain; kwargs...)
621621
end
622622

623623
function transitions_from_chain(

src/variational/advi.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ end
9191
9292
Creates a mean-field approximation with multivariate normal as underlying distribution.
9393
"""
94-
meanfield(model::DynamicPPL.Model) = meanfield(Random.GLOBAL_RNG, model)
94+
meanfield(model::DynamicPPL.Model) = meanfield(Random.default_rng(), model)
9595
function meanfield(rng::Random.AbstractRNG, model::DynamicPPL.Model)
9696
# Setup.
9797
varinfo = DynamicPPL.VarInfo(model)

test/inference/gibbs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# Test gid of each samplers
2222
g = Turing.Sampler(s3, gdemo_default)
2323

24-
_, state = AbstractMCMC.step(Random.GLOBAL_RNG, gdemo_default, g)
24+
_, state = AbstractMCMC.step(Random.default_rng(), gdemo_default, g)
2525
@test state.samplers[1].selector != g.selector
2626
@test state.samplers[2].selector != g.selector
2727
@test state.samplers[1].selector != state.samplers[2].selector

0 commit comments

Comments
 (0)