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, 08 Oct 2023 13:05:47 +0200Using polynomial rings in cythonhttps://ask.sagemath.org/question/73656/using-polynomial-rings-in-cython/ Hello,
I have a sage script that is mostly made up of python code, but uses the sage implementation
of polynomial rings in one variable. I have been trying to convert the script to cython to speed
it up, but am getting an error because of the polynomial ring.
The first line of the script is:
> t = ZZ['t'].0
which I am using to create the polynomial ring in the variable 't'. When I change the .sage extension
to .spyx and try to load the file I get the error:
>Syntax error in simple statement list
which points to the second "]" in the line of code.
Is there a simple way to fix this?
Fri, 29 Sep 2023 12:11:51 +0200https://ask.sagemath.org/question/73656/using-polynomial-rings-in-cython/Comment by naf for <p>Hello,</p>
<p>I have a sage script that is mostly made up of python code, but uses the sage implementation
of polynomial rings in one variable. I have been trying to convert the script to cython to speed
it up, but am getting an error because of the polynomial ring.</p>
<p>The first line of the script is:</p>
<blockquote>
<p>t = ZZ['t'].0</p>
</blockquote>
<p>which I am using to create the polynomial ring in the variable 't'. When I change the .sage extension
to .spyx and try to load the file I get the error:</p>
<blockquote>
<p>Syntax error in simple statement list</p>
</blockquote>
<p>which points to the second "]" in the line of code. </p>
<p>Is there a simple way to fix this?</p>
https://ask.sagemath.org/question/73656/using-polynomial-rings-in-cython/?comment=73821#post-id-73821Thank you, that does the job.Sun, 08 Oct 2023 13:05:47 +0200https://ask.sagemath.org/question/73656/using-polynomial-rings-in-cython/?comment=73821#post-id-73821Comment by FrédéricC for <p>Hello,</p>
<p>I have a sage script that is mostly made up of python code, but uses the sage implementation
of polynomial rings in one variable. I have been trying to convert the script to cython to speed
it up, but am getting an error because of the polynomial ring.</p>
<p>The first line of the script is:</p>
<blockquote>
<p>t = ZZ['t'].0</p>
</blockquote>
<p>which I am using to create the polynomial ring in the variable 't'. When I change the .sage extension
to .spyx and try to load the file I get the error:</p>
<blockquote>
<p>Syntax error in simple statement list</p>
</blockquote>
<p>which points to the second "]" in the line of code. </p>
<p>Is there a simple way to fix this?</p>
https://ask.sagemath.org/question/73656/using-polynomial-rings-in-cython/?comment=73667#post-id-73667This syntax is for babies' convenience. Use `t = polygen(QQ, "t")` instead.Sat, 30 Sep 2023 07:52:14 +0200https://ask.sagemath.org/question/73656/using-polynomial-rings-in-cython/?comment=73667#post-id-73667Comment by John Palmieri for <p>Hello,</p>
<p>I have a sage script that is mostly made up of python code, but uses the sage implementation
of polynomial rings in one variable. I have been trying to convert the script to cython to speed
it up, but am getting an error because of the polynomial ring.</p>
<p>The first line of the script is:</p>
<blockquote>
<p>t = ZZ['t'].0</p>
</blockquote>
<p>which I am using to create the polynomial ring in the variable 't'. When I change the .sage extension
to .spyx and try to load the file I get the error:</p>
<blockquote>
<p>Syntax error in simple statement list</p>
</blockquote>
<p>which points to the second "]" in the line of code. </p>
<p>Is there a simple way to fix this?</p>
https://ask.sagemath.org/question/73656/using-polynomial-rings-in-cython/?comment=73664#post-id-73664If you mean that `sage x.spyx` fails, then look at what happens when you did `sage x.sage`: it created a file called `x.sage.py`. Try renaming that file as `x.spyx`. Does it work better?Sat, 30 Sep 2023 00:35:11 +0200https://ask.sagemath.org/question/73656/using-polynomial-rings-in-cython/?comment=73664#post-id-73664Comment by John Palmieri for <p>Hello,</p>
<p>I have a sage script that is mostly made up of python code, but uses the sage implementation
of polynomial rings in one variable. I have been trying to convert the script to cython to speed
it up, but am getting an error because of the polynomial ring.</p>
<p>The first line of the script is:</p>
<blockquote>
<p>t = ZZ['t'].0</p>
</blockquote>
<p>which I am using to create the polynomial ring in the variable 't'. When I change the .sage extension
to .spyx and try to load the file I get the error:</p>
<blockquote>
<p>Syntax error in simple statement list</p>
</blockquote>
<p>which points to the second "]" in the line of code. </p>
<p>Is there a simple way to fix this?</p>
https://ask.sagemath.org/question/73656/using-polynomial-rings-in-cython/?comment=73663#post-id-73663What do you mean by "load" the file? If I call the file `x.spyx` and do `%load x.spyx` in a Sage session, it works fine.Sat, 30 Sep 2023 00:33:07 +0200https://ask.sagemath.org/question/73656/using-polynomial-rings-in-cython/?comment=73663#post-id-73663