Skip to content

Derivatives do not work with non-float types? #206

Open
@bvdmitri

Description

@bvdmitri

E.g. this works fine

julia> derivative(DiffractorForwardBackend(), (a, b) -> sin(a) * cos(b), 1.0, 1.0)

but not this

julia> derivative(DiffractorForwardBackend(), (a, b) -> sin(a) * cos(b), 1, 1)
ERROR: MethodError: no method matching Diffractor.Jet(::Int64, ::Float64, ::Tuple{Float64})

Closest candidates are:
  Diffractor.Jet(::T, ::T, ::Tuple{Vararg{T, N}}) where {T, N}
   @ Diffractor ~/.julia/packages/Diffractor/vzpvE/src/jet.jl:19

Stacktrace:
  [1] njet(::Val{1}, ::typeof(sin), x₀::Int64)
    @ Diffractor ~/.julia/packages/Diffractor/vzpvE/src/higher_fwd_rules.jl:7
  [2] (::Diffractor.∂☆{1})(fb::ZeroBundle{1, typeof(sin)}, x::Diffractor.TangentBundle{1, Int64, Diffractor.TaylorTangent{…}})

and not this

julia> derivative(DiffractorForwardBackend(), (a, b) -> sin(a) * cos(b), π, 1.0)
ERROR: MethodError: no method matching Diffractor.Jet(::Irrational{:π}, ::Float64, ::Tuple{Float64})

Closest candidates are:
  Diffractor.Jet(::T, ::T, ::Tuple{Vararg{T, N}}) where {T, N}
   @ Diffractor ~/.julia/packages/Diffractor/vzpvE/src/jet.jl:19

Stacktrace:
  [1] njet(::Val{1}, ::typeof(sin), x₀::Irrational{:π})
julia> versioninfo()
Julia Version 1.10.0-beta1
Commit 6616549950e (2023-07-25 17:43 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin22.4.0)
  CPU: 12 × Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, skylake)
  Threads: 1 on 12 virtual cores
(jl_8k1XbP) pkg> st
Status `/private/var/folders/86/jlqr7cg52h3dd15zrj_145sr0000gn/T/jl_8k1XbP/Project.toml`
  [c29ec348] AbstractDifferentiation v0.5.2
  [9f5e2b26] Diffractor v0.2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions