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.Tue, 23 Jun 2020 12:45:24 +0200Why does implicit multiplication not work in the Sage Cell Server?https://ask.sagemath.org/question/52060/why-does-implicit-multiplication-not-work-in-the-sage-cell-server/Hello, Sage Community!
Is there any reason for `implicit_multiplication(True)` not having any effect in SageCell? Is there any way of solving this?
Thanks in advance for your answers! Wed, 17 Jun 2020 22:37:41 +0200https://ask.sagemath.org/question/52060/why-does-implicit-multiplication-not-work-in-the-sage-cell-server/Answer by tmonteil for <p>Hello, Sage Community!</p>
<p>Is there any reason for <code>implicit_multiplication(True)</code> not having any effect in SageCell? Is there any way of solving this?</p>
<p>Thanks in advance for your answers! </p>
https://ask.sagemath.org/question/52060/why-does-implicit-multiplication-not-work-in-the-sage-cell-server/?answer=52062#post-id-52062I think this is not specific to SageCell. It is the same in jupyter. `implicit_multiplication` changes the behaviour of the preparser, but the whole cell is preparsed according to the previous state of the preparser.
If, in a single cell, you write:
implicit_multiplication(True)
2x
You will get an error. But if you put the two lines in different cells, then it will work.
To take another example, you can do:
preparser(False)
type(1)
You will get `<class 'sage.rings.integer.Integer'>` because the whole cell was preparsed before the preparser is turned off. If you put the two lines in two different cells, you will get `<class 'int'>`, because the second line will not be preparsed anymore.
About the Sage preparser, see https://doc.sagemath.org/html/en/reference/repl/sage/repl/preparse.html
The sagecell works like a single jupyter cell.Thu, 18 Jun 2020 02:08:40 +0200https://ask.sagemath.org/question/52060/why-does-implicit-multiplication-not-work-in-the-sage-cell-server/?answer=52062#post-id-52062Comment by dsejas for <p>I think this is not specific to SageCell. It is the same in jupyter. <code>implicit_multiplication</code> changes the behaviour of the preparser, but the whole cell is preparsed according to the previous state of the preparser.</p>
<p>If, in a single cell, you write:</p>
<pre><code>implicit_multiplication(True)
2x
</code></pre>
<p>You will get an error. But if you put the two lines in different cells, then it will work.</p>
<p>To take another example, you can do:</p>
<pre><code>preparser(False)
type(1)
</code></pre>
<p>You will get <code><class 'sage.rings.integer.Integer'></code> because the whole cell was preparsed before the preparser is turned off. If you put the two lines in two different cells, you will get <code><class 'int'></code>, because the second line will not be preparsed anymore.</p>
<p>About the Sage preparser, see <a href="https://doc.sagemath.org/html/en/reference/repl/sage/repl/preparse.html">https://doc.sagemath.org/html/en/refe...</a></p>
<p>The sagecell works like a single jupyter cell.</p>
https://ask.sagemath.org/question/52060/why-does-implicit-multiplication-not-work-in-the-sage-cell-server/?comment=52149#post-id-52149Hello, @tmonteil! I see. Is there any possible tweak for using implicit multiplication in Sage Cell? Or is this a definitive unavoidable behavior?Mon, 22 Jun 2020 18:46:12 +0200https://ask.sagemath.org/question/52060/why-does-implicit-multiplication-not-work-in-the-sage-cell-server/?comment=52149#post-id-52149Comment by tmonteil for <p>I think this is not specific to SageCell. It is the same in jupyter. <code>implicit_multiplication</code> changes the behaviour of the preparser, but the whole cell is preparsed according to the previous state of the preparser.</p>
<p>If, in a single cell, you write:</p>
<pre><code>implicit_multiplication(True)
2x
</code></pre>
<p>You will get an error. But if you put the two lines in different cells, then it will work.</p>
<p>To take another example, you can do:</p>
<pre><code>preparser(False)
type(1)
</code></pre>
<p>You will get <code><class 'sage.rings.integer.Integer'></code> because the whole cell was preparsed before the preparser is turned off. If you put the two lines in two different cells, you will get <code><class 'int'></code>, because the second line will not be preparsed anymore.</p>
<p>About the Sage preparser, see <a href="https://doc.sagemath.org/html/en/reference/repl/sage/repl/preparse.html">https://doc.sagemath.org/html/en/refe...</a></p>
<p>The sagecell works like a single jupyter cell.</p>
https://ask.sagemath.org/question/52060/why-does-implicit-multiplication-not-work-in-the-sage-cell-server/?comment=52178#post-id-52178I doubt there is an easy way without modifying sagecell (or running your own).Tue, 23 Jun 2020 12:45:24 +0200https://ask.sagemath.org/question/52060/why-does-implicit-multiplication-not-work-in-the-sage-cell-server/?comment=52178#post-id-52178