Skip to content

Commit 24a1023

Browse files
committed
Apply JuliaFormatter
1 parent 3b5b8e0 commit 24a1023

File tree

7 files changed

+30
-53
lines changed

7 files changed

+30
-53
lines changed

src/combinators/bind.jl

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ function Base.rand(rng::AbstractRNG, ::Type{T}, d::Bind) where {T}
1717
return y
1818
end
1919

20-
2120
"""
2221
mbind(k, μ)::AbstractMeasure
2322

src/combinators/likelihood.jl

+1-27
Original file line numberDiff line numberDiff line change
@@ -64,31 +64,6 @@ With several parameters, things work as expected:
6464
6565
---------
6666
67-
Likelihood(M<:ParameterizedMeasure, constraint::NamedTuple, x)
68-
69-
In some cases the measure might have several parameters, and we may want the
70-
(log-)likelihood with respect to some subset of them. In this case, we can use
71-
the three-argument form, where the second argument is a constraint. For example,
72-
73-
julia> ℓ = Likelihood(Normal{(:μ,:σ)}, (σ=3.0,), 2.0)
74-
Likelihood(Normal{(:μ, :σ), T} where T, (σ = 3.0,), 2.0)
75-
76-
Similarly to the above, we have
77-
78-
julia> density_def(ℓ, (μ=2.0,))
79-
0.3333333333333333
80-
81-
julia> logdensity_def(ℓ, (μ=2.0,))
82-
-1.0986122886681098
83-
84-
julia> density_def(ℓ, 2.0)
85-
0.3333333333333333
86-
87-
julia> logdensity_def(ℓ, 2.0)
88-
-1.0986122886681098
89-
90-
-----------------------
91-
9267
Finally, let's return to the expression for Bayes's Law,
9368
9469
``P(θ|x) ∝ P(x|θ) P(θ)``
@@ -118,7 +93,7 @@ struct Likelihood{K,X} <: AbstractLikelihood
11893
x::X
11994

12095
Likelihood(k::K, x::X) where {K,X} = new{K,X}(k, x)
121-
#!!!!!!!!!!! # For type stability if `K isa UnionAll (e.g. a parameterized MeasureType)`
96+
#!!!!!!!!!!! # For type stability if `K isa UnionAll (e.g. a parameterized MeasureType)`
12297
Likelihood(::Type{K}, x::X) where {K<:AbstractMeasure,X} = new{K,X}(K, x)
12398
end
12499

@@ -191,7 +166,6 @@ function likelihoodof end
191166

192167
likelihoodof(k, x) = Likelihood(k, x)
193168

194-
195169
###############################################################################
196170
# At the least, we need to think through in some more detail whether
197171
# (log-)likelihood ratios expressed in this way are correct and useful. For now

src/combinators/product.jl

-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ function testvalue(::Type{T}, d::AbstractProductMeasure) where {T}
167167
_map(m -> testvalue(T, m), marginals(d))
168168
end
169169

170-
171170
###############################################################################
172171
# I <: Base.Generator
173172

src/density.jl

+18-8
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ Base.:∘(::typeof(log), d::Density) = logdensity_rel(d.μ, d.base)
3131

3232
Base.log(d::Density) = log d
3333

34-
3534
density_rel(μ, base) = Density(μ, base)
3635

3736
(f::Density)(x) = density_rel(f.μ, f.base, x)
@@ -112,8 +111,6 @@ logdensity_def(μ::DensityMeasure, x) = logdensityof(μ.f, x)
112111

113112
density_def::DensityMeasure, x) = densityof.f, x)
114113

115-
116-
117114
@doc raw"""
118115
mintegrate(f, μ::AbstractMeasure)::AbstractMeasure
119116
@@ -135,11 +132,14 @@ mintegrate(f, μ::AbstractMeasure) = _mintegrate_impl(f, μ, DensityKind(f))
135132

