Skip to content

Commit

Permalink
Enable try/catch test
Browse files Browse the repository at this point in the history
  • Loading branch information
jgreener64 authored and wsmoses committed Aug 7, 2023
1 parent a20a5cb commit cde474c
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -375,19 +375,16 @@ end
@test autodiff(Reverse, f24, Active, Active(2.0))[1][1] == 3
@test autodiff(Forward, f24, Duplicated(2.0, 1.0))[1] == 3

# See #971
@static if VERSION v"1.9-"
function f25(x)
try
sqrt(-1.0)
return 3x
catch
return 2x
end
function f25(x)
try
sqrt(-1.0)
return 3x
catch
return 2x
end
@test autodiff(Reverse, f25, Active, Active(2.0))[1][1] == 2
@test autodiff(Forward, f25, Duplicated(2.0, 1.0))[1] == 2
end
@test autodiff(Reverse, f25, Active, Active(2.0))[1][1] == 2
@test autodiff(Forward, f25, Duplicated(2.0, 1.0))[1] == 2

f26(x) = circshift([1.0, 2x, 3.0], 1)[end]
@test autodiff(Reverse, f26, Active, Active(2.0))[1][1] == 2
Expand Down Expand Up @@ -2449,7 +2446,7 @@ end
@test autodiff(Reverse, f8, Active, Active(1.5))[1][1] == 0
@test autodiff(Forward, f8, Duplicated(1.5, 1.0))[1] == 0

# On Julia 1.6 the gradients are wrong (0.7 not 1.2)
# On Julia 1.6 the gradients are wrong (0.7 not 1.2), see #973
@static if VERSION v"1.7-"
f9(x) = sum(quantile([1.0, x], [0.5, 0.7]))
@test autodiff(Reverse, f9, Active, Active(2.0))[1][1] == 1.2
Expand Down

0 comments on commit cde474c

Please sign in to comment.