Skip to content

Commit 00cc0ac

Browse files
authored
Merge pull request #496 from ReactiveBayes/revert-486-dont-check-for-proper-in-division-of
Revert "Dont check for proper in division of to accomodate inference"
2 parents 83a030c + a5337c9 commit 00cc0ac

4 files changed

Lines changed: 0 additions & 160 deletions

File tree

ext/ReactiveMPProjectionExt/ReactiveMPProjectionExt.jl

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@ using ReactiveMP, ExponentialFamily, Distributions, ExponentialFamilyProjection,
55
struct DivisionOf{A, B}
66
numerator::A
77
denumerator::B
8-
function DivisionOf(numerator::A, denumerator::B) where {A, B}
9-
if variate_form(A) == variate_form(B)
10-
return new{A, B}(numerator, denumerator)
11-
else
12-
error("DivisionOf does not support arguments of different variate forms: $(variate_form(A)) and $(variate_form(B))")
13-
end
14-
end
158
end
169

1710
(divisionof::DivisionOf)(x) = logpdf(divisionof, x)
@@ -51,8 +44,6 @@ include("layout/cvi_projection.jl")
5144
include("rules/in.jl")
5245
include("rules/out.jl")
5346
include("rules/marginals.jl")
54-
include("divisionof/univariate_gaussian.jl")
55-
include("divisionof/multivariate_gaussian.jl")
5647

5748
# This will enable the extension and make `CVIProjection` compatible with delta nodes
5849
# Otherwise it should throw an error suggesting users to install `ExponentialFamilyProjection`

ext/ReactiveMPProjectionExt/divisionof/multivariate_gaussian.jl

Lines changed: 0 additions & 28 deletions
This file was deleted.

ext/ReactiveMPProjectionExt/divisionof/univariate_gaussian.jl

Lines changed: 0 additions & 24 deletions
This file was deleted.

test/ext/ReactiveMPProjectionExt/ReactiveMPProjectionExt_tests.jl

Lines changed: 0 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -15,105 +15,6 @@
1515
@test ext.DivisionOf(d1, d2) == prod(GenericProd(), missing, ext.DivisionOf(d1, d2))
1616
end
1717

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-
11718
@testitem "create_project_to_ins type stability" begin
11819
using ExponentialFamily, ExponentialFamilyProjection, BayesBase, Test
11920
using ReactiveMP: CVIProjection

0 commit comments

Comments
 (0)