Skip to content

Commit ba4182c

Browse files
committed
apply Will's suggestions
1 parent cb6ecb7 commit ba4182c

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/sampler.jl

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -157,17 +157,21 @@ By default, it returns an instance of [`SampleFromPrior`](@ref).
157157
initialsampler(spl::Sampler) = SampleFromPrior()
158158

159159
function set_values!!(
160-
varinfo::AbstractVarInfo, initial_params::AbstractVector{T}, spl::AbstractSampler
161-
) where {T}
162-
if T === Any
163-
throw(
164-
ArgumentError(
165-
"`initial_params` must be a vector of type `Union{Real,Missing}`. " *
166-
"If `initial_params` is a vector of vectors, please flatten it first using `vcat`.",
167-
),
168-
)
169-
end
160+
varinfo::AbstractVarInfo, initial_params::AbstractVector, spl::AbstractSampler
161+
)
162+
throw(
163+
ArgumentError(
164+
"`initial_params` must be a vector of type `Union{Real,Missing}`. " *
165+
"If `initial_params` is a vector of vectors, please flatten it (e.g. using `vcat`) first.",
166+
),
167+
)
168+
end
170169

170+
function set_values!!(
171+
varinfo::AbstractVarInfo,
172+
initial_params::AbstractVector{<:Union{Real,Missing}},
173+
spl::AbstractSampler,
174+
)
171175
flattened_param_vals = varinfo[spl]
172176
length(flattened_param_vals) == length(initial_params) || throw(
173177
DimensionMismatch(
@@ -199,7 +203,8 @@ function set_values!!(
199203
if subsumes(vn, vv)
200204
throw(
201205
ArgumentError(
202-
"Variable $v not found in model, but it subsumes a variable ($vv) in the model. " *
206+
"The current model does not contain variable $v, but there's ($vv) in the model. " *
207+
"Using NamedTuple for initial_params is not supported for this model. " *
203208
"Please use AbstractVector for initial_params instead of NamedTuple.",
204209
),
205210
)

0 commit comments

Comments
 (0)