Ask Your Question
1

Cell label reset

asked 2017-12-28 11:59:31 +0100

danielvolinski gravatar image

What is the proper way to reset the cell number in a notebook cell? When I evaluate all the cells of a notebook I want to always start with the number In[1] as the first cell label of the notebook in order to have a predictable number of all the subsequent cells, something like kill(labels) in Maxima.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2017-12-28 16:15:16 +0100

vdelecroix gravatar image

updated 2017-12-28 16:17:42 +0100

In Jupyter, the number on the left are not the number of the cells but the order in the execution. IPython has the very same behavior

$ sage -ipython
Python 2.7.14 (default, Dec 13 2017, 23:18:38) 
Type "copyright", "credits" or "license" for more information.

IPython 5.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: 1+1
Out[1]: 2

In [2]: 3+5
Out[2]: 8

In [3]:

But in a console as above, you are not allowed to edit the input lines as you would do with cells in a notebook.

The proper way to reinitialize the execution of the kernel (and hence starting again from 1) is to do Kernel -> Restart.

edit flag offensive delete link more

Comments

What I want is a command in a Sage Notebook cell that will make the next cell executed to be In[1]

danielvolinski gravatar imagedanielvolinski ( 2017-12-28 18:19:20 +0100 )edit

First of all, I assume that you are using the Jupyter notebook since the legacy Sage notebook does not have any numbering for its cell (at least that are visible). As I wrote at the end of my answer you should use Kernel -> Restart.

vdelecroix gravatar imagevdelecroix ( 2017-12-28 18:59:29 +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: 2017-12-28 11:59:31 +0100

Seen: 430 times

Last updated: Dec 28 '17