Skip to content

Commit

Permalink
Resolving issue JuliaMath#61: Expressions evaluated to NaN
Browse files Browse the repository at this point in the history
Changed `!=` to use `!isequal()` to not get stuck in infinite loops with NaN.
Non-trivial test also added that verifies this.
  • Loading branch information
Johan Blåbäck committed Apr 21, 2017
1 parent f7b5556 commit 26a19b2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/symbolic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function simplify(ex::Expr)
return eval(current_module(), ex)
end
new_ex = simplify(SymbolParameter(ex.args[1]), ex.args[2:end])
while new_ex != ex
while !(isequal(new_ex, ex))
new_ex, ex = simplify(new_ex), new_ex
end
return new_ex
Expand Down
2 changes: 2 additions & 0 deletions test/symbolic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ end
@test isequal(simplify(:(x*3*4)), :(*(12,x)))
@test isequal(simplify(:(2*y*x*3)), :(*(6,y,x)))

@test isequal(simplify(:(sin((1*(sin(0/0)))))), NaN)

#
# Tests with ifelse
#
Expand Down

0 comments on commit 26a19b2

Please sign in to comment.