Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no method matching iterate(::NoLogAbsDetJacobian) #124

Open
cscherrer opened this issue Aug 7, 2023 · 1 comment
Open

no method matching iterate(::NoLogAbsDetJacobian) #124

cscherrer opened this issue Aug 7, 2023 · 1 comment
Assignees

Comments

@cscherrer
Copy link
Collaborator

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.

@cscherrer cscherrer self-assigned this Aug 7, 2023
@oschulz
Copy link
Collaborator

oschulz commented Aug 8, 2023

I'll add it to the ToDo-list for #122 ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants