File tree Expand file tree Collapse file tree 5 files changed +22
-1
lines changed Expand file tree Collapse file tree 5 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 11# DynamicPPL Changelog
22
3+ ## 0.36.9
4+
5+ Fixed a failure when sampling from ` ProductNamedTupleDistribution ` due to
6+ missing ` tovec ` methods for ` NamedTuple ` and ` Tuple ` .
7+
38## 0.36.8
49
510Made ` LogDensityFunction ` a subtype of ` AbstractMCMC.AbstractModel ` .
Original file line number Diff line number Diff line change 11name = " DynamicPPL"
22uuid = " 366bfd00-2699-11ea-058f-f148b4cae6d8"
3- version = " 0.36.8 "
3+ version = " 0.36.9 "
44
55[deps ]
66ADTypes = " 47edcb42-4c32-4615-8424-f2b9edc5f35b"
Original file line number Diff line number Diff line change @@ -443,6 +443,8 @@ to_linked_vec_transform(x) = inverse(from_linked_vec_transform(x))
443443# or fix `tovec` to flatten the full matrix instead of using `Bijectors.triu_to_vec`.
444444tovec (x:: Real ) = [x]
445445tovec (x:: AbstractArray ) = vec (x)
446+ tovec (t:: Tuple ) = mapreduce (tovec, vcat, t)
447+ tovec (nt:: NamedTuple ) = mapreduce (tovec, vcat, values (nt))
446448tovec (C:: Cholesky ) = tovec (Matrix (C. UL))
447449
448450"""
Original file line number Diff line number Diff line change @@ -617,4 +617,15 @@ const GDEMO_DEFAULT = DynamicPPL.TestUtils.demo_assume_observe_literal()
617617 ]) ≈ 1.0 * xs_test[2 ] rtol = 0.1
618618 end
619619 end
620+
621+ @testset " ProductNamedTupleDistribution sampling" begin
622+ priors = (a = Normal (), b = Normal ())
623+ d = product_distribution (priors)
624+ @model function sample_nt (priors_dist)
625+ x ~ priors_dist
626+ return x
627+ end
628+ model = sample_nt (d)
629+ @test model () isa NamedTuple
630+ end
620631end
Original file line number Diff line number Diff line change 4747 dist = LKJCholesky (2 , 1 )
4848 x = rand (dist)
4949 @test DynamicPPL. tovec (x) == vec (x. UL)
50+
51+ nt = (a = [1 , 2 ], b = 3.0 )
52+ @test DynamicPPL. tovec (nt) == [1 , 2 , 3.0 ]
5053 end
5154
5255 @testset " unique_syms" begin
You can’t perform that action at this time.
0 commit comments