Skip to content

Commit 7baa487

Browse files
committed
Fix most of depwarns and errors on 0.7
* The adjoint overloading is a serious type piracy * The `current_module()` depwarn is not fixed since fixing it requires threading the module over all functions in an API visible way.
1 parent c8d05a2 commit 7baa487

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/Calculus.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ isdefined(Base, :__precompile__) && __precompile__()
22

33
module Calculus
44
import Compat
5-
import Base.ctranspose
65
export check_derivative,
76
check_gradient,
87
check_hessian,

src/derivative.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ function Base.gradient(f, dtype::Symbol = :central)
2323
Calculus.gradient(f,dtype)
2424
end
2525

26-
ctranspose(f::Function) = derivative(f)
26+
if isdefined(Base, :adjoint)
27+
Base.adjoint(f::Function) = derivative(f)
28+
else
29+
Base.ctranspose(f::Function) = derivative(f)
30+
end
2731

2832
function jacobian{T <: Number}(f, x::Vector{T}, dtype::Symbol)
2933
finite_difference_jacobian(f, x, dtype)

test/derivative.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ f2(x::Vector) = sin(x[1])
1414
@test norm(derivative(f2, :vector, :central)([0.0]) .- cos(0.0)) < 10e-4
1515

1616
#
17-
# ctranspose overloading
17+
# adjoint overloading
1818
#
1919

2020
f3(x::Real) = sin(x)

0 commit comments

Comments
 (0)