Skip to content

Commit a0af7cc

Browse files
committed
add comments for callable types
1 parent c8f4422 commit a0af7cc

File tree

4 files changed

+7
-0
lines changed

4 files changed

+7
-0
lines changed

src/hamiltonian.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ struct Hamiltonian{T<:Real,M<:AbstractMetric{T},F1,F2}
66
∂logπ∂θ :: F2
77
end
88

9+
# Create a `Hamiltonian` with a new `M⁻¹`
910
function (h::Hamiltonian)(M⁻¹)
1011
return Hamiltonian(h.metric(M⁻¹), h.logπ, h.∂logπ∂θ)
1112
end

src/integrator.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ struct Leapfrog{T<:AbstractFloat} <: AbstractIntegrator
44
ϵ :: T
55
end
66

7+
# Create a `Leapfrog` with a new `ϵ`
78
function (::Leapfrog)(ϵ::AbstractFloat)
89
return Leapfrog(ϵ)
910
end

src/metric.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ function UnitEuclideanMetric(θ::A) where {T<:Real,A<:AbstractVector{T}}
88
return UnitEuclideanMetric{T}(length(θ))
99
end
1010

11+
# Create a `UnitEuclideanMetric`; required for an unified interface
1112
function (ue::UnitEuclideanMetric{T})(::Nothing) where {T<:Real}
1213
return UnitEuclideanMetric{T}(ue.dim)
1314
end
@@ -22,6 +23,7 @@ struct DiagEuclideanMetric{T<:Real,A<:AbstractVector{T}} <: AbstractMetric{T}
2223
_temp :: A
2324
end
2425

26+
# Create a `DiagEuclideanMetric` with a new `M⁻¹`
2527
function (::DiagEuclideanMetric)(M⁻¹::A) where {T<:Real,A<:AbstractVector{T}}
2628
return DiagEuclideanMetric(M⁻¹)
2729
end
@@ -46,6 +48,7 @@ struct DenseEuclideanMetric{T<:Real,AV<:AbstractVector{T},AM<:AbstractMatrix{T}}
4648
_temp :: AV
4749
end
4850

51+
# Create a `DenseEuclideanMetric` with a new `M⁻¹`
4952
function (::DenseEuclideanMetric)(M⁻¹::A) where {T<:Real,A<:AbstractMatrix{T}}
5053
return DenseEuclideanMetric(M⁻¹)
5154
end

src/proposal.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ struct TakeLastProposal{I<:AbstractIntegrator} <: StaticTrajectory{I}
77
n_steps :: Int
88
end
99

10+
# Create a `TakeLastProposal` with a new `ϵ`
1011
function (tlp::TakeLastProposal)(ϵ::AbstractFloat)
1112
return TakeLastProposal(tlp.integrator(ϵ), tlp.n_steps)
1213
end
@@ -22,6 +23,7 @@ struct SliceNUTS{I<:AbstractIntegrator} <: NoUTurnTrajectory{I}
2223
integrator :: I
2324
end
2425

26+
# Create a `SliceNUTS` with a new `ϵ`
2527
function (snuts::SliceNUTS)(ϵ::AbstractFloat)
2628
return SliceNUTS(snuts.integrator(ϵ))
2729
end

0 commit comments

Comments
 (0)