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

Calculus breaks Base.gradient function with ambiguous methods #123

Open
david-pl opened this issue May 7, 2018 · 1 comment
Open

Calculus breaks Base.gradient function with ambiguous methods #123

david-pl opened this issue May 7, 2018 · 1 comment

Comments

@david-pl
Copy link

david-pl commented May 7, 2018

Since a recent update, there seems to be a problem with the gradient fucntion.

The following works fine:

julia> gradient([1:3;])
3-element Array{Float64,1}:
 1.0
 1.0
 1.0

julia> using Calculus

julia> gradient([1:3;])
3-element Array{Float64,1}:
 1.0
 1.0
 1.0

However, if Calculus is used before calling gradient, you get

julia> using Calculus

julia> gradient([1:3;])
ERROR: MethodError: gradient(::Array{Int64,1}, ::Array{Int64,1}) is ambiguous. Candidates:
  gradient(f, x::Union{Array{T,1}, T}) where T<:Number in Calculus at /home/david/.julia/v0.6/Calculus/src/derivative.jl:17
  gradient(F::AbstractArray{T,1} where T, h::Array{T,1} where T) in Base.LinAlg at linalg/dense.jl:186
Possible fix, define
  gradient(::AbstractArray{T,1} where T, ::Array{T<:Number,1})
Stacktrace:
 [1] gradient(::Array{Int64,1}) at ./linalg/generic.jl:282

Even directly calling the function from base with Base.LinAlg.gradient throws the above error.
I am using v"0.3.1", but this also happens when pinning to v"0.3.0". Older version fail to pre-compile with Julia 0.6.2.

@mlubin
Copy link
Collaborator

mlubin commented May 12, 2018

This is a bug. Calculus should not be extending Base.gradient.

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