Skip to content
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

Extract Julia code from SymPy expression? #198

Closed
dpsanders opened this issue Nov 15, 2017 · 5 comments
Closed

Extract Julia code from SymPy expression? #198

dpsanders opened this issue Nov 15, 2017 · 5 comments

Comments

@dpsanders
Copy link

Is there a way of extracting the Julia code from a SymPy expression, i.e. what lambdify does but returning the Julia source code for the body of the function, instead of the anonymous function itself?

@mzaffalon
Copy link
Contributor

mzaffalon commented Nov 15, 2017

Is what you want fn defined at https://github.com/JuliaPy/SymPy.jl/blob/master/src/lambdify.jl#L150? The following line returns the anonymous function.

@dpsanders
Copy link
Author

Thanks it looks like sympy_meth(:julia_code, s) is actually what I was looking for.

@asmeurer
Copy link

SymPy also has a built in Julia code generator https://github.com/sympy/sympy/blob/master/sympy/printing/julia.py

@ccmejia
Copy link

ccmejia commented Jun 15, 2020

SymPy also has a built in Julia code generator https://github.com/sympy/sympy/blob/master/sympy/printing/julia.py

I’ve been trying whit julia_code generator but it seems that I must should do something before:
UndefVarError: julia_code not defined
:(

@jverzani
Copy link
Collaborator

This is in the lambdify code defn:

body = Meta.parse(sympy.julia_code(ex))

We don't actually use it unless asked, as there had been issues with a few things.

If that isn't what you are lookiing for, please re-open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants