@@ -314,8 +314,6 @@ function mcmcsample(
314
314
315
315
# Ensure that initial parameters are `nothing` or of the correct length
316
316
check_initial_params (init_params, nchains)
317
- # We will use `getindex` later so we need to `collect`.
318
- _init_params = init_params != = nothing ? collect (init_params) : nothing
319
317
320
318
# Set up a chains vector.
321
319
chains = Vector {Any} (undef, nchains)
@@ -366,10 +364,10 @@ function mcmcsample(
366
364
_sampler,
367
365
N;
368
366
progress= false ,
369
- init_params= if _init_params === nothing
367
+ init_params= if init_params === nothing
370
368
nothing
371
369
else
372
- _init_params [chainidx]
370
+ init_params [chainidx]
373
371
end ,
374
372
kwargs... ,
375
373
)
@@ -540,13 +538,21 @@ end
540
538
tighten_eltype (x) = x
541
539
tighten_eltype (x:: Vector{Any} ) = map (identity, x)
542
540
543
- check_initial_params (x:: Nothing , n:: Int ) = nothing
544
- function check_initial_params (x, n:: Int )
541
+ @nospecialize check_initial_params (x, n) = throw (
542
+ ArgumentError (
543
+ " initial parameters must be specified as a vector of length equal to the number of chains or `nothing`" ,
544
+ ),
545
+ )
546
+
547
+ check_initial_params (:: Nothing , n) = nothing
548
+ function check_initial_params (x:: AbstractArray , n)
545
549
if length (x) != n
546
550
throw (
547
551
ArgumentError (
548
552
" incorrect number of initial parameters (expected $n , received $(length (x)) "
549
553
),
550
554
)
551
555
end
556
+
557
+ return nothing
552
558
end
0 commit comments