From 44e8f4cee1e92943470272af315c3f4e336d978e Mon Sep 17 00:00:00 2001 From: jverzani Date: Sun, 14 May 2017 22:08:18 -0400 Subject: [PATCH 1/3] call invokelatest in lambdify --- src/subs.jl | 9 +++++++-- test/runtests.jl | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/subs.jl b/src/subs.jl index 33a98d0..5ae1f75 100644 --- a/src/subs.jl +++ b/src/subs.jl @@ -107,9 +107,14 @@ 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)) + if VERSION >= v"0.6.0-rc1" + (args...) -> Base.invokelatest(fn, args...) # https://github.com/JuliaLang/julia/pull/19784 + else + fn + end catch err throw(ArgumentError("Expression does not lambdify")) end diff --git a/test/runtests.jl b/test/runtests.jl index 7e3c846..5222206 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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 From b3526588788d76dd550f19fb775e1c4fce92abfe Mon Sep 17 00:00:00 2001 From: jverzani Date: Mon, 15 May 2017 09:22:44 -0400 Subject: [PATCH 2/3] use compat --- REQUIRE | 2 +- src/subs.jl | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/REQUIRE b/REQUIRE index 36b7a53..b2d880a 100644 --- a/REQUIRE +++ b/REQUIRE @@ -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 diff --git a/src/subs.jl b/src/subs.jl index 5ae1f75..3f83888 100644 --- a/src/subs.jl +++ b/src/subs.jl @@ -110,11 +110,7 @@ function _lambdify(ex::Basic, vars) fn = eval(Expr(:function, Expr(:call, gensym(), map(Symbol,vars)...), body)) - if VERSION >= v"0.6.0-rc1" - (args...) -> Base.invokelatest(fn, args...) # https://github.com/JuliaLang/julia/pull/19784 - else - fn - end + (args...) -> Base.invokelatest(fn, args...) # https://github.com/JuliaLang/julia/pull/19784 catch err throw(ArgumentError("Expression does not lambdify")) end From 47667eae2564fb513d67051e3301bf73cdade2e1 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Mon, 15 May 2017 19:49:31 +0530 Subject: [PATCH 3/3] Import invokelatest from Compat --- src/SymEngine.jl | 2 +- src/subs.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SymEngine.jl b/src/SymEngine.jl index 8b4717b..20d33d6 100644 --- a/src/SymEngine.jl +++ b/src/SymEngine.jl @@ -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 diff --git a/src/subs.jl b/src/subs.jl index 3f83888..e9229ed 100644 --- a/src/subs.jl +++ b/src/subs.jl @@ -110,7 +110,7 @@ function _lambdify(ex::Basic, vars) fn = eval(Expr(:function, Expr(:call, gensym(), map(Symbol,vars)...), body)) - (args...) -> Base.invokelatest(fn, args...) # https://github.com/JuliaLang/julia/pull/19784 + (args...) -> invokelatest(fn, args...) # https://github.com/JuliaLang/julia/pull/19784 catch err throw(ArgumentError("Expression does not lambdify")) end