Skip to content

Commit fc2df33

Browse files
committed
Add rng keyword argument
1 parent c19e4db commit fc2df33

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/test_utils/ad.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import DifferentiationInterface as DI
66
using DocStringExtensions
77
using DynamicPPL: Model, LogDensityFunction, VarInfo, AbstractVarInfo, link
88
using LogDensityProblems: logdensity, logdensity_and_gradient
9-
using Random: Random, Xoshiro
9+
using Random: AbstractRNG, default_rng
1010
using Statistics: median
1111
using Test: @test
1212

@@ -160,8 +160,8 @@ Everything else is optional, and can be categorised into several groups:
160160
161161
Note that if the VarInfo is not specified (and thus automatically generated)
162162
the parameters in it will have been sampled from the prior of the model. If
163-
you want to seed the parameter generation, the easiest way is to pass a
164-
`rng` argument to the VarInfo constructor (i.e. do `VarInfo(rng, model)`).
163+
you want to seed the parameter generation for the VarInfo, you can pass the
164+
`rng` keyword argument, which will then be used to create the VarInfo.
165165
166166
Finally, note that these only reflect the parameters used for _evaluating_
167167
the gradient. If you also want to control the parameters used for
@@ -214,7 +214,8 @@ function run_ad(
214214
benchmark::Bool=false,
215215
value_atol::AbstractFloat=1e-6,
216216
grad_atol::AbstractFloat=1e-6,
217-
varinfo::AbstractVarInfo=link(VarInfo(model), model),
217+
rng::AbstractRNG=default_rng(),
218+
varinfo::AbstractVarInfo=link(VarInfo(rng, model), model),
218219
params::Union{Nothing,Vector{<:AbstractFloat}}=nothing,
219220
verbose=true,
220221
)::ADResult

0 commit comments

Comments
 (0)