Skip to content

Commit 8055b52

Browse files
authored
Testvalue (#208)
* minor reformatting * require MeasureBase 0.10 * fix OrthoLebesgue * IfElse * bump version
1 parent ee201c9 commit 8055b52

File tree

3 files changed

+28
-10
lines changed

3 files changed

+28
-10
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "MeasureTheory"
22
uuid = "eadaa1a4-d27c-401d-8699-e962e1bbc33b"
33
authors = ["Chad Scherrer <[email protected]> and contributors"]
4-
version = "0.16.2"
4+
version = "0.16.3"
55

66
[deps]
77
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
@@ -57,7 +57,7 @@ LogExpFunctions = "0.3.3"
5757
MLStyle = "0.4"
5858
MacroTools = "0.5"
5959
MappedArrays = "0.4"
60-
MeasureBase = "0.9"
60+
MeasureBase = "0.10"
6161
NamedTupleTools = "0.13, 0.14"
6262
NestedTuples = "0.3"
6363
PositiveFactorizations = "0.2"

src/combinators/affine.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,20 @@ struct OrthoLebesgue{N,T} <: PrimitiveMeasure
137137
OrthoLebesgue(nt::NamedTuple{N,T}) where {N,T} = new{N,T}(nt)
138138
end
139139

140+
params(d::OrthoLebesgue) = getfield(d, :par)
141+
142+
Base.getproperty(d::OrthoLebesgue, s::Symbol) = getproperty(params(d), s)
143+
Base.propertynames(d::OrthoLebesgue) = propertynames(params(d))
144+
145+
testvalue(d::OrthoLebesgue{(:μ, :σ)}) = d.μ
146+
testvalue(d::OrthoLebesgue{(:μ, :λ)}) = d.μ
147+
testvalue(d::OrthoLebesgue{(:μ,)}) = d.μ
148+
149+
testvalue(d::OrthoLebesgue{(:σ,)}) = zeros(size(d.σ, 1))
150+
testvalue(d::OrthoLebesgue{(:λ,)}) = zeros(size(d.λ, 2))
151+
140152
function insupport(d::OrthoLebesgue, x)
141-
f = AffineTransform(d.par)
153+
f = AffineTransform(params(d))
142154
finv = inverse(f)
143155
z = finv(x)
144156
f(z) x

test/runtests.jl

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ using FillArrays
1010
using MeasureTheory
1111
using MeasureBase.Interface
1212
using MeasureTheory: kernel
13-
1413
using Aqua
14+
using IfElse
1515
Aqua.test_all(MeasureTheory; ambiguities = false, unbound_args = false)
1616

1717
function draw2(μ)
@@ -611,10 +611,16 @@ end
611611
@testset "IfElseMeasure" begin
612612
p = rand()
613613
x = randn()
614-
@test logdensityof(MeasureTheory.IfElse.ifelse(Bernoulli(p), Normal(), Normal()), x)
615-
logdensityof(Normal(), x)
616-
@test logdensityof(
617-
MeasureTheory.IfElse.ifelse(Bernoulli(p), Normal(2, 3), Normal()),
618-
x,
619-
) logdensityof(p * Normal(2, 3) + (1 - p) * Normal(), x)
614+
615+
@test let
616+
a = logdensityof(IfElse.ifelse(Bernoulli(p), Normal(), Normal()), x)
617+
b = logdensityof(Normal(), x)
618+
a b
619+
end
620+
621+
@test let
622+
a = logdensityof(IfElse.ifelse(Bernoulli(p), Normal(2, 3), Normal()), x)
623+
b = logdensityof(p * Normal(2, 3) + (1 - p) * Normal(), x)
624+
a b
625+
end
620626
end

0 commit comments

Comments
 (0)