Skip to content

Commit 8851a55

Browse files
committed
Updates for Julia v0.7
- bump Julia requirement to 0.7-beta - update Travis and AppVeyor scripts - remove usage of Compat - misc other Julia 0.7 changes
1 parent 3f62885 commit 8851a55

16 files changed

+72
-73
lines changed

.travis.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
language: julia
22
julia:
3-
- 0.6
3+
# - 0.7
44
- nightly
5-
matrix:
6-
allow_failures:
7-
- julia: nightly
5+
# matrix:
6+
# allow_failures:
7+
# - julia: nightly
88
notifications:
99
email: false
1010
sudo: false
1111
script:
1212
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
13-
- julia -e 'include(joinpath(JULIA_HOME, Base.DATAROOTDIR, "julia", "build_sysimg.jl")); build_sysimg(force=true)';
1413
- julia -e 'Pkg.clone(pwd()); Pkg.build("ForwardDiff"); Pkg.test("ForwardDiff"; coverage=true)';
1514
- julia -O3 -e 'include(joinpath(Pkg.dir("ForwardDiff"), "test/SIMDTest.jl"))';
1615
after_success:

REQUIRE

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
julia 0.6.0
2-
Compat 0.47.0
1+
julia 0.7-beta
32
StaticArrays 0.5.0
43
DiffResults 0.0.1
54
DiffRules 0.0.4

appveyor.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
environment:
22
matrix:
3-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
4-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
3+
# - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.7/julia-0.7-latest-win32.exe"
4+
# - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.7/julia-0.7-latest-win64.exe"
5+
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
6+
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
57

68
branches:
79
only:

