Git Product home page Git Product logo

Comments (8)

stevengj avatar stevengj commented on June 18, 2024

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.

jverzani avatar jverzani commented on June 18, 2024

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.

stevengj avatar stevengj commented on June 18, 2024

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.

jverzani avatar jverzani commented on June 18, 2024

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.

stevengj avatar stevengj commented on June 18, 2024

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.

jverzani avatar jverzani commented on June 18, 2024

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.

stevengj avatar stevengj commented on June 18, 2024

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.

jverzani avatar jverzani commented on June 18, 2024

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)

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.