ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 05 Jan 2020 02:20:41 +0100Cython: undeclared name not builtinhttps://ask.sagemath.org/question/49341/cython-undeclared-name-not-builtin/Loading a .spyx file with
def bla(W):
RootSystem(W.cartan_type())
yields
undeclared name not builtin: RootSystem
Is there a library that I need to include?Fri, 03 Jan 2020 17:32:28 +0100https://ask.sagemath.org/question/49341/cython-undeclared-name-not-builtin/Answer by nbruin for <p>Loading a .spyx file with</p>
<pre><code> def bla(W):
RootSystem(W.cartan_type())
</code></pre>
<p>yields</p>
<pre><code>undeclared name not builtin: RootSystem
</code></pre>
<p>Is there a library that I need to include?</p>
https://ask.sagemath.org/question/49341/cython-undeclared-name-not-builtin/?answer=49345#post-id-49345It looks like you should:
sage: import_statements(RootSystem)
from sage.combinat.root_system.root_system import RootSystem
As you can see in the documentation of `import_statements`, it tries to find out from where the symbol requested should be imported and returns a string that describes a command to do that import. So, in your case, it suggests to use
from sage.combinat.root_system.root_system import RootSystemFri, 03 Jan 2020 20:11:49 +0100https://ask.sagemath.org/question/49341/cython-undeclared-name-not-builtin/?answer=49345#post-id-49345Comment by Bob67846 for <p>It looks like you should:</p>
<pre><code>sage: import_statements(RootSystem)
from sage.combinat.root_system.root_system import RootSystem
</code></pre>
<p>As you can see in the documentation of <code>import_statements</code>, it tries to find out from where the symbol requested should be imported and returns a string that describes a command to do that import. So, in your case, it suggests to use</p>
<pre><code>from sage.combinat.root_system.root_system import RootSystem
</code></pre>
https://ask.sagemath.org/question/49341/cython-undeclared-name-not-builtin/?comment=49346#post-id-49346Thanks, this was helpful - the right answer is
from sage.all import RootSystemFri, 03 Jan 2020 21:11:55 +0100https://ask.sagemath.org/question/49341/cython-undeclared-name-not-builtin/?comment=49346#post-id-49346Comment by nbruin for <p>It looks like you should:</p>
<pre><code>sage: import_statements(RootSystem)
from sage.combinat.root_system.root_system import RootSystem
</code></pre>
<p>As you can see in the documentation of <code>import_statements</code>, it tries to find out from where the symbol requested should be imported and returns a string that describes a command to do that import. So, in your case, it suggests to use</p>
<pre><code>from sage.combinat.root_system.root_system import RootSystem
</code></pre>
https://ask.sagemath.org/question/49341/cython-undeclared-name-not-builtin/?comment=49348#post-id-49348If you check the contents of `sage.all`, you'll see that it consists entirely of imports from other modules. There is something to say for importing symbols from their original location, which is why `import_statements` traces the import to its actual origin. I wouldn't say the import from `sage.all` is *wrong* but it's definitely not *the* right answer.Sat, 04 Jan 2020 04:42:34 +0100https://ask.sagemath.org/question/49341/cython-undeclared-name-not-builtin/?comment=49348#post-id-49348Comment by Bob67846 for <p>It looks like you should:</p>
<pre><code>sage: import_statements(RootSystem)
from sage.combinat.root_system.root_system import RootSystem
</code></pre>
<p>As you can see in the documentation of <code>import_statements</code>, it tries to find out from where the symbol requested should be imported and returns a string that describes a command to do that import. So, in your case, it suggests to use</p>
<pre><code>from sage.combinat.root_system.root_system import RootSystem
</code></pre>
https://ask.sagemath.org/question/49341/cython-undeclared-name-not-builtin/?comment=49364#post-id-49364Sorry I'm new to this, but `import_statements(RootSystem)` didn't seem to work for Cython - I suppose the "right" answer might then be
from sage.combinat.root_system.root_system import RootSystemSat, 04 Jan 2020 22:15:51 +0100https://ask.sagemath.org/question/49341/cython-undeclared-name-not-builtin/?comment=49364#post-id-49364Comment by Bob67846 for <p>It looks like you should:</p>
<pre><code>sage: import_statements(RootSystem)
from sage.combinat.root_system.root_system import RootSystem
</code></pre>
<p>As you can see in the documentation of <code>import_statements</code>, it tries to find out from where the symbol requested should be imported and returns a string that describes a command to do that import. So, in your case, it suggests to use</p>
<pre><code>from sage.combinat.root_system.root_system import RootSystem
</code></pre>
https://ask.sagemath.org/question/49341/cython-undeclared-name-not-builtin/?comment=49369#post-id-49369... and that's exactly what you meant. Woops!Sun, 05 Jan 2020 02:20:41 +0100https://ask.sagemath.org/question/49341/cython-undeclared-name-not-builtin/?comment=49369#post-id-49369