@@ -120,7 +120,11 @@ setleafcontext(::IsLeaf, ::IsLeaf, left, right) = right
120
120
121
121
# Contexts
122
122
"""
123
- SamplingContext(rng, sampler, context)
123
+ SamplingContext(
124
+ [rng::Random.AbstractRNG=Random.GLOBAL_RNG],
125
+ [sampler::AbstractSampler=SampleFromPrior()],
126
+ [context::AbstractContext=DefaultContext()],
127
+ )
124
128
125
129
Create a context that allows you to sample parameters with the `sampler` when running the model.
126
130
The `context` determines how the returned log density is computed when running the model.
@@ -132,10 +136,26 @@ struct SamplingContext{S<:AbstractSampler,C<:AbstractContext,R} <: AbstractConte
132
136
sampler:: S
133
137
context:: C
134
138
end
135
- SamplingContext (sampler, context) = SamplingContext (Random. GLOBAL_RNG, sampler, context)
136
- SamplingContext (context:: AbstractContext ) = SamplingContext (SampleFromPrior (), context)
137
- SamplingContext (sampler:: AbstractSampler ) = SamplingContext (sampler, DefaultContext ())
138
- SamplingContext () = SamplingContext (SampleFromPrior ())
139
+
140
+ function SamplingContext (
141
+ rng:: Random.AbstractRNG = Random. GLOBAL_RNG, sampler:: AbstractSampler = SampleFromPrior ()
142
+ )
143
+ return SamplingContext (rng, sampler, DefaultContext ())
144
+ end
145
+
146
+ function SamplingContext (
147
+ sampler:: AbstractSampler , context:: AbstractContext = DefaultContext ()
148
+ )
149
+ return SamplingContext (Random. GLOBAL_RNG, sampler, context)
150
+ end
151
+
152
+ function SamplingContext (rng:: Random.AbstractRNG , context:: AbstractContext )
153
+ return SamplingContext (rng, SampleFromPrior (), context)
154
+ end
155
+
156
+ function SamplingContext (context:: AbstractContext )
157
+ return SamplingContext (Random. GLOBAL_RNG, SampleFromPrior (), context)
158
+ end
139
159
140
160
NodeTrait (context:: SamplingContext ) = IsParent ()
141
161
childcontext (context:: SamplingContext ) = context. context
0 commit comments