Skip to content

Commit 23eb984

Browse files
authored
Restrict StaticArrays to compatible versions (#688)
1 parent 5e9240a commit 23eb984

File tree

9 files changed

+28
-34
lines changed

9 files changed

+28
-34
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
version:
2020
- '1.6'
2121
- '1'
22-
- 'nightly'
22+
# - 'nightly'
2323
os:
2424
- ubuntu-latest
2525
arch:

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ LogExpFunctions = "0.3"
3131
NaNMath = "1"
3232
Preferences = "1"
3333
SpecialFunctions = "1, 2"
34-
StaticArrays = "1.5"
34+
StaticArrays = "1.5 - 1.6"
3535
julia = "1.6"
3636

3737
[extras]

test/AllocationsTest.jl

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,25 @@ convert_test_574() = convert(ForwardDiff.Dual{Nothing,ForwardDiff.Dual{Nothing,F
2424
index = 1
2525
alloc = @allocated ForwardDiff.seed!(duals, x, index, seeds)
2626
alloc = @allocated ForwardDiff.seed!(duals, x, index, seeds)
27-
@test alloc == 0
27+
if VERSION < v"1.9"
28+
@test alloc == 0
29+
else
30+
@test_broken alloc == 0
31+
end
2832

2933
index = 1
3034
alloc = @allocated ForwardDiff.seed!(duals, x, index, seed)
3135
alloc = @allocated ForwardDiff.seed!(duals, x, index, seed)
32-
@test alloc == 0
33-
36+
if VERSION < v"1.9"
37+
@test alloc == 0
38+
else
39+
@test_broken alloc == 0
40+
end
41+
3442
alloc = @allocated convert_test_574()
3543
alloc = @allocated convert_test_574()
3644
@test alloc == 0
37-
45+
3846
end
3947

4048
end

test/DerivativeTest.jl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ Random.seed!(1)
1717

1818
const x = 1
1919

20-
for f in DiffTests.NUMBER_TO_NUMBER_FUNCS
21-
println(" ...testing $f")
20+
@testset "$f" for f in DiffTests.NUMBER_TO_NUMBER_FUNCS
2221
v = f(x)
2322
d = ForwardDiff.derivative(f, x)
2423
@test isapprox(d, Calculus.derivative(f, x), atol=FINITEDIFF_ERROR)
@@ -29,8 +28,7 @@ for f in DiffTests.NUMBER_TO_NUMBER_FUNCS
2928
@test isapprox(DiffResults.derivative(out), d)
3029
end
3130

32-
for f in DiffTests.NUMBER_TO_ARRAY_FUNCS
33-
println(" ...testing $f")
31+
@testset "$f" for f in DiffTests.NUMBER_TO_ARRAY_FUNCS
3432
v = f(x)
3533
d = ForwardDiff.derivative(f, x)
3634

@@ -47,8 +45,7 @@ for f in DiffTests.NUMBER_TO_ARRAY_FUNCS
4745
@test isapprox(DiffResults.derivative(out), d)
4846
end
4947

50-
for f! in DiffTests.INPLACE_NUMBER_TO_ARRAY_FUNCS
51-
println(" ...testing $f!")
48+
@testset "$(f!)" for f! in DiffTests.INPLACE_NUMBER_TO_ARRAY_FUNCS
5249
m, n = 3, 2
5350
y = fill(0.0, m, n)
5451
f = x -> (tmp = similar(y, promote_type(eltype(y), typeof(x)), m, n); f!(tmp, x); tmp)

test/DualTest.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ ForwardDiff.:≺(::Type{TestTag}, ::Type{OuterTestTag}) = true
3131
ForwardDiff.:(::Type{OuterTestTag}, ::Type{TestTag}) = false
3232

3333
@testset "Dual{Z,$V,$N} and Dual{Z,Dual{Z,$V,$M},$N}" for N in (0,3), M in (0,4), V in (Int, Float32)
34-
println(" ...testing Dual{TestTag(),$V,$N} and Dual{TestTag(),Dual{TestTag(),$V,$M},$N}")
3534

3635
PARTIALS = Partials{N,V}(ntuple(n -> intrand(V), N))
3736
PRIMAL = intrand(V)
@@ -466,13 +465,12 @@ ForwardDiff.:≺(::Type{OuterTestTag}, ::Type{TestTag}) = false
466465
@test abs(NESTED_FDNUM) === NESTED_FDNUM
467466

468467
if V != Int
469-
@testset "$f" for (M, f, arity) in DiffRules.diffrules(filter_modules = nothing)
468+
@testset "$(M).$(f) with $arity arguments" for (M, f, arity) in DiffRules.diffrules(filter_modules = nothing)
470469
if f in (:/, :rem2pi)
471470
continue # Skip these rules
472471
elseif !(isdefined(@__MODULE__, M) && isdefined(getfield(@__MODULE__, M), f))
473472
continue # Skip rules for methods not defined in the current scope
474473
end
475-
println(" ...auto-testing $(M).$(f) with $arity arguments")
476474
if arity == 1
477475
deriv = DiffRules.diffrule(M, f, :x)
478476
modifier = if in(f, (:asec, :acsc, :asecd, :acscd, :acosh, :acoth))

test/GradientTest.jl

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ v = f(x)
2121
g = [-9.4, 15.6, 52.0]
2222

2323
@testset "Rosenbrock, chunk size = $c and tag = $(repr(tag))" for c in (1, 2, 3), tag in (nothing, Tag(f, eltype(x)))
24-
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}
@@ -60,8 +59,7 @@ cfgx = ForwardDiff.GradientConfig(sin, x)
6059
v = f(X)
6160
g = ForwardDiff.gradient(f, X)
6261
@test isapprox(g, Calculus.gradient(f, X), atol=FINITEDIFF_ERROR)
63-
for c in CHUNK_SIZES, tag in (nothing, Tag(f, eltype(x)))
64-
println(" ...testing $f with chunk size = $c and tag = $(repr(tag))")
62+
@testset "... with chunk size = $c and tag = $(repr(tag))" for c in CHUNK_SIZES, tag in (nothing, Tag(f, eltype(x)))
6563
cfg = ForwardDiff.GradientConfig(f, X, ForwardDiff.Chunk{c}(), tag)
6664

6765
out = ForwardDiff.gradient(f, X, cfg)
@@ -82,9 +80,7 @@ end
8280
# test specialized StaticArray codepaths #
8381
##########################################
8482

85-
println(" ...testing specialized StaticArray codepaths")
86-
87-
@testset "$T" for T in (StaticArrays.SArray, StaticArrays.MArray)
83+
@testset "Specialized StaticArray codepaths: $T" for T in (StaticArrays.SArray, StaticArrays.MArray)
8884
x = rand(3, 3)
8985

9086
sx = T{Tuple{3,3}}(x)
@@ -172,7 +168,7 @@ end
172168
function f(p)
173169
sum(collect(0.0:p[1]:p[2]))
174170
end
175-
@test ForwardDiff.gradient(f, [0.2,25.0]) == [7875.0, 0.0]
171+
@test ForwardDiff.gradient(f, [0.3, 25.0]) == [3486.0, 0.0]
176172
end
177173

178174
@testset "det with branches" begin
@@ -193,7 +189,7 @@ end
193189

194190
# And issue 407
195191
@test ForwardDiff.hessian(det, A) ForwardDiff.hessian(det2, A)
196-
192+
197193
# https://discourse.julialang.org/t/forwarddiff-and-zygote-return-wrong-jacobian-for-log-det-l/77961
198194
S = [1.0 0.8; 0.8 1.0]
199195
L = cholesky(S).L

test/HessianTest.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ h = [-66.0 -40.0 0.0;
2323
-40.0 130.0 -80.0;
2424
0.0 -80.0 200.0]
2525

26-
for c in HESSIAN_CHUNK_SIZES, tag in (nothing, Tag((f,ForwardDiff.gradient), eltype(x)))
27-
println(" ...running hardcoded test with chunk size = $c and tag = $(repr(tag))")
26+
@testset "running hardcoded test with chunk size = $c and tag = $(repr(tag))" for c in HESSIAN_CHUNK_SIZES, tag in (nothing, Tag((f,ForwardDiff.gradient), eltype(x)))
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,7 @@ 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 HESSIAN_CHUNK_SIZES, tag in (nothing, Tag((f,ForwardDiff.gradient), eltype(x)))
73-
println(" ...testing $f with chunk size = $c and tag = $(repr(tag))")
71+
@testset "$f with chunk size = $c and tag = $(repr(tag))" for c in HESSIAN_CHUNK_SIZES, tag in (nothing, Tag((f,ForwardDiff.gradient), eltype(x)))
7472
cfg = ForwardDiff.HessianConfig(f, X, ForwardDiff.Chunk{c}(), tag)
7573
resultcfg = ForwardDiff.HessianConfig(f, DiffResults.HessianResult(X), X, ForwardDiff.Chunk{c}(), tag)
7674

@@ -93,7 +91,7 @@ end
9391
# test specialized StaticArray codepaths #
9492
##########################################
9593

96-
println(" ...testing specialized StaticArray codepaths")
94+
@info "testing specialized StaticArray codepaths"
9795

9896
x = rand(3, 3)
9997
for T in (StaticArrays.SArray, StaticArrays.MArray)

test/JacobianTest.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,10 @@ for f in DiffTests.ARRAY_TO_ARRAY_FUNCS
103103
v = f(X)
104104
j = ForwardDiff.jacobian(f, X)
105105
@test isapprox(j, Calculus.jacobian(x -> vec(f(x)), X, :forward), atol=1.3FINITEDIFF_ERROR)
106-
for c in CHUNK_SIZES, tag in (nothing, Tag)
106+
@testset "$f with chunk size = $c and tag = $(repr(tag))" for c in CHUNK_SIZES, tag in (nothing, Tag)
107107
if tag == Tag
108108
tag = Tag(f, eltype(X))
109109
end
110-
println(" ...testing $f with chunk size = $c and tag = $(repr(tag))")
111110
cfg = JacobianConfig(f, X, ForwardDiff.Chunk{c}(), tag)
112111

113112
out = ForwardDiff.jacobian(f, X, cfg)
@@ -129,8 +128,7 @@ for f! in DiffTests.INPLACE_ARRAY_TO_ARRAY_FUNCS
129128
f!(v, X)
130129
j = ForwardDiff.jacobian(f!, fill!(similar(Y), 0.0), X)
131130
@test isapprox(j, Calculus.jacobian(x -> (y = fill!(similar(Y), 0.0); f!(y, x); vec(y)), X, :forward), atol=FINITEDIFF_ERROR)
132-
for c in CHUNK_SIZES, tag in (nothing, Tag(f!, eltype(X)))
133-
println(" ...testing $(f!) with chunk size = $c and tag = $(repr(tag))")
131+
@testset "$(f!) with chunk size = $c and tag = $(repr(tag))" for c in CHUNK_SIZES, tag in (nothing, Tag(f!, eltype(X)))
134132
ycfg = JacobianConfig(f!, fill!(similar(Y), 0.0), X, ForwardDiff.Chunk{c}(), tag)
135133

136134
y = fill!(similar(Y), 0.0)
@@ -164,7 +162,7 @@ end
164162
# test specialized StaticArray codepaths #
165163
##########################################
166164

167-
println(" ...testing specialized StaticArray codepaths")
165+
@info "testing specialized StaticArray codepaths"
168166

169167
x = rand(3, 3)
170168
for T in (StaticArrays.SArray, StaticArrays.MArray)

test/PartialsTest.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ using ForwardDiff: Partials
88
samerng() = MersenneTwister(1)
99

1010
@testset "Partials{$N,$T}" for N in (0, 3), T in (Int, Float32, Float64)
11-
println(" ...testing Partials{$N,$T}")
1211

1312
VALUES = (rand(T,N)...,)
1413
PARTIALS = Partials{N,T}(VALUES)

0 commit comments

Comments
 (0)