Skip to content

Commit

Permalink
add debugging info to clamp
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamed82008 committed Jan 15, 2019
1 parent 2ace38a commit 247aace
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Bijectors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ end

const TransformDistribution{T<:ContinuousUnivariateDistribution} = Union{T, Truncated{T}}
@inline function _clamp(x::Real, dist::TransformDistribution)
return clamp(x, minimum(dist), maximum(dist))
bounds = (minimum(dist), maximum(dist))
clamped_x = clamp(x, bounds...)
@debug "x = $x, bounds = $bounds, clamped_x = $clamped_x"
return clamped_x
end

link(d::TransformDistribution, x::Real) = _link(d, _clamp(x, d))
Expand Down Expand Up @@ -149,7 +152,10 @@ end

const SimplexDistribution = Union{Dirichlet}
@inline function _clamp(x::T, dist::SimplexDistribution) where T
return clamp(x, zero(T), one(T))
bounds = (zero(T), one(T))
clamped_x = clamp(x, bounds...)
@debug "x = $x, bounds = $bounds, clamped_x = $clamped_x"
return clamped_x
end

function link(
Expand Down

0 comments on commit 247aace

Please sign in to comment.