Skip to content

Commit

Permalink
Printing to find CI error
Browse files Browse the repository at this point in the history
  • Loading branch information
jgreener64 authored and wsmoses committed Aug 7, 2023
1 parent cde474c commit 84f5331
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,12 @@ end
f10(x) = x * argmax([1.0, 3.0, 2.0])
@test autodiff(Reverse, f10, Active, Active(3.0))[1][1] == 2
@test autodiff(Forward, f10, Duplicated(3.0, 1.0))[1] == 2
println("Done 10")

f11(x) = x * sum(LinRange(x, 10.0, 6))
@test autodiff(Reverse, f11, Active, Active(2.0))[1][1] == 42
@test autodiff(Forward, f11, Duplicated(2.0, 1.0))[1] == 42
println("Done 11")

f12(x, k) = get(Dict(1 => 1.0, 2 => x, 3 => 3.0), k, 1.0)
@test autodiff(Reverse, f12, Active, Active(2.0), Const(2))[1] == (1.0, nothing)
Expand All @@ -313,49 +315,60 @@ end
@test autodiff(Forward, f12, Duplicated(2.0, 1.0), Const(3)) == (0.0,)
@test autodiff(Reverse, f12, Active, Active(2.0), Const(4))[1] == (0.0, nothing)
@test autodiff(Forward, f12, Duplicated(2.0, 1.0), Const(4)) == (0.0,)
println("Done 12")

f13(x) = muladd(x, 3, x)
@test autodiff(Reverse, f13, Active, Active(2.0))[1][1] == 4
@test autodiff(Forward, f13, Duplicated(2.0, 1.0))[1] == 4
println("Done 13")

f14(x) = x * cmp(x, 3)
@test autodiff(Reverse, f14, Active, Active(2.0))[1][1] == -1
@test autodiff(Forward, f14, Duplicated(2.0, 1.0))[1] == -1
println("Done 14")

f15(x) = hypot(x, 2x)
@test autodiff(Reverse, f15, Active, Active(2.0))[1][1] == sqrt(5)
@test autodiff(Forward, f15, Duplicated(2.0, 1.0))[1] == sqrt(5)
println("Done 15")

f16(x) = evalpoly(2, (1, 2, x))
@test autodiff(Reverse, f16, Active, Active(3.0))[1][1] == 4
@test autodiff(Forward, f16, Duplicated(3.0, 1.0))[1] == 4
println("Done 16")

f17(x) = @evalpoly(2, 1, 2, x)
@test autodiff(Reverse, f17, Active, Active(3.0))[1][1] == 4
@test autodiff(Forward, f17, Duplicated(3.0, 1.0))[1] == 4
println("Done 17")

f18(x) = widemul(x, 5.0f0)
@test autodiff(Reverse, f18, Active, Active(2.0f0))[1][1] == 5
@test autodiff(Forward, f18, Duplicated(2.0f0, 1.0f0))[1] == 5
println("Done 18")

f19(x) = copysign(x, -x)
@test autodiff(Reverse, f19, Active, Active(2.0))[1][1] == -1
@test autodiff(Forward, f19, Duplicated(2.0, 1.0))[1] == -1
println("Done 19")

f20(x) = sum([ifelse(i > 5, i, zero(i)) for i in [x, 2x, 3x, 4x]])
@test autodiff(Reverse, f20, Active, Active(2.0))[1][1] == 7
@test autodiff(Forward, f20, Duplicated(2.0, 1.0))[1] == 7
println("Done 20")

function f21(x)
nt = (a=x, b=2x, c=3x)
return nt.c
end
@test autodiff(Reverse, f21, Active, Active(2.0))[1][1] == 3
@test autodiff(Forward, f21, Duplicated(2.0, 1.0))[1] == 3
println("Done 21")

f22(x) = sum(fill(x, (3, 3)))
@test autodiff(Reverse, f22, Active, Active(2.0))[1][1] == 9
@test autodiff(Forward, f22, Duplicated(2.0, 1.0))[1] == 9
println("Done 22")

function f23(x)
a = similar(rand(3, 3))
Expand All @@ -364,6 +377,7 @@ end
end
@test autodiff(Reverse, f23, Active, Active(2.0))[1][1] == 9
@test autodiff(Forward, f23, Duplicated(2.0, 1.0))[1] == 9
println("Done 23")

function f24(x)
try
Expand All @@ -374,6 +388,7 @@ end
end
@test autodiff(Reverse, f24, Active, Active(2.0))[1][1] == 3
@test autodiff(Forward, f24, Duplicated(2.0, 1.0))[1] == 3
println("Done 24")

function f25(x)
try
Expand All @@ -385,41 +400,50 @@ end
end
@test autodiff(Reverse, f25, Active, Active(2.0))[1][1] == 2
@test autodiff(Forward, f25, Duplicated(2.0, 1.0))[1] == 2
println("Done 25")

f26(x) = circshift([1.0, 2x, 3.0], 1)[end]
@test autodiff(Reverse, f26, Active, Active(2.0))[1][1] == 2
@test autodiff(Forward, f26, Duplicated(2.0, 1.0))[1] == 2
println("Done 26")

f27(x) = sum(diff([0.0 x; 1.0 2x]; dims=2))
@test autodiff(Reverse, f27, Active, Active(2.0))[1][1] == 3
@test autodiff(Forward, f27, Duplicated(2.0, 1.0))[1] == 3
println("Done 27")

f28(x) = repeat([x 3x], 3)[2, 2]
@test autodiff(Reverse, f28, Active, Active(2.0))[1][1] == 3
@test autodiff(Forward, f28, Duplicated(2.0, 1.0))[1] == 3
println("Done 28")

f29(x) = rot180([x 2x; 3x 4x], 3)[1, 1]
@test autodiff(Reverse, f29, Active, Active(2.0))[1][1] == 4
@test autodiff(Forward, f29, Duplicated(2.0, 1.0))[1] == 4
println("Done 29")

f30(x) = x * sum(trues(4, 3))
@test autodiff(Reverse, f30, Active, Active(2.0))[1][1] == 12
@test autodiff(Forward, f30, Duplicated(2.0, 1.0))[1] == 12
println("Done 30")

f31(x) = sum(Set([1.0, x, 2x, x]))
@test autodiff(Reverse, f31, Active, Active(2.0))[1][1] == 3
@test autodiff(Forward, f31, Duplicated(2.0, 1.0))[1] == 3
println("Done 31")

f32(x) = reverse([x 2.0 3x])[1]
@test autodiff(Reverse, f32, Active, Active(2.0))[1][1] == 3
@test autodiff(Forward, f32, Duplicated(2.0, 1.0))[1] == 3
println("Done 32")

# See #970
@static if VERSION v"1.9-"
f33(x) = sum(skipmissing([x, missing, 3.0, 3x]))
@test autodiff(Reverse, f33, Active, Active(2.0))[1][1] == 4
@test autodiff(Forward, f33, Duplicated(2.0, 1.0))[1] == 4
end
println("Done 33")
end

@testset "Taylor series tests" begin
Expand Down

0 comments on commit 84f5331

Please sign in to comment.