Comments (8)
It looks like the problem is that some of the identifiers in the sympy
module are Julia reserved words (e.g. sympy.function
), so that pywrap
has a problem when it tries to declare a datatype with members of those names. I hacked pywrap
to add "__"
to the end of all of the identifiers, and the problem goes away.
I'm not sure which of the identifiers in particular causes the problem yet, or why it gives this strange error message. The general solution would be for pywrap
to add underscores or something (?) to symbols that are reserved words in Julia.
from pycall.jl.
Thanks, but I also need to add these to your reserved words to get it to work out for me:
const reserved_from_base = Set("Dict", "Matrix", "Range", "Rational", "Set", "acos", "acosh", "acot", "acoth", "add", "asin", "asinh", "atan", "atan2", "atanh", "besseli", "besselj", "besselk", "bessely", "beta", "binomial", "collect", "cos", "cosh", "cot", "coth", "csc", "dense", "diag", "diff", "digamma", "div", "erf", "exp", "expand", "expr", "eye", "factor", "factorial", "floor", "gamma", "gcd", "im", "isprime", "lcm", "log", "mod", "nan", "ones", "pi", "prod", "rem", "reshape", "sec", "sign", "sin", "sinh", "solve", "sparse", "sqrt", "symbol", "take", "tan", "tanh", "transpose", "trunc", "var", "zeros", "zeta")
These came from intersecting the member names of the pyimport("sympy") object with the names in Base.
from pycall.jl.
Hmm, on my machine sympy.acot
imported just fine. acot
is not a reserved word in Julia, so it is safe to use it as the name of a member.
On my machine, there is no sympy.Dict
; maybe I'm using a version that is too old? If sympy.Dict
translates to something of type Dict
, that could cause a problem because of Julia issue #2919. Similarly for sympy.Set
and any other member that corresponds to a typename in Base. This seems like a bug in Julia (typenames are not reserved words, and it is possible to use them as member names), but if it takes too long to get fixed I might add them to reserved
as a workaround.
from pycall.jl.
Thanks for looking into this.
I have the following:
o = pyimport("sympy")
members = convert(Vector{(String,PyObject)},
pycall(PyCall.inspect["getmembers"], PyObject,
o))
members[200] ## ("version",PyObject '0.7.2-git')
members[25] ## ("Dict",PyObject <class 'sympy.core.containers.Dict'>)
members[164] ## ("Set",PyObject <class 'sympy.core.sets.Set'>)
0.7.2 is the latest released version from
https://code.google.com/p/sympy/downloads/list
I can do a workaround in my initialization code for my SymPy package. It
will get much less use than yours. All I need to do is modify pywrap and
sympy seems to work fine and remove that when things settle out.
On Tue, Apr 23, 2013 at 1:20 PM, Steven G. Johnson <[email protected]
wrote:
Hmm, on my machine sympy.acot imported just fine. acot is not a reserved
word in Julia, so it is safe to use it as the name of a member.On my machine, there is no sympy.Dict; maybe I'm using a version that is
too old? If sympy.Dict translates to something of type Dict, that could
cause a problem because of Julia issue #2919. Similarly for sympy.Set and
any other member that corresponds to a typename in Base. This seems like a
bug in Julia (typenames are not reserved words, and it is possible to use
them as member names), but if it takes too long to get fixed I might add
them to reserved as a workaround.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/18#issuecomment-16883743
.
John Verzani
Chair, Department of Mathematics
College of Staten Island, CUNY
[email protected]
from pycall.jl.
If you just include the typenames (Dict, Matrix, etcetera) in the reserved words, but not the functions (acos, etc.), does it work?
from pycall.jl.
This combination worked (just adding ,"Dict", "Matrix", "Range",
"Rational", "Set" as suggested).
const reserved = Set("while", "if", "for", "try", "return", "break",
"continue", "function", "macro", "quote", "let",
"local",
"global", "const", "abstract", "typealias", "type",
"bitstype", "immutable", "ccall", "do", "module",
"baremodule", "using", "import", "export", "importall",
"Function"
,"Dict", "Matrix", "Range", "Rational", "Set"
)
On Tue, Apr 23, 2013 at 7:27 PM, Steven G. Johnson <[email protected]
wrote:
If you just include the typenames (Dict, Matrix, etcetera) in the reserved
words, but not the functions (acos, etc.), does it work?—
Reply to this email directly or view it on GitHubhttps://github.com//issues/18#issuecomment-16904893
.
John Verzani
Chair, Department of Mathematics
College of Staten Island, CUNY
[email protected]
from pycall.jl.
I'm guessing you only need Dict
and Matrix
, since the other three types aren't converted into types of the same name (yet).
from pycall.jl.
In fact, it looks like just adding Dict works. Thanks again!
On Wed, Apr 24, 2013 at 7:02 AM, Steven G. Johnson <[email protected]
wrote:
I'm guessing you only need Dict and Matrix, since the other three types
aren't converted into types of the same name (yet).—
Reply to this email directly or view it on GitHubhttps://github.com//issues/18#issuecomment-16931285
.
John Verzani
Chair, Department of Mathematics
College of Staten Island, CUNY
[email protected]
from pycall.jl.
Related Issues (20)
- pytype_mapping confusion
- Building PyCall Offline with Mamba HOT 4
- Convert memory address to Python pointer HOT 3
- notable startup latency HOT 3
- How to detect if Python object is class/function/property
- Incompatible with PythonCall.jl HOT 1
- Pkg.build("PyCall"), json.decoder.JSONDecodeError: Extra data
- ERROR: LoadError: syntax: invalid interpolation syntax: "$\"
- the ENV["PYTHON"]="path/to/python.exe" not work for python3.12.0 HOT 4
- LoadError: Couldn't find libpython while building PyCall HOT 5
- PyCall 1.96.2 breaks tests at Imbalance.jl HOT 5
- Error on building 'PyCall' argument not expected: --satisfied-skip-solve HOT 1
- buildutils.jl broken on Python 3.12 HOT 1
- Remove support for Python <=3.7
- Reproducible garbage collection-related segfaults on Python 3.12 HOT 3
- How can I use rospy through PyCall directly? HOT 1
- julia-1.10.0 _Py_DECREF segmentation faults (not present in 1.9.3)
- `Segmentation fault(core dumped)` when using multiple threads
- REPL crashes when importing pyvista objects
- Howto - Python yield statement HOT 1
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 pycall.jl.