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 1
1
# DynamicPPL Changelog
2
2
3
+ ## 0.36.9
4
+
5
+ Fixed a failure when sampling from ` ProductNamedTupleDistribution ` due to
6
+ missing ` tovec ` methods for ` NamedTuple ` and ` Tuple ` .
7
+
3
8
## 0.36.8
4
9
5
10
Made ` LogDensityFunction ` a subtype of ` AbstractMCMC.AbstractModel ` .
Original file line number Diff line number Diff line change 1
1
name = " DynamicPPL"
2
2
uuid = " 366bfd00-2699-11ea-058f-f148b4cae6d8"
3
- version = " 0.36.8 "
3
+ version = " 0.36.9 "
4
4
5
5
[deps ]
6
6
ADTypes = " 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))
443
443
# or fix `tovec` to flatten the full matrix instead of using `Bijectors.triu_to_vec`.
444
444
tovec (x:: Real ) = [x]
445
445
tovec (x:: AbstractArray ) = vec (x)
446
+ tovec (t:: Tuple ) = mapreduce (tovec, vcat, t)
447
+ tovec (nt:: NamedTuple ) = mapreduce (tovec, vcat, values (nt))
446
448
tovec (C:: Cholesky ) = tovec (Matrix (C. UL))
447
449
448
450
"""
Original file line number Diff line number Diff line change @@ -617,4 +617,15 @@ const GDEMO_DEFAULT = DynamicPPL.TestUtils.demo_assume_observe_literal()
617
617
]) ≈ 1.0 * xs_test[2 ] rtol = 0.1
618
618
end
619
619
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
620
631
end
Original file line number Diff line number Diff line change 47
47
dist = LKJCholesky (2 , 1 )
48
48
x = rand (dist)
49
49
@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 ]
50
53
end
51
54
52
55
@testset " unique_syms" begin
You can’t perform that action at this time.
0 commit comments