JuliaMath / JuliaMath/MeasureBase.jl
no method matching iterate(::NoLogAbsDetJacobian)
- Dominant language
- Julia
- Stars
- 32
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
This doesn't work:
```julia
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
```julia
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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.