Skip to content

Commit

Permalink
avoid Order in lambdify, close #402 (#403)
Browse files Browse the repository at this point in the history
* avoid Order in lambdify

* version bump
  • Loading branch information
jverzani authored Jan 9, 2021
1 parent 3a292f5 commit 56c66bb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "SymPy"
uuid = "24249f21-da20-56a4-8eb1-6a02cf4ae2e6"
version = "1.0.37"
version = "1.0.38"


[deps]
Expand Down
9 changes: 4 additions & 5 deletions src/lambdify.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export __prod__
fn_map = Dict(
"Add" => :+,
"Sub" => :-,
"Mul" => :__prod__, # :* can now be used
"Mul" => :((as...)->prod(as)), #:__prod__, # :* can now be used
"Div" => :/,
"Pow" => :^,
"re" => :real,
Expand All @@ -49,8 +49,8 @@ fn_map = Dict(
"Min" => :min,
"Max" => :max,
"Poly" => :identity,
"Heaviside" => :(_heaviside),
"Piecewise" => :(_piecewise),
"Order" => :((xs...)->0),
"And" => :(&),
"Or" => :(|),
"Less" => :(<),
Expand All @@ -61,8 +61,8 @@ fn_map = Dict(
"Unequality" => :(!==),
"StrictGreaterThan" => :(>),
"GreaterThan" => :(>=),
"Greater" => :(>),
"conjugate" => :conj
"Greater" => :(>),
"conjugate" => :conj
)

map_fn(key, fn_map) = haskey(fn_map, key) ? fn_map[key] : Symbol(key)
Expand Down Expand Up @@ -102,7 +102,6 @@ function walk_expression(ex; values=Dict(), fns=Dict())
end

as = Introspection.args(ex)

Expr(:call, map_fn(fn, fns_map), [walk_expression(a, values=values, fns=fns) for a in as]...)
end

Expand Down
5 changes: 5 additions & 0 deletions test/tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,11 @@ end
fn1 = Lambda(x, ex)
fn2 = lambdify(ex)
@test fn1(3) == fn2(3)

## issue 402 with lamdify and Order
@vars x
t = series(exp(x), x, 0, 2)
@test lambdify(t)(1/2) == 1 + 1/2
end

@testset "generic programming, issue 223" begin
Expand Down

2 comments on commit 56c66bb

@jverzani
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/27615

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.38 -m "<description of version>" 56c66bb71538594ef55136d6b6de03e0d50f4cc0
git push origin v1.0.38

Please sign in to comment.