MeasureBase.jl
MeasureBase.jl copied to clipboard
no method matching iterate(::NoLogAbsDetJacobian)
This doesn't work:
julia> using ChainRules, MeasureBase, InverseFunctions
julia> f(x) = 3x + 1
f (generic function with 1 method)
julia> finv(y) = (y - 1) / 3
finv (generic function with 1 method)
julia> d = pushfwd(setinverse(f, finv), StdNormal())
PushforwardMeasure(
InverseFunctions.FunctionWithInverse{typeof(f), typeof(finv)}(f, finv),
StdNormal())
julia> logdensity_def(d, 0.2)
ERROR: MethodError: no method matching iterate(::NoLogAbsDetJacobian{typeof(finv), Float64})
Closest candidates are:
iterate(::Base.EnvDict)
@ Base env.jl:186
iterate(::Base.EnvDict, ::Any)
@ Base env.jl:186
iterate(::Base.AsyncGenerator, ::Base.AsyncGeneratorState)
@ Base asyncmap.jl:362
The problem is a line that reads
x_orig, inv_ladj = with_logabsdet_jacobian(unwrap(finv), y)
The rhs is a NoLogAbsDetJacobian{typeof(finv), Float64}
, which the lhs tries to deconstruct as a pair.
It would be better to assign this a temporary variable first, so we could add a line that gives an informative error if it's not a pair. After that we could deconstruct it safely.
I'll add it to the ToDo-list for #122 ...