docs/make.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ makedocs(modules=[ForwardDiff],
1616

1717
deploydocs(repo = "github.com/JuliaDiff/ForwardDiff.jl.git",
1818
osname = "linux",
19-
julia = "0.6",
19+
julia = "0.7",
2020
target = "build",
2121
deps = nothing,
2222
make = nothing)

src/ForwardDiff.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ module ForwardDiff
55
using DiffRules, DiffResults
66
using DiffResults: DiffResult, MutableDiffResult, ImmutableDiffResult
77
using StaticArrays
8-
using Compat
9-
using Compat.Random
8+
using Random
109

1110
import NaNMath
1211
import SpecialFunctions

test/ConfusionTest.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
module ConfusionTest
22

3-
using Compat
4-
using Compat.Test
3+
using Test
54
using ForwardDiff
65

6+
using LinearAlgebra
7+
78
# Perturbation Confusion (Issue #83) #
89
#------------------------------------#
910

@@ -44,7 +45,7 @@ function Legendre_transformation(F, w)
4445
z = fill(0.0, size(w))
4546
M = ForwardDiff.hessian(F, z)
4647
b = ForwardDiff.gradient(F, z)
47-
v = cholfact(M)\(w-b)
48+
v = cholesky(M)\(w-b)
4849
dot(w,v) - F(v)
4950
end
5051
function Lagrangian2Hamiltonian(Lagrangian, t, q, p)

test/DeprecatedTest.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module DeprecatedTest
22

3-
using Compat
4-
using Compat.Test
3+
using Test
54
using ForwardDiff, DiffResults
65

76
using ForwardDiff: AbstractConfig, GradientConfig,
@@ -31,7 +30,7 @@ out = DiffResults.HessianResult(x)
3130
N = 1
3231
chunk = ForwardDiff.Chunk{N}()
3332

34-
info("The following tests print lots of deprecation warnings on purpose.")
33+
@info("The following tests print lots of deprecation warnings on purpose.")
3534

3635
@test similar_config(GradientConfig{N}(x), GradientConfig(nothing, x, chunk))
3736
@test similar_config(JacobianConfig{N}(x), JacobianConfig(nothing, x, chunk))
@@ -40,6 +39,6 @@ info("The following tests print lots of deprecation warnings on purpose.")
4039
@test similar_config(HessianConfig{N}(out, x), HessianConfig(nothing, out, x, chunk))
4140
@test similar_config(MultithreadConfig(GradientConfig(nothing, x, chunk)), GradientConfig(nothing, x, chunk))
4241

43-
info("Deprecation testing is now complete, so any further deprecation warnings are real.")
42+
@info("Deprecation testing is now complete, so any further deprecation warnings are real.")
4443

4544
end # module

test/DerivativeTest.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ module DerivativeTest
22

33
import Calculus
44

5-
using Compat
6-
using Compat.Test
5+
using Test
6+
using Random
77
using ForwardDiff
88
using DiffTests
99

test/DualTest.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module DualTest
22

3-
using Compat
4-
using Compat.Test
3+
using Test
4+
using Random
55
using ForwardDiff
66
using ForwardDiff: Partials, Dual, value, partials
77

test/GradientTest.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ module GradientTest
22

33
import Calculus
44

5-
using Compat
6-
using Compat.Test
5+
using Test
76
using ForwardDiff
87
using ForwardDiff: Dual, Tag
98
using StaticArrays
@@ -21,7 +20,7 @@ v = f(x)
2120
g = [-9.4, 15.6, 52.0]
2221

2322
for c in (1, 2, 3), tag in (nothing, Tag(f, eltype(x)))
24-
println(" ...running hardcoded test with chunk size = $c and tag = $tag")
23+
println(" ...running hardcoded test with chunk size = $c and tag = $(repr(tag))")
2524
cfg = ForwardDiff.GradientConfig(f, x, ForwardDiff.Chunk{c}(), tag)
2625

2726
@test eltype(cfg) == Dual{typeof(tag), eltype(x), c}
@@ -61,7 +60,7 @@ for f in DiffTests.VECTOR_TO_NUMBER_FUNCS
6160
g = ForwardDiff.gradient(f, X)
6261
@test isapprox(g, Calculus.gradient(f, X), atol=FINITEDIFF_ERROR)
6362
for c in CHUNK_SIZES, tag in (nothing, Tag(f, eltype(x)))
64-
println(" ...testing $f with chunk size = $c and tag = $tag")
63+
println(" ...testing $f with chunk size = $c and tag = $(repr(tag))")
6564
cfg = ForwardDiff.GradientConfig(f, X, ForwardDiff.Chunk{c}(), tag)
6665

6766
out = ForwardDiff.gradient(f, X, cfg)

test/HessianTest.jl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ module HessianTest
22

33
import Calculus
44

5-
using Compat
6-
using Compat.Test
5+
using Test
76
using ForwardDiff
87
using ForwardDiff: Dual, Tag
98
using StaticArrays
@@ -23,8 +22,8 @@ h = [-66.0 -40.0 0.0;
2322
-40.0 130.0 -80.0;
2423
0.0 -80.0 200.0]
2524

26-
for c in (1, 2, 3), tag in (nothing, Tag((f,gradient), eltype(x)))
27-
println(" ...running hardcoded test with chunk size = $c and tag = $tag")
25+
for c in (1, 2, 3), tag in (nothing, Tag((f,ForwardDiff.gradient), eltype(x)))
26+
println(" ...running hardcoded test with chunk size = $c and tag = $(repr(tag))")
2827
cfg = ForwardDiff.HessianConfig(f, x, ForwardDiff.Chunk{c}(), tag)
2928
resultcfg = ForwardDiff.HessianConfig(f, DiffResults.HessianResult(x), x, ForwardDiff.Chunk{c}(), tag)
3029

@@ -69,8 +68,8 @@ for f in DiffTests.VECTOR_TO_NUMBER_FUNCS
6968
h = ForwardDiff.hessian(f, X)
7069
# finite difference approximation error is really bad for Hessians...
7170
@test isapprox(h, Calculus.hessian(f, X), atol=0.02)
72-
for c in CHUNK_SIZES, tag in (nothing, Tag((f,gradient), eltype(x)))
73-
println(" ...testing $f with chunk size = $c and tag = $tag")
71+
for c in CHUNK_SIZES, tag in (nothing, Tag((f,ForwardDiff.gradient), eltype(x)))
72+
println(" ...testing $f with chunk size = $c and tag = $(repr(tag))")
7473
cfg = ForwardDiff.HessianConfig(f, X, ForwardDiff.Chunk{c}(), tag)
7574
resultcfg = ForwardDiff.HessianConfig(f, DiffResults.HessianResult(X), X, ForwardDiff.Chunk{c}(), tag)
7675

test/JacobianTest.jl

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ module JacobianTest
22

33
import Calculus
44

5-
using Compat
6-
using Compat.Test
5+
using Test
76
using ForwardDiff
87
using ForwardDiff: Dual, Tag, JacobianConfig
98
using StaticArrays
@@ -33,7 +32,7 @@ j = [0.8242369704835132 0.4121184852417566 -10.933563142616123
3332

3433
for c in (1, 2, 3), tags in ((nothing, nothing),
3534
(Tag(f, eltype(x)), Tag(f!, eltype(x))))
36-
println(" ...running hardcoded test with chunk size = $c and tag = $tags")
35+
println(" ...running hardcoded test with chunk size = $c and tag = $(repr(tags))")
3736
cfg = JacobianConfig(f, x, ForwardDiff.Chunk{c}(), tags[1])
3837
ycfg = JacobianConfig(f!, fill(0.0, 4), x, ForwardDiff.Chunk{c}(), tags[2])
3938

@@ -108,7 +107,7 @@ for f in DiffTests.ARRAY_TO_ARRAY_FUNCS
108107
if tag == Tag
109108
tag = Tag(f, eltype(X))
110109
end
111-
println(" ...testing $f with chunk size = $c and tag = $tag")
110+
println(" ...testing $f with chunk size = $c and tag = $(repr(tag))")
112111
cfg = JacobianConfig(f, X, ForwardDiff.Chunk{c}(), tag)
113112

114113
out = ForwardDiff.jacobian(f, X, cfg)
@@ -131,7 +130,7 @@ for f! in DiffTests.INPLACE_ARRAY_TO_ARRAY_FUNCS
131130
j = ForwardDiff.jacobian(f!, fill!(similar(Y), 0.0), X)
132131
@test isapprox(j, Calculus.jacobian(x -> (y = fill!(similar(Y), 0.0); f!(y, x); vec(y)), X, :forward), atol=FINITEDIFF_ERROR)
133132
for c in CHUNK_SIZES, tag in (nothing, Tag(f!, eltype(X)))
134-
println(" ...testing $(f!) with chunk size = $c and tag = $tag")
133+
println(" ...testing $(f!) with chunk size = $c and tag = $(repr(tag))")
135134
ycfg = JacobianConfig(f!, fill!(similar(Y), 0.0), X, ForwardDiff.Chunk{c}(), tag)
136135

137136
y = fill!(similar(Y), 0.0)
@@ -173,35 +172,38 @@ sx = StaticArrays.SArray{Tuple{3,3}}(x)
173172
cfg = ForwardDiff.JacobianConfig(nothing, x)
174173
scfg = ForwardDiff.JacobianConfig(nothing, sx)
175174

176-
actual = ForwardDiff.jacobian(diff, x)
177-
@test ForwardDiff.jacobian(diff, sx) == actual
178-
@test ForwardDiff.jacobian(diff, sx, cfg) == actual
179-
@test ForwardDiff.jacobian(diff, sx, scfg) == actual
180-
@test ForwardDiff.jacobian(diff, sx, scfg) isa StaticArray
181-
@test ForwardDiff.jacobian(diff, sx, scfg, Val{false}()) == actual
182-
@test ForwardDiff.jacobian(diff, sx, scfg, Val{false}()) isa StaticArray
175+
_diff(A) = false ? diff(A, 1) : diff(A; dims=1)
176+
_diff(A::StaticArray) = diff(A) # StaticArray's don't use dims kwarg (yet)
177+
178+
actual = ForwardDiff.jacobian(_diff, x)
179+
@test ForwardDiff.jacobian(_diff, sx) == actual
180+
@test ForwardDiff.jacobian(_diff, sx, cfg) == actual
181+
@test ForwardDiff.jacobian(_diff, sx, scfg) == actual
182+
@test ForwardDiff.jacobian(_diff, sx, scfg) isa StaticArray
183+
@test ForwardDiff.jacobian(_diff, sx, scfg, Val{false}()) == actual
184+
@test ForwardDiff.jacobian(_diff, sx, scfg, Val{false}()) isa StaticArray
183185

184186
out = similar(x, 6, 9)
185-
ForwardDiff.jacobian!(out, diff, sx)
187+
ForwardDiff.jacobian!(out, _diff, sx)
186188
@test out == actual
187189

188190
out = similar(x, 6, 9)
189-
ForwardDiff.jacobian!(out, diff, sx, cfg)
191+
ForwardDiff.jacobian!(out, _diff, sx, cfg)
190192
@test out == actual
191193

192194
out = similar(x, 6, 9)
193-
ForwardDiff.jacobian!(out, diff, sx, scfg)
195+
ForwardDiff.jacobian!(out, _diff, sx, scfg)
194196
@test out == actual
195197

196198
result = DiffResults.JacobianResult(similar(x, 6), x)
197-
result = ForwardDiff.jacobian!(result, diff, x)
199+
result = ForwardDiff.jacobian!(result, _diff, x)
198200

199201
result1 = DiffResults.JacobianResult(similar(sx, 6), sx)
200202
result2 = DiffResults.JacobianResult(similar(sx, 6), sx)
201203
result3 = DiffResults.JacobianResult(similar(sx, 6), sx)
202-
result1 = ForwardDiff.jacobian!(result1, diff, sx)
203-
result2 = ForwardDiff.jacobian!(result2, diff, sx, cfg)
204-
result3 = ForwardDiff.jacobian!(result3, diff, sx, scfg)
204+
result1 = ForwardDiff.jacobian!(result1, _diff, sx)
205+
result2 = ForwardDiff.jacobian!(result2, _diff, sx, cfg)
206+
result3 = ForwardDiff.jacobian!(result3, _diff, sx, scfg)
205207
@test DiffResults.value(result1) == DiffResults.value(result)
206208
@test DiffResults.value(result2) == DiffResults.value(result)
207209
@test DiffResults.value(result3) == DiffResults.value(result)
@@ -213,9 +215,9 @@ sy = @SVector fill(zero(eltype(sx)), 6)
213215
sresult1 = DiffResults.JacobianResult(sy, sx)
214216
sresult2 = DiffResults.JacobianResult(sy, sx)
215217
sresult3 = DiffResults.JacobianResult(sy, sx)
216-
sresult1 = ForwardDiff.jacobian!(sresult1, diff, sx)
217-
sresult2 = ForwardDiff.jacobian!(sresult2, diff, sx, cfg)
218-
sresult3 = ForwardDiff.jacobian!(sresult3, diff, sx, scfg)
218+
sresult1 = ForwardDiff.jacobian!(sresult1, _diff, sx)
219+
sresult2 = ForwardDiff.jacobian!(sresult2, _diff, sx, cfg)
220+
sresult3 = ForwardDiff.jacobian!(sresult3, _diff, sx, scfg)
219221
@test DiffResults.value(sresult1) == DiffResults.value(result)
220222
@test DiffResults.value(sresult2) == DiffResults.value(result)
221223
@test DiffResults.value(sresult3) == DiffResults.value(result)

test/MiscTest.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ module MiscTest
22

33
import NaNMath
44

5-
using Compat
6-
using Compat.Test
5+
using Test
76
using ForwardDiff
87
using DiffTests
8+
using SparseArrays: sparse
99

1010
include(joinpath(dirname(@__FILE__), "utils.jl"))
1111

@@ -114,7 +114,7 @@ N = 4
114114
a = fill(1.0, N)
115115
jac0 = reshape(vcat([[fill(0.0, N*(i-1)); a; fill(0.0, N^2-N*i)] for i = 1:N]...), N^2, N)
116116

117-
for op in (:-, :+, :.-, :.+, :./, :.*)
117+
for op in (:.-, :.+, :./, :.*)
118118
f = @eval x -> [$op(x[1], a); $op(x[2], a); $op(x[3], a); $op(x[4], a)]
119119
jac = @eval ForwardDiff.jacobian(f, a)
120120
@test isapprox(jac0, jac)

test/PartialsTest.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module PartialsTest
22

3-
using Compat
4-
using Compat.Test
3+
using Test
4+
using Random
55
using ForwardDiff
66
using ForwardDiff: Partials
77

test/SIMDTest.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module SIMDTest
22

3-
using Compat
4-
using Compat.Test
3+
using Test
54
using ForwardDiff: Dual, valtype
5+
using InteractiveUtils: code_llvm
66

77
const DUALS = (Dual(1., 2., 3., 4.),
88
Dual(1., 2., 3., 4., 5.),
@@ -19,28 +19,28 @@ end
1919

2020
for D in map(typeof, DUALS)
2121
plus_bitcode = sprint(io -> code_llvm(io, +, (D, D)))
22-
@test contains(plus_bitcode, "fadd <4 x double>")
22+
@test occursin("fadd <4 x double>", plus_bitcode)
2323

2424
minus_bitcode = sprint(io -> code_llvm(io, -, (D, D)))
25-
@test contains(minus_bitcode, "fsub <4 x double>")
25+
@test occursin("fsub <4 x double>", minus_bitcode)
2626

2727
times_bitcode = sprint(io -> code_llvm(io, *, (D, D)))
28-
@test ismatch(r"fadd \<.*?x double\>", times_bitcode)
29-
@test ismatch(r"fmul \<.*?x double\>", times_bitcode)
28+
@test occursin(r"fadd \<.*?x double\>", times_bitcode)
29+
@test occursin(r"fmul \<.*?x double\>", times_bitcode)
3030

3131
div_bitcode = sprint(io -> code_llvm(io, /, (D, D)))
32-
@test ismatch(r"fadd \<.*?x double\>", div_bitcode)
33-
@test ismatch(r"fmul \<.*?x double\>", div_bitcode)
32+
@test occursin(r"fadd \<.*?x double\>", div_bitcode)
33+
@test occursin(r"fmul \<.*?x double\>", div_bitcode)
3434

3535
exp_bitcode = sprint(io -> code_llvm(io, ^, (D, D)))
36-
@test ismatch(r"fadd \<.*?x double\>", exp_bitcode)
36+
@test occursin(r"fadd \<.*?x double\>", exp_bitcode)
3737
if !(valtype(D) <: Dual)
3838
# see https://github.com/JuliaDiff/ForwardDiff.jl/issues/167
39-
@test ismatch(r"fmul \<.*?x double\>", exp_bitcode)
39+
@test occursin(r"fmul \<.*?x double\>", exp_bitcode)
4040

4141
# see https://github.com/JuliaDiff/ForwardDiff.jl/pull/201
4242
sum_bitcode = sprint(io -> code_llvm(io, simd_sum, (Vector{D},)))
43-
@test ismatch(r"fadd \<.*?x double\>", sum_bitcode)
43+
@test occursin(r"fadd (fast |)\<.*?x double\>", sum_bitcode)
4444
end
4545
end
4646

test/utils.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import ForwardDiff
22
using ForwardDiff: DEFAULT_CHUNK_THRESHOLD
3-
using Compat
4-
using Compat.Test
3+
using Test
4+
using Random
55

66
# seed RNG, thus making result inaccuracies deterministic
77
# so we don't have to retune EPS for arbitrary inputs

0 commit comments

Comments
 (0)