JuliaMath / JuliaMath/Calculus.jl

Calculus breaks Base.gradient function with ambiguous methods

Open
#123 1 comment 3 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
285
Forks
78
PR merge metrics
No merged PRs in 30d

Description

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

The following works fine:
```julia
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
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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.