ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 23 Oct 2015 01:46:32 -0500Can I deactivate block of cells in worksheet?http://ask.sagemath.org/question/30216/can-i-deactivate-block-of-cells-in-worksheet/I have a worksheet where I first derive a bunch of equation and then use these equations for numerical computations and plotting. If I open the worksheet and want to run a new numerical computation using the same equations, I need to evaluate all the cells at the beginning of the notebook and then I can write my new numerical code and evaluate the new cell. To avoid going through each single cell and pressing Alt+Enter to evaluate, I'd like to use "Evaluate all" from the notebook menu, but this also evaluates all my other numerical cells, which takes an awful long time. Is there a way to 'deactivate' a block of cells in the worksheet, e.g. by turning them into a text block in the worksheet editing environment?
I was thinking about putting <html> before and <\html> after the cells but this did not work. Thanks for your help!Thu, 22 Oct 2015 06:39:15 -0500http://ask.sagemath.org/question/30216/can-i-deactivate-block-of-cells-in-worksheet/Answer by vdelecroix for <p>I have a worksheet where I first derive a bunch of equation and then use these equations for numerical computations and plotting. If I open the worksheet and want to run a new numerical computation using the same equations, I need to evaluate all the cells at the beginning of the notebook and then I can write my new numerical code and evaluate the new cell. To avoid going through each single cell and pressing Alt+Enter to evaluate, I'd like to use "Evaluate all" from the notebook menu, but this also evaluates all my other numerical cells, which takes an awful long time. Is there a way to 'deactivate' a block of cells in the worksheet, e.g. by turning them into a text block in the worksheet editing environment? </p>
<p>I was thinking about putting <html> before and <\html> after the cells but this did not work. Thanks for your help!</p>
http://ask.sagemath.org/question/30216/can-i-deactivate-block-of-cells-in-worksheet/?answer=30222#post-id-30222This is one way to choose the behavior of your cells
Create a custom class whose method eval does what you want with the input and instanciate it
class LazyCell(object):
def eval(self, *args, **kwds):
return "ignored cell"
lazy_cell = LazyCell()
You can now use it in any cell
%lazy_cell
This cell will be ignored... and I can do whatever I want in it
And the output will simply be the result of **eval**....
ignored cellThu, 22 Oct 2015 10:01:19 -0500http://ask.sagemath.org/question/30216/can-i-deactivate-block-of-cells-in-worksheet/?answer=30222#post-id-30222Comment by stan for <p>This is one way to choose the behavior of your cells</p>
<p>Create a custom class whose method eval does what you want with the input and instanciate it</p>
<pre><code>class LazyCell(object):
def eval(self, *args, **kwds):
return "ignored cell"
lazy_cell = LazyCell()
</code></pre>
<p>You can now use it in any cell</p>
<pre><code>%lazy_cell
This cell will be ignored... and I can do whatever I want in it
</code></pre>
<p>And the output will simply be the result of <strong>eval</strong>....</p>
<pre><code>ignored cell
</code></pre>
http://ask.sagemath.org/question/30216/can-i-deactivate-block-of-cells-in-worksheet/?comment=30239#post-id-30239Thanks, this is an elegant way for single cells, but is there a way to do something for a group of cells? I would like to temporarily ignore a hundred cells, so I'd need to put some line into the worksheet code at the appropriate place to ignore everything after that line or between two particular lines that I put in. This is why I was looking at going via the "Edit" button and the text interface. Ideally, I'd would like to comment out a whole bunch of lines in the text interface. Is this possible at all?Fri, 23 Oct 2015 01:46:32 -0500http://ask.sagemath.org/question/30216/can-i-deactivate-block-of-cells-in-worksheet/?comment=30239#post-id-30239Comment by kcrisman for <p>This is one way to choose the behavior of your cells</p>
<p>Create a custom class whose method eval does what you want with the input and instanciate it</p>
<pre><code>class LazyCell(object):
def eval(self, *args, **kwds):
return "ignored cell"
lazy_cell = LazyCell()
</code></pre>
<p>You can now use it in any cell</p>
<pre><code>%lazy_cell
This cell will be ignored... and I can do whatever I want in it
</code></pre>
<p>And the output will simply be the result of <strong>eval</strong>....</p>
<pre><code>ignored cell
</code></pre>
http://ask.sagemath.org/question/30216/can-i-deactivate-block-of-cells-in-worksheet/?comment=30237#post-id-30237Wow, I would almost want this as a pull request for sagenb.Thu, 22 Oct 2015 21:29:11 -0500http://ask.sagemath.org/question/30216/can-i-deactivate-block-of-cells-in-worksheet/?comment=30237#post-id-30237