First time here? Check out the FAQ!

Ask Your Question
0

Cython: undeclared name not builtin

asked 5 years ago

Bob67846 gravatar image

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?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 5 years ago

nbruin gravatar image

updated 5 years ago

It 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 RootSystem
Preview: (hide)
link

Comments

Thanks, this was helpful - the right answer is

from sage.all import RootSystem
Bob67846 gravatar imageBob67846 ( 5 years ago )
3

If 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.

nbruin gravatar imagenbruin ( 5 years ago )

Sorry 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 RootSystem
Bob67846 gravatar imageBob67846 ( 5 years ago )

... and that's exactly what you meant. Woops!

Bob67846 gravatar imageBob67846 ( 5 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 5 years ago

Seen: 3,367 times

Last updated: Jan 04 '20