diff --git a/Project.toml b/Project.toml index 0bdcbb9..7cfa566 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "SymPyCore" uuid = "458b697b-88f0-4a86-b56b-78b75cfb3531" authors = ["jverzani and contributors"] -version = "0.2.8" +version = "0.2.9" [deps] CommonEq = "3709ef60-1bee-4518-9f2f-acd86f176c50" diff --git a/src/lambdify.jl b/src/lambdify.jl index e537c99..12520a5 100644 --- a/src/lambdify.jl +++ b/src/lambdify.jl @@ -191,7 +191,9 @@ sympy_fn_julia_fn = Dict( const fn_map = Dict(k => last(v) for (k,v) ∈ pairs(sympy_fn_julia_fn)) -map_fn(key, fn_map) = haskey(fn_map, key) ? fn_map[key] : Symbol(key) +map_fn(key, fn_map) = haskey(fn_map, key) ? fn_map[key] : + isdefined(@__MODULE__, Symbol(key)) ? Symbol(key) : + error("Lambdify doesn't know what to do with $key. Sorry.") ## @@ -272,8 +274,10 @@ function walk_expression(ex; values=Dict(), fns=Dict()) return vals_map[fn] end + fn′ = map_fn(fn, fns_map) + as = args(ex) - Expr(:call, map_fn(fn, fns_map), [walk_expression(a, values=values, fns=fns) for a in as]...) + Expr(:call, fn′, [walk_expression(a, values=values, fns=fns) for a in as]...) end """