GithubHelp home page GithubHelp logo

Comments (8)

jverzani avatar jverzani commented on May 28, 2024

As far as I know, this feature is not in SymEngine, but it is in SymPy. In SymPy.jl you have the constructor SymFunction and macro @symfuns (called without a comma).

from symengine.jl.

nhannguyen123 avatar nhannguyen123 commented on May 28, 2024

@jverzani . Thanks. After using SymPy, I can define the symbolic function f

using PyCall
using SymPy
@vars x y
f = SymFunction("f")

However, the next expression

f(x,y)

comes to error

PyError (:PyObject_Call) <class 'sympy.core.sympify.SympifyError'>
SympifyError()
  File "/usr/lib/python2.7/dist-packages/sympy/core/function.py", line 616, in __new__
    args = list(map(sympify, args))
  File "/usr/lib/python2.7/dist-packages/sympy/core/sympify.py", line 315, in sympify
    raise SympifyError('could not parse %r' % a, exc)


 in pyerr_check at /home/nhan/.julia/v0.5/PyCall/src/exception.jl:56 [inlined]
 in pyerr_check at /home/nhan/.julia/v0.5/PyCall/src/exception.jl:61 [inlined]
 in macro expansion at /home/nhan/.julia/v0.5/PyCall/src/exception.jl:81 [inlined]
 in #_pycall#66(::Array{Any,1}, ::Function, ::PyCall.PyObject, ::PyCall.PyObject, ::Vararg{PyCall.PyObject,N}) at /home/nhan/.julia/v0.5/PyCall/src/PyCall.jl:596
 in _pycall(::PyCall.PyObject, ::PyCall.PyObject, ::Vararg{PyCall.PyObject,N}) at /home/nhan/.julia/v0.5/PyCall/src/PyCall.jl:584
 in #pycall#70(::Array{Any,1}, ::Function, ::PyCall.PyObject, ::Type{PyCall.PyAny}, ::PyCall.PyObject, ::Vararg{PyCall.PyObject,N}) at /home/nhan/.julia/v0.5/PyCall/src/PyCall.jl:618
 in pycall(::PyCall.PyObject, ::Type{PyCall.PyAny}, ::PyCall.PyObject, ::Vararg{PyCall.PyObject,N}) at /home/nhan/.julia/v0.5/PyCall/src/PyCall.jl:618
 in #call#71(::Array{Any,1}, ::PyCall.PyObject, ::PyCall.PyObject, ::Vararg{PyCall.PyObject,N}) at /home/nhan/.julia/v0.5/PyCall/src/PyCall.jl:621
 in (::PyCall.PyObject)(::PyCall.PyObject, ::Vararg{PyCall.PyObject,N}) at /home/nhan/.julia/v0.5/PyCall/src/PyCall.jl:621
 in (::SymPy.SymFunction)(::SymEngine.Basic, ::SymEngine.Basic, ::Vararg{SymEngine.Basic,N}) at /home/nhan/.julia/v0.5/SymPy/src/call.jl:15

Could you explain this error? Sorry I'm a newbie in both Python and Julia.

from symengine.jl.

isuruf avatar isuruf commented on May 28, 2024

@nhannguyen123, following should work if you are using the latest version. What version of SymEngine are you using?

using SymEngine
@vars x y
f = SymFunction("f")
@funs g h

from symengine.jl.

jverzani avatar jverzani commented on May 28, 2024

Oops, sorry for the noise @nhannguyen123 and @isuruf . I grepped through a stale version of SymEngine before answering.

from symengine.jl.

isuruf avatar isuruf commented on May 28, 2024

Ah, it seems you need SymEngine master for this. I'll make a release in a few hours.

Oops, sorry for the noise @nhannguyen123 and @isuruf . I grepped through a stale version of SymEngine before answering.

np

from symengine.jl.

nhannguyen123 avatar nhannguyen123 commented on May 28, 2024

@isuruf The versions that I'm using are

PyCall 1.14.0
SymEngine 0.2.0
SymPy 0.5.3
As I have said, after using SymPy I can defined f, g, h as follows
using PyCall
using SymPy
@vars x y
f = SymFunction("f")
@symfuns g h # note that: @funs --> error

However the following code makes error

f(x,y)

If it's because the module I'm using is not the latest, then I will wait for the new release. Thanks.

from symengine.jl.

isuruf avatar isuruf commented on May 28, 2024

SymPy and SymEngine can't interoperate. So you should use either SymPy or SymEngine, not both.

For me, following works. If it doesn't please open an issue at https://github.com/JuliaPy/SymPy.jl

using PyCall
using SymPy
@vars x y
f = SymFunction("f")
@symfuns g h 
f(x,y)

If you want to use SymEngine, you can do

Pkg.checkout("SymEngine")
Pkg.build("SymEngine")

to use the git master. After doing that, you can do,

using SymEngine
@vars x y
f = SymFunction("f")
@funs g h
f(x,y)

from symengine.jl.

nhannguyen123 avatar nhannguyen123 commented on May 28, 2024

@isuruf @jverzani Thank you. @SymFunction and @funs in SymEngine work now.

from symengine.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.