136133
_mintegrate_impl(f, μ, ::IsDensity) = DensityMeasure(f, μ)
137134
function _mintegrate_impl(f, μ, ::HasDensity)
138-
throw(ArgumentError( "`mintegrate(f, mu)` requires `DensityKind(f)` to be `IsDensity()` or `NoDensity()`."))
135+
throw(
136+
ArgumentError(
137+
"`mintegrate(f, mu)` requires `DensityKind(f)` to be `IsDensity()` or `NoDensity()`.",
138+
),
139+
)
139140
end
140141
_mintegrate_impl(f, μ, ::NoDensity) = DensityMeasure(funcdensity(f), μ)
141142

142-
143143
@doc raw"""
144144
mintegrate_exp(log_f, μ::AbstractMeasure)
145145
@@ -162,12 +162,22 @@ internally.
162162
function mintegrate_exp end
163163
export mintegrate_exp
164164

165-
mintegrate_exp(log_f, μ::AbstractMeasure) = _mintegrate_exp_impl(log_f, μ, DensityKind(log_f))
165+
function mintegrate_exp(log_f, μ::AbstractMeasure)
166+
_mintegrate_exp_impl(log_f, μ, DensityKind(log_f))
167+
end
166168

167169
function _mintegrate_exp_impl(log_f, μ, ::IsDensity)
168-
throw(ArgumentError("`mintegrate_exp(log_f, μ)` is not valid when `DensityKind(log_f) == IsDensity()`. Use `mintegral(log_f, μ)` instead."))
170+
throw(
171+
ArgumentError(
172+
"`mintegrate_exp(log_f, μ)` is not valid when `DensityKind(log_f) == IsDensity()`. Use `mintegral(log_f, μ)` instead.",
173+
),
174+
)
169175
end
170176
function _mintegrate_exp_impl(log_f, μ, ::HasDensity)
171-
throw(ArgumentError("`mintegrate_exp(log_f, μ)` is not valid when `DensityKind(log_f) == HasDensity()`."))
177+
throw(
178+
ArgumentError(
179+
"`mintegrate_exp(log_f, μ)` is not valid when `DensityKind(log_f) == HasDensity()`.",
180+
),
181+
)
172182
end
173183
_mintegrate_exp_impl(log_f, μ, ::NoDensity) = DensityMeasure(logfuncdensity(log_f), μ)

src/measure_operators.jl

+1-11
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ using MeasureBase: mintegrate, mintegrate_exp, density_rel, logdensity_rel
1515
using InverseFunctions: inverse
1616
using Reexport: @reexport
1717

18-
1918
@doc raw"""
2019
⋄(f, μ::AbstractMeasure) = pushfwd(f, μ)
2120
@@ -33,7 +32,6 @@ Also see [`ν ⊙ f`](@ref), the pullback operator.
3332
(f, μ::AbstractMeasure) = pushfwd(f, μ)
3433
export
3534

36-
3735
@doc raw"""
3836
⊙(ν::AbstractMeasure, f) = pullbck(f, ν)
3937
@@ -55,7 +53,6 @@ Also see [f ⋄ μ](@ref), the pushforward operator.
5553
::AbstractMeasure, f) = pullbck(f, ν)
5654
export
5755

58-
5956
"""
6057
μ ▷ k = mbind(k, μ)
6158
@@ -71,10 +68,9 @@ passing functions as the first argument. `▷`, on the other hand, takes
7168
its arguments in the order common for monadic binds in functional
7269
programming (like the Haskell `>>=` operator) and mathematics.
7370
"""
74-
::AbstractMeasure,k) = mbind(k, μ)
71+
::AbstractMeasure, k) = mbind(k, μ)
7572
export
7673

77-
7874
# ToDo: Use `⨂` instead of `⊗` for better readability?
7975
"""
8076
⊗(μs::AbstractMeasure...) = productmeasure(μs)
@@ -86,7 +82,6 @@ See [`productmeasure(μs)`](@ref) for details.
8682
(μs::AbstractMeasure...) = productmeasure(μs)
8783
export
8884

