Closed jlbosse closed 10 months ago
Yes,
I don't have too much control over that. When called with use_julia_code=true
we just get this back:
julia> expr = a * sin(a)^2 / (2*b)
2
a⋅sin (a)
─────────
2⋅b
julia> sympy.julia_code(expr)
"a.*sin(a).^2./(2*b)"
You can see the lack of spaces produced by sympy. That issue sits with the Python package. If you do not pass in use_julia_code=true
, then the code path chosen is basically this:
julia> convert(Expr, expr)
:((1 / 2) * a * b ^ -1 * sin(a) ^ 2)
Which should work with lambdify
assuming you know the order of the arguments.
Thanks, I guess then there is nothing that can be done (short of opening an issue on the SymPy project) here.
For future users running into this: I am using the approach shown in the documentation in the example block after "More performant functions can be produced using the following patter" together with RuntimeGeneratedFunctions.jl to produce fast julia functions from the results of a sympy calculation.
Lambdifying expressions that involve fractions right after powers fails due to missing spaces in the sympy expression. See the following MWE:
fails with the error message