|
15 | 15 | @test ext.DivisionOf(d1, d2) == prod(GenericProd(), missing, ext.DivisionOf(d1, d2)) |
16 | 16 | end |
17 | 17 |
|
18 | | -@testitem "Check warning when DivisionOf is not proper" begin |
19 | | - using ExponentialFamily, ExponentialFamilyProjection, BayesBase |
20 | | - ext = Base.get_extension(ReactiveMP, :ReactiveMPProjectionExt) |
21 | | - @test !isnothing(ext) |
22 | | - using .ext |
23 | | - |
24 | | - @testset "Check warning when DivisionOf is not proper" begin |
25 | | - d1 = NormalMeanVariance(0, 1) |
26 | | - d2 = NormalMeanVariance(0, 0.01) |
27 | | - d3 = NormalMeanVariance(0, 0.5) |
28 | | - @test_logs (:warn, "The product of $(d3) and $(d1) divided by $(d2) is not proper") prod(GenericProd(), ext.DivisionOf(d1, d2), d3) |
29 | | - end |
30 | | - |
31 | | - @testset "Check warning when DivisionOf is not proper" begin |
32 | | - d1 = MvNormalMeanCovariance([0.0, 0.0], [1.0 0.0; 0.0 1.0]) |
33 | | - d2 = MvNormalMeanCovariance([1.0, 1.0], [0.01 0.0; 0.0 0.01]) |
34 | | - d3 = MvNormalMeanCovariance([2.0, 2.0], [3.0 0.0; 0.0 3.0]) |
35 | | - @test_logs (:warn, "The product of $(d3) and $(d1) divided by $(d2) is not proper") prod(GenericProd(), ext.DivisionOf(d1, d2), d3) |
36 | | - end |
37 | | - |
38 | | - @testset "Check no warning when DivisionOf is proper" begin |
39 | | - d1 = NormalMeanVariance(0, 1) |
40 | | - d2 = NormalMeanVariance(0, 2) |
41 | | - d3 = NormalMeanVariance(0, 1) |
42 | | - @test_logs prod(GenericProd(), ext.DivisionOf(d1, d2), d3) |
43 | | - end |
44 | | -end |
45 | | - |
46 | | -@testitem "DivisionOf(Gaussian, Gaussian) x Gaussian" begin |
47 | | - using ExponentialFamily, ExponentialFamilyProjection, BayesBase |
48 | | - |
49 | | - # `DivisionOf` is internal to the extension |
50 | | - ext = Base.get_extension(ReactiveMP, :ReactiveMPProjectionExt) |
51 | | - @test !isnothing(ext) |
52 | | - using .ext |
53 | | - |
54 | | - d1 = NormalMeanVariance(0, 1) |
55 | | - d2 = NormalMeanVariance(1, 2) |
56 | | - d3 = NormalMeanVariance(2, 3) |
57 | | - result = NormalMeanVariance(0.2, 1.2) |
58 | | - |
59 | | - @test prod(GenericProd(), ext.DivisionOf(d1, d2), d3) ≈ prod(GenericProd(), d3, ext.DivisionOf(d1, d2)) |
60 | | - @test prod(GenericProd(), ext.DivisionOf(d1, d2), d3) ≈ result |
61 | | - |
62 | | - d1 = NormalMeanVariance(0, 1) |
63 | | - d2 = convert(NormalWeightedMeanPrecision, d2) |
64 | | - d3 = convert(NormalMeanPrecision, d3) |
65 | | - |
66 | | - @test prod(GenericProd(), ext.DivisionOf(d1, d2), d3) ≈ prod(GenericProd(), d3, ext.DivisionOf(d1, d2)) |
67 | | - @test prod(GenericProd(), ext.DivisionOf(d1, d2), d3) ≈ result |
68 | | -end |
69 | | - |
70 | | -@testitem "DivisionOf(MvGaussian, MvGaussian) x MvGaussian" begin |
71 | | - using ExponentialFamily, ExponentialFamilyProjection, BayesBase |
72 | | - |
73 | | - # `DivisionOf` is internal to the extension |
74 | | - ext = Base.get_extension(ReactiveMP, :ReactiveMPProjectionExt) |
75 | | - @test !isnothing(ext) |
76 | | - using .ext |
77 | | - |
78 | | - d1 = MvNormalMeanCovariance([0.0, 0.0], [1.0 0.0; 0.0 1.0]) |
79 | | - d2 = MvNormalMeanCovariance([1.0, 1.0], [2.0 0.0; 0.0 2.0]) |
80 | | - d3 = MvNormalMeanCovariance([2.0, 2.0], [3.0 0.0; 0.0 3.0]) |
81 | | - result = MvNormalMeanCovariance([0.2, 0.2], [1.2 0.0; 0.0 1.2]) |
82 | | - |
83 | | - @test prod(GenericProd(), ext.DivisionOf(d1, d2), d3) ≈ prod(GenericProd(), d3, ext.DivisionOf(d1, d2)) |
84 | | - @test prod(GenericProd(), ext.DivisionOf(d1, d2), d3) ≈ result |
85 | | - |
86 | | - d1 = MvNormalMeanCovariance([0.0, 0.0], [1.0 0.0; 0.0 1.0]) |
87 | | - d2 = convert(MvNormalWeightedMeanPrecision, d2) |
88 | | - d3 = convert(MvNormalMeanPrecision, d3) |
89 | | - |
90 | | - @test prod(GenericProd(), ext.DivisionOf(d1, d2), d3) ≈ prod(GenericProd(), d3, ext.DivisionOf(d1, d2)) |
91 | | - @test prod(GenericProd(), ext.DivisionOf(d1, d2), d3) ≈ result |
92 | | - |
93 | | - d1 = MvNormalMeanCovariance([0.0, 0.0], [1.0 0.0; 0.0 1.0]) |
94 | | - d2 = MvNormalMeanScalePrecision([1.0, 1.0], 1 / 2) |
95 | | - d3 = convert(MvNormalMeanPrecision, d3) |
96 | | - |
97 | | - @test prod(GenericProd(), ext.DivisionOf(d1, d2), d3) ≈ prod(GenericProd(), d3, ext.DivisionOf(d1, d2)) |
98 | | - @test prod(GenericProd(), ext.DivisionOf(d1, d2), d3) ≈ result |
99 | | -end |
100 | | - |
101 | | -@testitem "Raise error when DivisionOf of Univarive and Multivariate" begin |
102 | | - using ExponentialFamily, ExponentialFamilyProjection, BayesBase |
103 | | - |
104 | | - # `DivisionOf` is internal to the extension |
105 | | - ext = Base.get_extension(ReactiveMP, :ReactiveMPProjectionExt) |
106 | | - @test !isnothing(ext) |
107 | | - using .ext |
108 | | - |
109 | | - d1 = NormalMeanVariance(0, 1) |
110 | | - d2 = MvNormalMeanCovariance([0.0, 0.0], [1.0 0.0; 0.0 1.0]) |
111 | | - d3 = NormalMeanVariance(0, 1) |
112 | | - |
113 | | - @test_throws "DivisionOf does not support arguments of different variate forms" prod(GenericProd(), ext.DivisionOf(d1, d2), d2) |
114 | | - @test_throws "DivisionOf does not support arguments of different variate forms" prod(GenericProd(), d2, ext.DivisionOf(d1, d2)) |
115 | | -end |
116 | | - |
117 | 18 | @testitem "create_project_to_ins type stability" begin |
118 | 19 | using ExponentialFamily, ExponentialFamilyProjection, BayesBase, Test |
119 | 20 | using ReactiveMP: CVIProjection |
|
0 commit comments