Skip to content

Commit 89cf6fd

Browse files
authored
formatting (#196)
1 parent ab96459 commit 89cf6fd

26 files changed

+328
-252
lines changed

docs/make.jl

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using Documenter
22
using MeasureTheory
33

4-
DocMeta.setdocmeta!(MeasureBase, :DocTestSetup, :(using MeasureBase); recursive=true)
5-
DocMeta.setdocmeta!(MeasureTheory, :DocTestSetup, :(using MeasureTheory); recursive=true)
4+
DocMeta.setdocmeta!(MeasureBase, :DocTestSetup, :(using MeasureBase); recursive = true)
5+
DocMeta.setdocmeta!(MeasureTheory, :DocTestSetup, :(using MeasureTheory); recursive = true)
66

77
pages = [
88
"Home" => "index.md",
@@ -18,18 +18,16 @@ pages = [
1818
]
1919

2020
makedocs(;
21-
modules=[MeasureBase, MeasureTheory],
22-
authors="Chad Scherrer <[email protected]> and contributors",
23-
repo="https://github.com/cscherrer/MeasureTheory.jl/blob/{commit}{path}#L{line}",
24-
sitename="MeasureTheory.jl",
25-
format=Documenter.HTML(;
26-
prettyurls=get(ENV, "CI", "false") == "true",
27-
canonical="https://cscherrer.github.io/MeasureTheory.jl",
28-
assets=String[],
21+
modules = [MeasureBase, MeasureTheory],
22+
authors = "Chad Scherrer <[email protected]> and contributors",
23+
repo = "https://github.com/cscherrer/MeasureTheory.jl/blob/{commit}{path}#L{line}",
24+
sitename = "MeasureTheory.jl",
25+
format = Documenter.HTML(;
26+
prettyurls = get(ENV, "CI", "false") == "true",
27+
canonical = "https://cscherrer.github.io/MeasureTheory.jl",
28+
assets = String[],
2929
),
30-
pages=pages
30+
pages = pages,
3131
)
3232

33-
deploydocs(;
34-
repo="github.com/cscherrer/MeasureTheory.jl",
35-
)
33+
deploydocs(; repo = "github.com/cscherrer/MeasureTheory.jl")

scratch/orderstats.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ struct OrderStatistic{n,r,B} <: AbstractMeasure
33
end
44

55
@inline function basemeasure(d::OrderStatistic{n,r})
6-
WeightedMeasure(logbeta(n+1, r+1), d.base)
6+
WeightedMeasure(logbeta(n + 1, r + 1), d.base)
77
end
88

99
@inline function logdensity_def(d::OrderStatistic{n,r}, x)

src/MeasureTheory.jl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,16 @@ export ifelse
4949

5050
import MeasureBase: insupport, instance, marginals
5151
import MeasureBase:
52-
testvalue, logdensity_def, density_def, basemeasure, kleisli, params, paramnames, ∫, 𝒹, ∫exp
52+
testvalue,
53+
logdensity_def,
54+
density_def,
55+
basemeasure,
56+
kleisli,
57+
params,
58+
paramnames,
59+
∫,
60+
𝒹,
61+
∫exp
5362
import MeasureBase:
5463
using MeasureBase: BoundedInts, BoundedReals, CountingMeasure, IntegerDomain, IntegerNumbers
5564
using MeasureBase: weightedmeasure, restrict

src/combinators/affine.jl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ Base.propertynames(d::AffineTransform{N}) where {N} = N
2323

2424
import InverseFunctions: inverse
2525

26-
@inline inverse(f::AffineTransform{(:μ, :σ)}) =
27-
AffineTransform((μ = -(f.σ \ f.μ), ω = f.σ))
26+
@inline inverse(f::AffineTransform{(:μ, :σ)}) = AffineTransform((μ = -(f.σ \ f.μ), ω = f.σ))
2827
@inline inverse(f::AffineTransform{(:μ, :ω)}) = AffineTransform((μ = -f.ω * f.μ, σ = f.ω))
2928
@inline inverse(f::AffineTransform{(:σ,)}) = AffineTransform((ω = f.σ,))
3029
@inline inverse(f::AffineTransform{(:ω,)}) = AffineTransform((σ = f.ω,))
@@ -121,14 +120,12 @@ logjac(f::AffineTransform{(:μ,)}) = 0.0
121120

122121
###############################################################################
123122

124-
125123
struct OrthoLebesgue{N,T} <: PrimitiveMeasure
126124
par::NamedTuple{N,T}
127125

128126
OrthoLebesgue(nt::NamedTuple{N,T}) where {N,T} = new{N,T}(nt)
129127
end
130128

131-
132129
basemeasure(d::OrthoLebesgue) = d
133130

134131
logdensity_def(::OrthoLebesgue, x) = static(0)
@@ -139,7 +136,7 @@ struct Affine{N,M,T} <: AbstractMeasure
139136
end
140137

141138
function Pretty.tile(d::Affine)
142-
Pretty.list_layout(Pretty.tile.([params(d.f), d.parent]); prefix=:Affine)
139+
Pretty.list_layout(Pretty.tile.([params(d.f), d.parent]); prefix = :Affine)
143140
end
144141

145142
function testvalue(d::Affine)
@@ -233,16 +230,20 @@ end
233230
weightedmeasure(-logjac(d), OrthoLebesgue(params(d)))
234231
end
235232

236-
@inline function basemeasure(d::Affine{N,M,Tuple{A1,A2}}) where {N,M,A1<:AbstractArray, A2<:AbstractArray}
233+
@inline function basemeasure(
234+
d::Affine{N,M,Tuple{A1,A2}},
235+
) where {N,M,A1<:AbstractArray,A2<:AbstractArray}
237236
weightedmeasure(-logjac(d), OrthoLebesgue(params(d)))
238237
end
239238

240239
@inline basemeasure(d::Affine) = affine(getfield(d, :f), basemeasure(d.parent))
241240

242241
# We can't do this until we know we're working with Lebesgue measure, since for
243242
# example it wouldn't make sense to apply a log-Jacobian to a point measure
244-
@inline basemeasure(d::Affine{N,L}) where {N,L<:Lebesgue} = weightedmeasure(-logjac(d), d.parent)
245-
@inline basemeasure(d::Affine{N,L}) where {N,L<:LebesgueMeasure} = weightedmeasure(-logjac(d), d.parent)
243+
@inline basemeasure(d::Affine{N,L}) where {N,L<:Lebesgue} =
244+
weightedmeasure(-logjac(d), d.parent)
245+
@inline basemeasure(d::Affine{N,L}) where {N,L<:LebesgueMeasure} =
246+
weightedmeasure(-logjac(d), d.parent)
246247

247248
logjac(d::Affine) = logjac(getfield(d, :f))
248249

src/combinators/chain.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ using DynamicIterators
22
import DynamicIterators: dub, dyniterate, evolve
33
using Base.Iterators: SizeUnknown, IsInfinite
44

5-
65
export Chain
76

87
struct Chain{K,M} <: AbstractMeasure

src/combinators/exponential-families.jl

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export ExponentialFamily
55
mdim
66
pdim
77
t
8-
x
8+
x
99
a
1010
end
1111

@@ -17,7 +17,7 @@ function MeasureBase.powermeasure(fam::ExponentialFamily, dims::NTuple{N,I}) whe
1717
t = Tuple((y -> f.(y) for f in fam.t))
1818
a(η) = BroadcastArray(fam.a, η)
1919
p = prod(dims)
20-
ExponentialFamily(fam.base ^ dims, fam.mdim * p, fam.pdim * p, t, fam.x, a)
20+
ExponentialFamily(fam.base^dims, fam.mdim * p, fam.pdim * p, t, fam.x, a)
2121
end
2222

2323
@concrete terse struct ExpFamMeasure <: AbstractMeasure
@@ -26,24 +26,24 @@ end
2626
a # instantiated to a value
2727
end
2828

29-
3029
@inline function (fam::ExponentialFamily)(β)
31-
η = fam.x * β
30+
η = fam.x * β
3231
a = fam.a(η)
3332
ExpFamMeasure(fam, η, a)
3433
end
3534

3635
MeasureBase.basemeasure(d::ExpFamMeasure) = d.fam.base
3736

38-
tracedot(a::AbstractVector,b::AbstractVector) = dot(a, b)
37+
tracedot(a::AbstractVector, b::AbstractVector) = dot(a, b)
3938

40-
tracedot(a::AbstractVector,x,b::AbstractVector) = dot(a, x, b)
39+
tracedot(a::AbstractVector, x, b::AbstractVector) = dot(a, x, b)
4140

42-
tracedot(a,b) = sum((dot(view(a,:,j), view(b,:,j)) for j in 1:size(a,2)))
41+
tracedot(a, b) = sum((dot(view(a, :, j), view(b, :, j)) for j in 1:size(a, 2)))
4342

44-
tracedot(a,x,b) = sum(1:size(a,2)) do j
45-
dot(view(a,:,j), x, view(b,:,j))
46-
end
43+
tracedot(a, x, b) =
44+
sum(1:size(a, 2)) do j
45+
dot(view(a, :, j), x, view(b, :, j))
46+
end
4747

4848
# @inline function tracedot(a::BlockDiag, b::BlockDiag)
4949
# numblocks = length(a.blocks)
@@ -61,13 +61,12 @@ function logdensity_def(d::ExpFamMeasure, y)
6161
dot(t, η)
6262
end
6363

64-
6564
function withX(fam::ExponentialFamily, x)
6665
@inline t(y) = fam.t.(y)
6766
newx = ApplyArray(kron, x, fam.x)
6867
η(β) = fam.η.(β)
6968
a(β) = sum(fam.a, β)
70-
ExponentialFamily(fam.base ^ size(x,1), t, x, η, a)
69+
ExponentialFamily(fam.base^size(x, 1), t, x, η, a)
7170
end
7271

7372
@concrete terse struct ExpFamLikelihood <: AbstractLikelihood
@@ -80,11 +79,10 @@ end
8079
export likelihood
8180

8281
function regression(fam, uᵀ, vᵀ)
83-
8482
end
8583

8684
function likelihood(fam::ExponentialFamily, y)
87-
c = logdensityof(fam.base, y)
85+
c = logdensityof(fam.base, y)
8886
t = ApplyArray(vcat, (f.(y) for f in fam.t)...)
8987
tᵀx = t' * fam.x
9088
ExpFamLikelihood(fam, y, tᵀx, c)

0 commit comments

Comments
 (0)