JuliaDiff / JuliaDiff/TaylorDiff.jl

Ambiguity with forwarddiff ?

Open
#103 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
83
Forks
12
PR merge metrics
No merged PRs in 30d

Description

In https://github.com/lrnv/Copulas.jl/issues/301,

we have a

julia> using ForwardDiff, TaylorDiff

julia> x = ForwardDiff.Dual(1, 1)
Dual{Nothing}(1,1)

julia> y = ForwardDiff.Dual(1,1)
Dual{Nothing}(1,1)

julia> TaylorDiff.derivative(z -> z*y, x, one(x), Val{3}())
ERROR: MethodError: *(::TaylorScalar{ForwardDiff.Dual{Nothing, Int64, 1}, 3}, ::ForwardDiff.Dual{Nothing, Int64, 1}) is ambiguous.

Candidates:
  *(a::TaylorScalar, b::Number)
    @ TaylorDiff ~\.julia\packages\TaylorDiff\N6Pcf\src\primitive.jl:119
  *(x::Real, y::ForwardDiff.Dual{Ty}) where Ty
    @ ForwardDiff ~\.julia\packages\ForwardDiff\Or6Qh\src\dual.jl:149

Possible fix, define
  *(::TaylorScalar, ::ForwardDiff.Dual{Ty}) where Ty

Can we force the choice here between the two somehow, so the code goes through ? eg by defining

*(::TaylorScalar{ForwardDiff.Dual{Ty}}, ::ForwardDiff.Dual{Ty}) where Ty

?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the Julia example using TaylorDiff.derivative with ForwardDiff.Dual values. Read TaylorDiff's src/primitive.jl around line 119 and ForwardDiff's dual.jl around line 149 to understand the competing methods. Done means the example no longer raises the ambiguous * MethodError and the intended derivative path is established.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.