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.Sat, 01 Oct 2016 22:43:02 +0200Is there a command like Mathematica's Dynamic[] in Sage?https://ask.sagemath.org/question/34977/is-there-a-command-like-mathematicas-dynamic-in-sage/I'm on a Mac with OS 10.11.6 and I'm using Sage 7.2's notebook interface. I did things in Mathematica that I want to check in Sage, but I'm a beginner at Sage. In Mathematica it's possible to keep track of the execution of my code, especially to detect when it's hanging, by using the Mathematica Dynamic[] command. Is there anything like this command in Sage, or is there perhaps another way to track the progress of the execution of a lengthy computation that will let me know in real time if and when it hangs? At the moment I insert print commands in my code that result in thousands of tuples of values of a tuple of variables streaming vertically down my screen. Messy. I'd rather see the values of such a tuple simply update in place as they do, say, on a digital clock. (This is what Dynamic[] achieves in Mathematica.)Wed, 28 Sep 2016 05:34:44 +0200https://ask.sagemath.org/question/34977/is-there-a-command-like-mathematicas-dynamic-in-sage/Comment by Mafra for <p>I'm on a Mac with OS 10.11.6 and I'm using Sage 7.2's notebook interface. I did things in Mathematica that I want to check in Sage, but I'm a beginner at Sage. In Mathematica it's possible to keep track of the execution of my code, especially to detect when it's hanging, by using the Mathematica Dynamic[] command. Is there anything like this command in Sage, or is there perhaps another way to track the progress of the execution of a lengthy computation that will let me know in real time if and when it hangs? At the moment I insert print commands in my code that result in thousands of tuples of values of a tuple of variables streaming vertically down my screen. Messy. I'd rather see the values of such a tuple simply update in place as they do, say, on a digital clock. (This is what Dynamic[] achieves in Mathematica.)</p>
https://ask.sagemath.org/question/34977/is-there-a-command-like-mathematicas-dynamic-in-sage/?comment=34997#post-id-34997There is a "profiling" section in the tutorial http://doc.sagemath.org/pdf/en/tutorial/SageTutorial.pdf which could be helpful.Fri, 30 Sep 2016 13:17:21 +0200https://ask.sagemath.org/question/34977/is-there-a-command-like-mathematicas-dynamic-in-sage/?comment=34997#post-id-34997Answer by tmonteil for <p>I'm on a Mac with OS 10.11.6 and I'm using Sage 7.2's notebook interface. I did things in Mathematica that I want to check in Sage, but I'm a beginner at Sage. In Mathematica it's possible to keep track of the execution of my code, especially to detect when it's hanging, by using the Mathematica Dynamic[] command. Is there anything like this command in Sage, or is there perhaps another way to track the progress of the execution of a lengthy computation that will let me know in real time if and when it hangs? At the moment I insert print commands in my code that result in thousands of tuples of values of a tuple of variables streaming vertically down my screen. Messy. I'd rather see the values of such a tuple simply update in place as they do, say, on a digital clock. (This is what Dynamic[] achieves in Mathematica.)</p>
https://ask.sagemath.org/question/34977/is-there-a-command-like-mathematicas-dynamic-in-sage/?answer=35011#post-id-35011Sage in written in Python, so you can benefit of any good things from it. Searching a couple of seconds on the web led me to the following:
sage: from time import sleep
sage: from sys import stdout
sage: for i in range(10):
....: stdout.write("\rDoing thing %i" % i)
....: stdout.flush()
....: sleep(1)
There might even be dedicated libraries.Sat, 01 Oct 2016 20:08:04 +0200https://ask.sagemath.org/question/34977/is-there-a-command-like-mathematicas-dynamic-in-sage/?answer=35011#post-id-35011Comment by paulmasson for <p>Sage in written in Python, so you can benefit of any good things from it. Searching a couple of seconds on the web led me to the following:</p>
<pre><code>sage: from time import sleep
sage: from sys import stdout
sage: for i in range(10):
....: stdout.write("\rDoing thing %i" % i)
....: stdout.flush()
....: sleep(1)
</code></pre>
<p>There might even be dedicated libraries.</p>
https://ask.sagemath.org/question/34977/is-there-a-command-like-mathematicas-dynamic-in-sage/?comment=35018#post-id-35018This is fine for the command line, but not effective in the notebook. Output on `stdout` is appended to the cell rather than replacing its contents.Sat, 01 Oct 2016 21:49:33 +0200https://ask.sagemath.org/question/34977/is-there-a-command-like-mathematicas-dynamic-in-sage/?comment=35018#post-id-35018Comment by tmonteil for <p>Sage in written in Python, so you can benefit of any good things from it. Searching a couple of seconds on the web led me to the following:</p>
<pre><code>sage: from time import sleep
sage: from sys import stdout
sage: for i in range(10):
....: stdout.write("\rDoing thing %i" % i)
....: stdout.flush()
....: sleep(1)
</code></pre>
<p>There might even be dedicated libraries.</p>
https://ask.sagemath.org/question/34977/is-there-a-command-like-mathematicas-dynamic-in-sage/?comment=35023#post-id-35023Hmm, indeed. It works in the jupyter notebook however.Sat, 01 Oct 2016 22:43:02 +0200https://ask.sagemath.org/question/34977/is-there-a-command-like-mathematicas-dynamic-in-sage/?comment=35023#post-id-35023