Comments (8)
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.
@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.
@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.
Oops, sorry for the noise @nhannguyen123 and @isuruf . I grepped through a stale version of SymEngine before answering.
from symengine.jl.
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.
@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.
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.
@isuruf @jverzani Thank you. @SymFunction
and @funs
in SymEngine
work now.
from symengine.jl.
Related Issues (20)
- Improvement: Early quitting when computing derivatives
- Segmentation fault and "Trying to print an uninitialized SymEngine Basic variable" when encountering `SymEngine.zoo` HOT 8
- Can't create Add (sums) manually HOT 5
- Implement `//` HOT 2
- Cannot install package via Pkg.add HOT 1
- Is it possible to use something like 1-x:1:10-x HOT 1
- Support macos aarch64 package install HOT 6
- Issues with Saving HOT 1
- Strange isless behavior
- Can't access type of operation HOT 2
- get_name causes a segfault if used with someting other than FunctionSymbol
- not throw error but crash when assign an expression to array HOT 2
- series fails
- Update SymEngine_jll HOT 2
- Serialization don't work with complex data types containing SymEngine expressions
- Make a new release HOT 2
- Regression: Multiplication of `Basic`, `Rational`, and `Vector{Basic}` fails HOT 1
- GCD does not work correctly
- Returning anonymous function when using lambdify instead of using gensym()
- `imag()` and `reim()` gives `InexactError(::Symbol, ::Any, ::Any)`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from symengine.jl.