89-
9085
"""
9186
∫(f, μ::AbstractMeasure) = mintegrate(f, μ)
9287
@@ -98,7 +93,6 @@ See [`mintegrate(f, μ)`](@ref) for details.
9893
(f, μ::AbstractMeasure) = mintegrate(f, μ)
9994
export
10095

101-
10296
"""
10397
∫exp(f, μ::AbstractMeasure) = mintegrate_exp(f, μ)
10498
@@ -110,7 +104,6 @@ See [`mintegrate_exp(f, μ)`](@ref) for details.
110104
∫exp(f, μ::AbstractMeasure) = mintegrate_exp(f, μ)
111105
export ∫exp
112106

113-
114107
"""
115108
𝒹(ν, μ) = density_rel(ν, μ)
116109
@@ -123,8 +116,6 @@ For details, see [`density_rel(ν, μ)`}(@ref).
123116
𝒹(ν, μ::AbstractMeasure) = density_rel(ν, μ)
124117
export 𝒹
125118

126-
127-
128119
"""
129120
log𝒹(ν, μ) = logdensity_rel(ν, μ)
130121
@@ -137,5 +128,4 @@ For details, see [`logdensity_rel(ν, μ)`}(@ref).
137128
log𝒹(ν, μ::AbstractMeasure) = logdensity_rel(ν, μ)
138129
export log𝒹
139130

140-
141131
end # module MeasureOperators

src/static.jl

+3-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ Returns the length of `x` as a dynamic or static integer.
4949
"""
5050
maybestatic_length(x) = length(x)
5151
maybestatic_length(x::AbstractUnitRange) = length(x)
52-
function maybestatic_length(::Static.OptionallyStaticUnitRange{<:StaticInteger{A},<:StaticInteger{B}}) where {A,B}
52+
function maybestatic_length(
53+
::Static.OptionallyStaticUnitRange{<:StaticInteger{A},<:StaticInteger{B}},
54+
) where {A,B}
5355
StaticInt{B - A + 1}()
5456
end
5557

test/static.jl

+7-4
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,21 @@ import FillArrays
1111
@test static(2) isa MeasureBase.IntegerLike
1212
@test true isa MeasureBase.IntegerLike
1313
@test static(true) isa MeasureBase.IntegerLike
14-
14+
1515
@test @inferred(MeasureBase.one_to(7)) isa Base.OneTo
1616
@test @inferred(MeasureBase.one_to(7)) == 1:7
1717
@test @inferred(MeasureBase.one_to(static(7))) isa Static.SOneTo
1818
@test @inferred(MeasureBase.one_to(static(7))) == static(1):static(7)
1919

2020
@test @inferred(MeasureBase.fill_with(4.2, (7,))) == FillArrays.Fill(4.2, 7)
2121
@test @inferred(MeasureBase.fill_with(4.2, (static(7),))) == FillArrays.Fill(4.2, 7)
22-
@test @inferred(MeasureBase.fill_with(4.2, (3, static(7)))) == FillArrays.Fill(4.2, 3, 7)
22+
@test @inferred(MeasureBase.fill_with(4.2, (3, static(7)))) ==
23+
FillArrays.Fill(4.2, 3, 7)
2324
@test @inferred(MeasureBase.fill_with(4.2, (3:7,))) == FillArrays.Fill(4.2, (3:7,))
24-
@test @inferred(MeasureBase.fill_with(4.2, (static(3):static(7),))) == FillArrays.Fill(4.2, (3:7,))
25-
@test @inferred(MeasureBase.fill_with(4.2, (3:7, static(2):static(5)))) == FillArrays.Fill(4.2, (3:7, 2:5))
25+
@test @inferred(MeasureBase.fill_with(4.2, (static(3):static(7),))) ==
26+
FillArrays.Fill(4.2, (3:7,))
27+
@test @inferred(MeasureBase.fill_with(4.2, (3:7, static(2):static(5)))) ==
28+
FillArrays.Fill(4.2, (3:7, 2:5))
2629

2730
@test MeasureBase.maybestatic_length(MeasureBase.one_to(7)) isa Int
2831
@test MeasureBase.maybestatic_length(MeasureBase.one_to(7)) == 7

0 commit comments

Comments
 (0)