Skip to content

Commit 73ca30a

Browse files
committed
more test updates
1 parent 98c36f3 commit 73ca30a

File tree

4 files changed

+42
-40
lines changed

4 files changed

+42
-40
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ ConcreteStructs = "2569d6c7-a4a2-43d3-a901-331e8e4be471"
88
ConstructionBase = "187b0558-2788-49d3-abe0-74a17ed4e7c9"
99
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
1010
KeywordCalls = "4d827475-d3e4-43d6-abe3-9688362ede9f"
11+
LogExpFunctions = "2ab3a3ac-af41-5b50-aa03-7779005ae688"
1112
MLStyle = "d8e11817-5142-5d16-987a-aa16d5891078"
1213
MappedArrays = "dbb5928d-eab1-5f90-85c2-b9b0edb7c900"
1314
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
@@ -18,6 +19,7 @@ ConcreteStructs = "0.2"
1819
ConstructionBase = "1.3"
1920
FillArrays = "0.12"
2021
KeywordCalls = "0.2"
22+
LogExpFunctions = "0.3"
2123
MLStyle = "0.4"
2224
MappedArrays = "0.4"
2325
Tricks = "0.1"

src/MeasureBase.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ sampletype(μ::AbstractMeasure) = typeof(testvalue(μ))
2020
export logdensity
2121
export basemeasure
2222

23+
using LogExpFunctions: logsumexp
24+
2325
"""
2426
logdensity(μ::AbstractMeasure{X}, x::X)
2527

src/combinators/superpose.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ struct SuperpositionMeasure{NT} <: AbstractMeasure
1818
components :: NT
1919
end
2020

21+
testvalue::SuperpositionMeasure) = testvalue(first.components))
22+
2123
# SuperpositionMeasure(ms :: AbstractMeasure...) = SuperpositionMeasure{X,length(ms)}(ms)
2224

2325
# SuperpositionMeasure(m::NTuple{N, Measure{X}}) where {N,X} = SuperpositionMeasure(m...)

test/runtests.jl

Lines changed: 36 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -36,49 +36,45 @@ end
3636
# return (x,y)
3737
# end
3838

39-
# function test_measure(μ)
40-
# logdensity(μ, testvalue(μ)) isa AbstractFloat
41-
# end
39+
function test_testvalue(μ)
40+
logdensity(μ, testvalue(μ)) isa AbstractFloat
41+
end
4242

43-
# test_measures = [
44-
# # Chain(x -> Normal(μ=x), Normal(μ=0.0))
45-
# For(3) do j Normal(σ=j) end
46-
# For(2,3) do i,j Normal(i,j) end
47-
# Lebesgue(ℝ) ^ 3
48-
# Lebesgue(ℝ) ^ (2,3)
49-
# 3 * Lebesgue(ℝ)
50-
# Dirac(π)
51-
# Lebesgue(ℝ)
52-
# # Normal() ⊙ Cauchy()
53-
# ]
54-
55-
# testbroken_measures = [
56-
# Pushforward(as𝕀, Normal())
57-
# SpikeMixture(Normal(), 2)
58-
# # InverseGamma(2) # Not defined yet
59-
# # MvNormal(I(3)) # Entirely broken for now
60-
# CountingMeasure(Float64)
61-
# Likelihood
62-
# Dirac(0.0) + Lebesgue(ℝ)
63-
64-
# TrivialMeasure()
65-
# ]
66-
67-
# @testset "testvalue" begin
68-
# for μ in test_measures
69-
# @test test_measure(μ)
70-
# end
43+
test_measures = [
44+
# Chain(x -> Normal(μ=x), Normal(μ=0.0))
45+
For(3) do j Dirac(j) end
46+
For(2,3) do i,j Dirac(i) + Dirac(j) end
47+
Lebesgue(ℝ) ^ 3
48+
Lebesgue(ℝ) ^ (2,3)
49+
3 * Lebesgue(ℝ)
50+
Dirac(π)
51+
Lebesgue(ℝ)
52+
Dirac(0.0) + Lebesgue(ℝ)
53+
# Normal() ⊙ Cauchy()
54+
]
55+
56+
testbroken_measures = [
57+
SpikeMixture(Lebesgue(ℝ), 2)
58+
# InverseGamma(2) # Not defined yet
59+
# MvNormal(I(3)) # Entirely broken for now
60+
CountingMeasure(Float64)
61+
Likelihood
62+
63+
TrivialMeasure()
64+
]
65+
66+
@testset "testvalue" begin
67+
for μ in test_measures
68+
@info "testing "
69+
@test test_testvalue(μ)
70+
end
7171

72-
# for μ in testbroken_measures
73-
# @test_broken test_measure(μ)
74-
# end
72+
for μ in testbroken_measures
73+
@info "testing "
74+
@test_broken test_testvalue(μ)
75+
end
7576

76-
# @testset "testvalue(::Chain)" begin
77-
# mc = Chain(x -> Normal(μ=x), Normal(μ=0.0))
78-
# r = testvalue(mc)
79-
# @test logdensity(mc, Iterators.take(r, 10)) isa AbstractFloat
80-
# end
81-
# end
77+
end
8278

8379

8480
# @testset "Kernel" begin

0 commit comments

Comments
 (0)