|
138 | 138 | end |
139 | 139 | end |
140 | 140 |
|
| 141 | + # check that Vector no longer works |
| 142 | + @test_throws ArgumentError sample( |
| 143 | + model, sampler, 1; initial_params=[4, -1], progress=false |
| 144 | + ) |
| 145 | + @test_throws ArgumentError sample( |
| 146 | + model, sampler, 1; initial_params=[missing, -1], progress=false |
| 147 | + ) |
| 148 | + |
141 | 149 | # model with two variables: initialization s = 4, m = -1 |
142 | 150 | @model function twovars() |
143 | 151 | s ~ InverseGamma(2, 3) |
144 | 152 | return m ~ Normal(0, sqrt(s)) |
145 | 153 | end |
146 | 154 | model = twovars() |
147 | 155 | lptrue = logpdf(InverseGamma(2, 3), 4) + logpdf(Normal(0, 2), -1) |
148 | | - let inits = InitFromParams((; s=4, m=-1)) |
| 156 | + for inits in ( |
| 157 | + InitFromParams((s=4, m=-1)), |
| 158 | + (s=4, m=-1), |
| 159 | + InitFromParams(Dict(@varname(s) => 4, @varname(m) => -1)), |
| 160 | + Dict(@varname(s) => 4, @varname(m) => -1), |
| 161 | + ) |
149 | 162 | chain = sample(model, sampler, 1; initial_params=inits, progress=false) |
150 | 163 | @test chain[1].metadata.s.vals == [4] |
151 | 164 | @test chain[1].metadata.m.vals == [-1] |
|
169 | 182 | end |
170 | 183 |
|
171 | 184 | # set only m = -1 |
172 | | - for inits in (InitFromParams((; s=missing, m=-1)), InitFromParams((; m=-1))) |
| 185 | + for inits in ( |
| 186 | + InitFromParams((; s=missing, m=-1)), |
| 187 | + InitFromParams(Dict(@varname(s) => missing, @varname(m) => -1)), |
| 188 | + (; s=missing, m=-1), |
| 189 | + Dict(@varname(s) => missing, @varname(m) => -1), |
| 190 | + InitFromParams((; m=-1)), |
| 191 | + InitFromParams(Dict(@varname(m) => -1)), |
| 192 | + (; m=-1), |
| 193 | + Dict(@varname(m) => -1), |
| 194 | + ) |
173 | 195 | chain = sample(model, sampler, 1; initial_params=inits, progress=false) |
174 | 196 | @test !ismissing(chain[1].metadata.s.vals[1]) |
175 | 197 | @test chain[1].metadata.m.vals == [-1] |
|
0 commit comments