Skip to content

Commit

Permalink
Minor fixes for deprecation warnings in v0.7. (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
tpapp authored and jrevels committed Jun 19, 2018
1 parent abe37e2 commit 16b1b42
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/rules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ end
@define_diffrule Base.:\(x, y) = :( -($y / $x / $x) ), :( inv($x) )
@define_diffrule Base.:^(x, y) = :( $y * ($x^($y - 1)) ), :( ($x^$y) * log($x) )

@define_diffrule Base.atan2(x, y) = :( $y / ($x^2 + $y^2) ), :( -$x / ($x^2 + $y^2) )
if VERSION < v"0.7-"
@define_diffrule Base.atan2(x, y) = :( $y / ($x^2 + $y^2) ), :( -$x / ($x^2 + $y^2) )
else
@define_diffrule Base.atan(x, y) = :( $y / ($x^2 + $y^2) ), :( -$x / ($x^2 + $y^2) )
end
@define_diffrule Base.hypot(x, y) = :( $x / hypot($x, $y) ), :( $y / hypot($x, $y) )
@define_diffrule Base.mod(x, y) = :( first(promote(ifelse(isinteger($x / $y), NaN, 1), NaN)) ), :( z = $x / $y; first(promote(ifelse(isinteger(z), NaN, -floor(z)), NaN)) )
@define_diffrule Base.rem(x, y) = :( first(promote(ifelse(isinteger($x / $y), NaN, 1), NaN)) ), :( z = $x / $y; first(promote(ifelse(isinteger(z), NaN, -trunc(z)), NaN)) )
Expand Down
10 changes: 8 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
using Base.Test
if VERSION < v"0.7-"
using Base.Test
srand(1)
else
using Test
import Random
Random.srand(1)
end
using SpecialFunctions, NaNMath
using DiffRules

srand(1)

function finitediff(f, x)
ϵ = cbrt(eps(typeof(x))) * max(one(typeof(x)), abs(x))
Expand Down

0 comments on commit 16b1b42

Please sign in to comment.