Skip to content

Commit 01a056d

Browse files
authored
Fix ldexp test errors (#568)
1 parent ab0e239 commit 01a056d

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

test/DualTest.jl

+10-11
Original file line numberDiff line numberDiff line change
@@ -444,24 +444,23 @@ for N in (0,3), M in (0,4), V in (Int, Float32)
444444
end
445445
elseif arity == 2
446446
derivs = DiffRules.diffrule(M, f, :x, :y)
447+
x, y = if f === :ldexp
448+
rand(), rand(1:10)
449+
elseif f === :mod
450+
13 + rand(), 5 + rand() # make sure x/y is not an integer
451+
else
452+
rand(1:10), rand()
453+
end
447454
@eval begin
448-
x, y = rand(1:10), rand()
455+
x, y = $x, $y
449456
dx = $M.$f(Dual{TestTag()}(x, one(x)), y)
450457
dy = $M.$f(x, Dual{TestTag()}(y, one(y)))
451458
actualdx = $(derivs[1])
452459
actualdy = $(derivs[2])
453460
@test value(dx) == $M.$f(x, y)
454461
@test value(dy) == value(dx)
455-
if isnan(actualdx)
456-
@test isnan(partials(dx, 1))
457-
else
458-
@test partials(dx, 1) actualdx
459-
end
460-
if isnan(actualdy)
461-
@test isnan(partials(dy, 1))
462-
else
463-
@test partials(dy, 1) actualdy
464-
end
462+
@test partials(dx, 1) actualdx nans=true
463+
@test partials(dy, 1) actualdy nans=true
465464
end
466465
end
467466
end

0 commit comments

Comments
 (0)