Skip to content

Commit

Permalink
Merge pull request #90 from jverzani/invokelatest
Browse files Browse the repository at this point in the history
call invokelatest in lambdify
  • Loading branch information
isuruf authored May 16, 2017
2 parents 093e525 + 47667ea commit bbcec5d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
julia 0.4
Compat 0.9.5
Compat 0.25.0
RecipesBase 0.0.6
BinDeps 0.4.0
Conda 0.4.0
2 changes: 1 addition & 1 deletion src/SymEngine.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ __precompile__()
module SymEngine

import Base: show, convert, real, imag
import Compat: String, unsafe_string, @compat, denominator, numerator
import Compat: String, unsafe_string, @compat, denominator, numerator, invokelatest

export Basic, symbols, @vars
export free_symbols, get_args
Expand Down
5 changes: 3 additions & 2 deletions src/subs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,10 @@ function _lambdify(ex::Basic, vars)
body = walk_expression(ex)

try
eval(Expr(:function,
fn = eval(Expr(:function,
Expr(:call, gensym(), map(Symbol,vars)...),
body))
body))
(args...) -> invokelatest(fn, args...) # https://github.com/JuliaLang/julia/pull/19784
catch err
throw(ArgumentError("Expression does not lambdify"))
end
Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ for val in samples
fn = lambdify(ex)
@test norm(fn(val) - sin(2*val)) <= 1e-14
end
@test lambdify(x^2)(3) == 9

## N
for val in samples
Expand Down

0 comments on commit bbcec5d

Please sign in to comment.