Skip to content

Commit 2bc717c

Browse files
alystAlexey Stukalovyebai
authored
Better init_theta size mismatch error (#576)
* better init_theta size mismatch error * Fix formatting * Update src/sampler.jl --------- Co-authored-by: Alexey Stukalov <[email protected]> Co-authored-by: Hong Ge <[email protected]>
1 parent a020171 commit 2bc717c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/sampler.jl

+6-3
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,14 @@ function initialize_parameters!!(
158158
vi = invlink!!(vi, spl, model)
159159
end
160160
theta = vi[spl]
161-
length(theta) == length(init_theta) ||
162-
error("Provided initial value doesn't match the dimension of the model")
161+
length(theta) == length(init_theta) || throw(
162+
DimensionMismatch(
163+
"Provided initial value size ($(length(init_theta))) doesn't match the model size ($(length(theta)))",
164+
),
165+
)
163166

164167
# Update values that are provided.
165-
for i in 1:length(init_theta)
168+
for i in eachindex(init_theta)
166169
x = init_theta[i]
167170
if x !== missing
168171
theta[i] = x

0 commit comments

Comments
 (0)