From e4aa5cf4a0a8b4e5c4136c5d213ae2e482da0457 Mon Sep 17 00:00:00 2001 From: Chad Scherrer Date: Sun, 14 Aug 2022 15:07:00 -0700 Subject: [PATCH] Product of Diracs (#223) * Product of Diracs * bump version --- Project.toml | 2 +- src/combinators/product.jl | 4 ++++ test/runtests.jl | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 4ded9bae..4925586d 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "MeasureTheory" uuid = "eadaa1a4-d27c-401d-8699-e962e1bbc33b" authors = ["Chad Scherrer and contributors"] -version = "0.17.0" +version = "0.17.1" [deps] Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697" diff --git a/src/combinators/product.jl b/src/combinators/product.jl index 68563361..f0c03e0b 100644 --- a/src/combinators/product.jl +++ b/src/combinators/product.jl @@ -2,6 +2,10 @@ function as(d::PowerMeasure) as(Array, as(d.parent), length.(d.axes)...) end +function as(d::ProductMeasure{<:AbstractArray{<:Dirac}}) + return asConst(testvalue.(marginals(d))) +end + function as(d::ProductMeasure{A}) where {A<:AbstractArray} mar = marginals(d) ts = map(as, mar) diff --git a/test/runtests.jl b/test/runtests.jl index b6ad72b7..aaea8646 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -275,6 +275,12 @@ end end end +@testset "Product of Diracs" begin + x = randn(3) + t = as(productmeasure(Dirac.(x))) + @test transform(t, []) == x +end + # @testset "Univariate chain" begin # ΞΎ0 = 1. # x = 1.2