Skip to content

Commit 98bc7d0

Browse files
committed
Add tests
1 parent b3f3ba1 commit 98bc7d0

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

test/chainrules.jl

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,33 @@
8181

8282
@testset "log gamma and co" begin
8383
# It is important that we have negative numbers with both odd and even integer parts
84-
for x in (1.5, 2.5, 10.5, -0.6, -2.6, -3.3, 1.6 + 1.6im, 1.6 - 1.6im, -4.6 + 1.6im)
84+
test_points = (1.5, 2.5, 10.5, -0.6, -2.6, -3.3, 1.6 + 1.6im, 1.6 - 1.6im, -4.6 + 1.6im)
85+
for x in test_points
8586
for m in (0, 1, 2, 3)
8687
test_frule(polygamma, m, x)
8788
test_rrule(polygamma, m, x)
8889
end
8990

9091
isreal(x) && x < 0 && continue
9192
test_scalar(loggamma, x)
93+
for a in test_points
94+
# ensure all complex if any complex for FiniteDifferences
95+
_a, _x = promote(a, x)
96+
test_frule(gamma, _a, _x; rtol=1e-8)
97+
test_rrule(gamma, _a, _x; rtol=1e-8)
98+
99+
test_frule(loggamma, _a, _x)
100+
test_rrule(loggamma, _a, _x)
101+
end
92102

93103
isreal(x) || continue
94104
test_frule(logabsgamma, x)
95105
test_rrule(logabsgamma, x; output_tangent=(randn(), randn()))
106+
for a in test_points
107+
isreal(a) && a > 0 || continue
108+
test_frule(gamma_inc, a, x, 0)
109+
test_rrule(gamma_inc, a, x, 0; output_tangent=(randn(), randn()))
110+
end
96111
end
97112
end
98113
end

0 commit comments

Comments
 (0)