Skip to content

Commit

Permalink
initial_values: rename theta to flattened_param_vals (#673)
Browse files Browse the repository at this point in the history
* theta -> flattened_param_vals

* add unittest

* Update test/sampler.jl

---------

Co-authored-by: Tor Erlend Fjelde <[email protected]>
  • Loading branch information
vandenman and torfjelde authored Sep 26, 2024
1 parent 0e40bd0 commit 96a3150
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/sampler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)))",
),
)

Expand Down
3 changes: 3 additions & 0 deletions test/sampler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 96a3150

Please sign in to comment.