From 2bc717c65a0f5ba5d47a81882a2967a4e16748c3 Mon Sep 17 00:00:00 2001 From: Alexey Stukalov Date: Thu, 29 Feb 2024 14:33:55 -0800 Subject: [PATCH] Better init_theta size mismatch error (#576) * better init_theta size mismatch error * Fix formatting * Update src/sampler.jl --------- Co-authored-by: Alexey Stukalov Co-authored-by: Hong Ge <3279477+yebai@users.noreply.github.com> --- src/sampler.jl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/sampler.jl b/src/sampler.jl index 910d6c1b5..b2fc6f4ec 100644 --- a/src/sampler.jl +++ b/src/sampler.jl @@ -158,11 +158,14 @@ function initialize_parameters!!( vi = invlink!!(vi, spl, model) end theta = vi[spl] - length(theta) == length(init_theta) || - error("Provided initial value doesn't match the dimension of the model") + length(theta) == length(init_theta) || throw( + DimensionMismatch( + "Provided initial value size ($(length(init_theta))) doesn't match the model size ($(length(theta)))", + ), + ) # Update values that are provided. - for i in 1:length(init_theta) + for i in eachindex(init_theta) x = init_theta[i] if x !== missing theta[i] = x