diff --git a/src/sampler.jl b/src/sampler.jl index cfc58942e..833aaf7e2 100644 --- a/src/sampler.jl +++ b/src/sampler.jl @@ -150,7 +150,7 @@ function set_values!!( flattened_param_vals = varinfo[spl] length(flattened_param_vals) == length(initial_params) || throw( DimensionMismatch( - "Provided initial value size ($(length(initial_params))) doesn't match the model size ($(length(theta)))", + "Provided initial value size ($(length(initial_params))) doesn't match the model size ($(length(flattened_param_vals)))", ), ) diff --git a/test/sampler.jl b/test/sampler.jl index b29d3caf1..95e838167 100644 --- a/test/sampler.jl +++ b/test/sampler.jl @@ -162,6 +162,9 @@ chain1 = sample(model, sampler, 1; progress=false) Random.seed!(1234) chain2 = sample(model, sampler, 1; initial_params=nothing, progress=false) + @test_throws DimensionMismatch sample( + model, sampler, 1; progress=false, initial_params=zeros(10) + ) @test chain1[1].metadata.m.vals == chain2[1].metadata.m.vals @test chain1[1].metadata.s.vals == chain2[1].metadata.s.vals