Ask Your Question
0

Can I deactivate block of cells in worksheet?

asked 2015-10-22 13:39:15 +0100

stan gravatar image

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!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2015-10-22 17:01:19 +0100

vdelecroix gravatar image

updated 2015-10-22 17:02:05 +0100

This 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 cell
edit flag offensive delete link more

Comments

1

Wow, I would almost want this as a pull request for sagenb.

kcrisman gravatar imagekcrisman ( 2015-10-23 04:29:11 +0100 )edit

Thanks, 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?

stan gravatar imagestan ( 2015-10-23 08:46:32 +0100 )edit

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-10-22 13:39:15 +0100

Seen: 454 times

Last updated: Oct 22 '15