Ask Your Question
1

Interpreting ints as ints

asked 2012-01-23 13:01:00 +0200

kartikv gravatar image

I am working with a python package called Theano, which has a function called "function" which basically takes in the symbolic representation of a function and compiles it for fast execution on a block of memory either on a CPU or a GPU. When trying to use it in sage, however, it gets a bit flummoxed by the fact that integers and such are interpreted as sage integers, rather than python basic types. Is there a way to (at runtime) turn off that part of the interpreter, so that code doesn't have to be rewritten to work in sage?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2012-01-23 13:26:44 +0200

Jason Grout gravatar image

updated 2012-01-23 13:27:49 +0200

You can turn off the preparser altogether:

sage: type(1)
<type 'sage.rings.integer.Integer'>
sage: preparser(False)
sage: type(1)
<type 'int'>

If you are running sage on a .py file, it should not preparse the file. If it is a .sage file, then preparsing happens by default (but you can turn it off like above, I think).

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2012-01-23 13:01:00 +0200

Seen: 244 times

Last updated: Jan 23 '12