-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
W2Julia expects an Expr, not a WExpr. #85
Comments
Hi @L2Fish:
Some examples or tests that will evaluate to true: using Test
@test W2Julia(W`{1,2,3}`) == [1,2,3]
@test W2Julia([1,2,3]) == [1,2,3]
@test W2Julia(W`{1,2,3}`) == [1,2,3]
@test W2Julia(W`{1,a,{1,2}}`) == [1,W"a",[1,2]]
@test W2Julia([.1,W`{1,a,3}`]) == [.1,[1,W"a",3]]
@test W2Julia(Dict( 1 => "A" , "B" => 2)) ==Dict( 1 => "A" , "B" => 2)
@test W2Julia(W`Association["A" -> "B", "C" -> "D"]`) == Dict( "A" => "B" , "C" => "D")
@test W2Julia(W`Association["A" -> {1,a,3}, "B" -> "C"]`) == Dict( "A" => [1,W"a",3] , "B" => "C")
Can you give an example test case of how you would like |
as described here |
@L2Fish I see what you want. I have now taken the first step and renamed Below are some of the tests documenting its usage @test W2JuliaExpr(W`a+b`) == :(a+b)
@test W2JuliaExpr(W`a*b`) == :(a*b)
@test W2JuliaExpr(W`Sin[a]`) == :(sin(a))
@test W2JuliaExpr(W`Sin[a+b]`) == :(sin(a+b))
@test W2JuliaExpr(W`Cos[a^b]`) == :(cos(a^b))
@test W2JuliaExpr(W`a/b`) == :(a*(b^-1))
@test W2JuliaExpr(W`a^b`) == :(a^b)
@test W2JuliaExpr(W`Exp[a]`) == :(exp(a)) I seems good to also do the second step and introduce the functions. Stay tuned. |
believe that MathLink.jl will perform better. |
I looked into it and i'm not sure how much automation one really wants to build in here. One can in principle build a function that automatically detects all the argument as creates a function for it. However, it seems to me that the user would need to know what the argument are in ny case in order to be able to sue it properly, and the code do construct such a functin is also a short oneliner : ex = W2JuliaExpr(W`Sin[a]`)
fun = @eval (a) -> $ex
@test fun(0) == sin(0)
@test fun(1) == sin(1) I'm thinking wrapping the |
you're right. |
W2Julia expects an Expr to be returned, not WExpr.
or use W2JuliaExpr instead
add Expr2Fcn to convert WExpr into a usable function.
The text was updated successfully, but these errors were encountered: