Skip to content

Commit

Permalink
added tests for isinf
Browse files Browse the repository at this point in the history
  • Loading branch information
jrevels committed Sep 18, 2015
1 parent fb1193b commit d59a0cf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion test/test_gradients.jl
Expand Up @@ -97,8 +97,12 @@ for (test_partials, Grad) in ((test_partialstup, ForwardDiff.GradNumTup), (test_
@test isconstant(const_grad) && isreal(const_grad)
@test isconstant(zero(not_const_grad)) && isreal(zero(not_const_grad))

inf_grad = Grad{N,T}(Inf)
@test isfinite(test_grad) && isfinite(test_val)
@test !isfinite(Grad{N,T}(Inf))
@test !(isfinite(inf_grad))

@test isinf(inf_grad)
@test !(isinf(test_grad))

@test isless(test_grad-1, test_grad)
@test isless(test_val-1, test_grad)
Expand Down
6 changes: 5 additions & 1 deletion test/test_hessians.jl
Expand Up @@ -112,8 +112,12 @@ not_const_hess = HessianNumber(GradientNumber(one(T), map(one, test_partials)))
@test isconstant(const_hess) && isreal(const_hess)
@test isconstant(zero(not_const_hess)) && isreal(zero(not_const_hess))

inf_hess = HessianNumber{N,T,C}(Inf)
@test isfinite(test_hess) == isfinite(test_val)
@test !isfinite(HessianNumber{N,T,C}(Inf))
@test !isfinite(inf_hess)

@test isinf(inf_hess)
@test !(isinf(test_hess))

@test isless(test_hess-1, test_hess)
@test isless(test_val-1, test_hess)
Expand Down
6 changes: 5 additions & 1 deletion test/test_tensors.jl
Expand Up @@ -126,8 +126,12 @@ not_const_tens = TensorNumber(HessianNumber(GradientNumber(one(T), map(one, test
@test isconstant(const_tens) && isreal(const_tens)
@test isconstant(zero(not_const_tens)) && isreal(zero(not_const_tens))

inf_tens = TensorNumber{N,T,C}(Inf)
@test isfinite(test_tens) == isfinite(test_val)
@test !isfinite(TensorNumber{N,T,C}(Inf))
@test !isfinite(inf_tens)

@test isinf(inf_tens)
@test !(isinf(test_tens))

@test isless(test_tens-1, test_tens)
@test isless(test_val-1, test_tens)
Expand Down

0 comments on commit d59a0cf

Please sign in to comment.