r-cas / caracas

Computer algebra in R
GNU General Public License v2.0
24 stars 2 forks source link

sympy functions #25

Closed bnicenboim closed 3 years ago

bnicenboim commented 4 years ago

I realize this is not really your "fault", it's something from reticulate but I can't manage to do the following (I'm also trying my luck here https://community.rstudio.com/t/sympy-functions-in-r/70156). Maybe you are more experienced with reticulate and sympy and can give me a solution (and improve your package).

I'm trying to adapt the following python code:

from sympy import Function, Symbol
x = Symbol('x')
f = Function('f')
g = Function('g')(x)
f(x)

It should be something like this

sympy <- caracas::get_sympy()
x <- sympy$Symbol('x')
f <- sympy$Function('f')
g <-  sympy$Function('g')(x)
# Error in py_call_impl(callable, dots$args, dots$keywords) : 
#  TypeError: expected bytes, NoneType found
f(x)
# Error in py_call_impl(callable, dots$args, dots$keywords) : 
#  TypeError: expected bytes, NoneType found

But it seems I need to convert the input of the sympy functions somehow, but I couldn't figure out how.

mikldk commented 4 years ago

Thanks for reporting this. I will have a look and get back.

mikldk commented 4 years ago

It does indeed seem difficult to get this working. I have tried playing around a bit, and I am afraid that I have not been able to find a way to make this possible. Maybe you can try asking at the reticulate package (and cross-reference this)?

GitHunter0 commented 3 years ago

Hey @mikldk , @bnicenboim , this might be a similar issue: https://github.com/rstudio/reticulate/issues/817

mikldk commented 3 years ago

@bnicenboim Do you have any examples of how you will use this? Then we might be able to help out with that.

bnicenboim commented 3 years ago

It was too long ago, I don't remember... probably to create functions. In any case, I started to use directly sympy and export the python objects with py$obj.

mikldk commented 3 years ago

@bnicenboim Ok. You are always welcome to suggest other ways of improving caracas. I'll close this for now.