Renumber cells for nbconvert

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

Renumber cells for nbconvert

Jon Wilson
Hi,
We often share around nbconverted notebooks in my research group. But,
it is difficult to refer (when in a phone meeting) to specific figures
or pieces of code or other output in the notebook.  This is because the
cells are often executed out of order, so they have non-sequential numbers.

Now, in some situations, knowing the order of execution is crucial.  
But usually in this case, the order is unimportant.  The non-sequential
ordering is due to things like "oh, I made a mistake in the fifth
figure, let me try a few things to fix it, now the 4th figure needs to
be fixed too," etc.

So, if it were possible to re-number the cells, either in the notebook
proper or in the nbconvert step, that would make our lives a little bit
easier.

Alternatively, it would be pretty awesome if figures could have
automatic (sequential) figure numbering.  Then the cell numbering
wouldn't matter nearly as much.
Regards,
Jon
_______________________________________________
IPython-dev mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-dev
Reply | Threaded
Open this post in threaded view
|

Re: Renumber cells for nbconvert

Thomas Kluyver-2
Hi Jon,

The simplest thing would be to use the ExecutePreprocessor available now in master to run the notebooks in order before converting them. That both puts the numbers in order and keeps them corresponding to the order of execution.

Thomas

On 18 September 2014 14:10, Jon Wilson <[hidden email]> wrote:
Hi,
We often share around nbconverted notebooks in my research group. But,
it is difficult to refer (when in a phone meeting) to specific figures
or pieces of code or other output in the notebook.  This is because the
cells are often executed out of order, so they have non-sequential numbers.

Now, in some situations, knowing the order of execution is crucial.
But usually in this case, the order is unimportant.  The non-sequential
ordering is due to things like "oh, I made a mistake in the fifth
figure, let me try a few things to fix it, now the 4th figure needs to
be fixed too," etc.

So, if it were possible to re-number the cells, either in the notebook
proper or in the nbconvert step, that would make our lives a little bit
easier.

Alternatively, it would be pretty awesome if figures could have
automatic (sequential) figure numbering.  Then the cell numbering
wouldn't matter nearly as much.
Regards,
Jon
_______________________________________________
IPython-dev mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-dev


_______________________________________________
IPython-dev mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-dev
Reply | Threaded
Open this post in threaded view
|

Re: Renumber cells for nbconvert

Jon Wilson
Hi Thomas,
That sounds great, but some of our notebooks can take hours or even days to execute, so I don't think that this is an option.  The notebook that prompted this email, according to the student whose notebook it is, takes 20-30 minutes to run.

Of course, some take less than a minute, and this solution is perfect for those short-run notebooks.
Regards,
Jon

On 09/18/2014 04:30 PM, Thomas Kluyver wrote:
Hi Jon,

The simplest thing would be to use the ExecutePreprocessor available now in master to run the notebooks in order before converting them. That both puts the numbers in order and keeps them corresponding to the order of execution.

Thomas

On 18 September 2014 14:10, Jon Wilson <[hidden email]> wrote:
Hi,
We often share around nbconverted notebooks in my research group. But,
it is difficult to refer (when in a phone meeting) to specific figures
or pieces of code or other output in the notebook.  This is because the
cells are often executed out of order, so they have non-sequential numbers.

Now, in some situations, knowing the order of execution is crucial.
But usually in this case, the order is unimportant.  The non-sequential
ordering is due to things like "oh, I made a mistake in the fifth
figure, let me try a few things to fix it, now the 4th figure needs to
be fixed too," etc.

So, if it were possible to re-number the cells, either in the notebook
proper or in the nbconvert step, that would make our lives a little bit
easier.

Alternatively, it would be pretty awesome if figures could have
automatic (sequential) figure numbering.  Then the cell numbering
wouldn't matter nearly as much.
Regards,
Jon
_______________________________________________
IPython-dev mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-dev



_______________________________________________
IPython-dev mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-dev


_______________________________________________
IPython-dev mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-dev
Reply | Threaded
Open this post in threaded view
|

Re: Renumber cells for nbconvert

Thomas Kluyver-2
On 18 September 2014 14:36, Jon Wilson <[hidden email]> wrote:
That sounds great, but some of our notebooks can take hours or even days to execute, so I don't think that this is an option.  The notebook that prompted this email, according to the student whose notebook it is, takes 20-30 minutes to run.

I had a feeling you were going to say that. ;-) It should be fairly straightforward to build an extension that renumbers cells without running them, but I'd rather not promote that, because it breaks the model of cell numbers representing execution order.

Thomas

_______________________________________________
IPython-dev mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-dev
Reply | Threaded
Open this post in threaded view
|

Re: Renumber cells for nbconvert

Jon Wilson
Hi Thomas,
Yes, it does break that, which is unfortunate.  What about automatic figure numbering?

Of course, the low-tech solution is to tell everyone that they have to make sequentially-numbered section headings or something similar.
Regards,
Jon

On 09/18/2014 04:41 PM, Thomas Kluyver wrote:
On 18 September 2014 14:36, Jon Wilson <[hidden email]> wrote:
That sounds great, but some of our notebooks can take hours or even days to execute, so I don't think that this is an option.  The notebook that prompted this email, according to the student whose notebook it is, takes 20-30 minutes to run.

I had a feeling you were going to say that. ;-) It should be fairly straightforward to build an extension that renumbers cells without running them, but I'd rather not promote that, because it breaks the model of cell numbers representing execution order.

Thomas


_______________________________________________
IPython-dev mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-dev


_______________________________________________
IPython-dev mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-dev
Reply | Threaded
Open this post in threaded view
|

Re: Renumber cells for nbconvert

Thomas Kluyver-2
On 18 September 2014 14:44, Jon Wilson <[hidden email]> wrote:
Yes, it does break that, which is unfortunate.  What about automatic figure numbering?

That's also possible, especially if you can put up with something not especially aesthetic - walk through the cells and outputs, find each png, and insert a text output below it with "Figure x".

Thomas

_______________________________________________
IPython-dev mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-dev
Reply | Threaded
Open this post in threaded view
|

Re: Renumber cells for nbconvert

Jon Wilson
Hi Thomas,
Thanks!  I will look into doing that.
Regards,
Jon

On 09/18/2014 04:46 PM, Thomas Kluyver wrote:
On 18 September 2014 14:44, Jon Wilson <[hidden email]> wrote:
Yes, it does break that, which is unfortunate.  What about automatic figure numbering?

That's also possible, especially if you can put up with something not especially aesthetic - walk through the cells and outputs, find each png, and insert a text output below it with "Figure x".

Thomas


_______________________________________________
IPython-dev mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-dev


_______________________________________________
IPython-dev mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-dev
Reply | Threaded
Open this post in threaded view
|

Re: Renumber cells for nbconvert

Doug Blank
In reply to this post by Jon Wilson
On Thu, Sep 18, 2014 at 5:44 PM, Jon Wilson <[hidden email]> wrote:
Hi Thomas,
Yes, it does break that, which is unfortunate. 

I was thinking about adding a "Force cell renumbering" option in our Calico Document Tools extension for another reason: in class, I sometimes want to clear the output, but still have the numbers for reference. Unfortunately, the "clear all output" clears the cell numbers too. This would be trivial code, but like Thomas mentioned, it destroys the sequence of operation. 

Although, I just tested the ability to renumber cells using a different scheme, such as "A", "B", "C", ... or "I", "II", "III" (or some other pattern) and that appears to work. Renumbering using a different numbering scheme could show the order, but also indicate that this isn't operation order.
 
What about automatic figure numbering?

Do you have a standard method of referring to figures? We have a bibliography tool, and so a Figure Renumbering Tool would fit right in with that.
 
Of course, the low-tech solution is to tell everyone that they have to make sequentially-numbered section headings or something similar.

We have a Heading Numbering Tool in the collection (and ways to move sections) that you might like. See:


-Doug
 
Regards,
Jon


On 09/18/2014 04:41 PM, Thomas Kluyver wrote:
On 18 September 2014 14:36, Jon Wilson <[hidden email]> wrote:
That sounds great, but some of our notebooks can take hours or even days to execute, so I don't think that this is an option.  The notebook that prompted this email, according to the student whose notebook it is, takes 20-30 minutes to run.

I had a feeling you were going to say that. ;-) It should be fairly straightforward to build an extension that renumbers cells without running them, but I'd rather not promote that, because it breaks the model of cell numbers representing execution order.

Thomas


_______________________________________________
IPython-dev mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-dev


_______________________________________________
IPython-dev mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-dev



_______________________________________________
IPython-dev mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-dev
Reply | Threaded
Open this post in threaded view
|

Re: Renumber cells for nbconvert

Thomas Kluyver-2
On 18 September 2014 14:55, Doug Blank <[hidden email]> wrote:
Although, I just tested the ability to renumber cells using a different scheme, such as "A", "B", "C", ... or "I", "II", "III" (or some other pattern) and that appears to work. Renumbering using a different numbering scheme could show the order, but also indicate that this isn't operation order.

Fair warning: if you do this and save the resulting notebook structure, we consider that an invalid notebook, since prompt numbers should be integers or null. Just doing it for static rendering might be OK, though.

Thomas

_______________________________________________
IPython-dev mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-dev
Reply | Threaded
Open this post in threaded view
|

Re: Renumber cells for nbconvert

Doug Blank
On Thu, Sep 18, 2014 at 5:59 PM, Thomas Kluyver <[hidden email]> wrote:
On 18 September 2014 14:55, Doug Blank <[hidden email]> wrote:
Although, I just tested the ability to renumber cells using a different scheme, such as "A", "B", "C", ... or "I", "II", "III" (or some other pattern) and that appears to work. Renumbering using a different numbering scheme could show the order, but also indicate that this isn't operation order.

Fair warning: if you do this and save the resulting notebook structure, we consider that an invalid notebook, since prompt numbers should be integers or null. Just doing it for static rendering might be OK, though.

Fair enough :) But, I did some more experimenting on master and found that floating-point numbers seem to pass as valid (eg, it at least saves and loads). But you are right that "A" gets reset to null on load. (Note that I'm not necessarily actually advocating this kind of numbering, just experimenting and attempting to show this difference (execution order vs. reference order). Thinking outside the box, er, cell, as it were.

-Doug
 


Thomas

_______________________________________________
IPython-dev mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-dev



_______________________________________________
IPython-dev mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-dev
Reply | Threaded
Open this post in threaded view
|

Re: Renumber cells for nbconvert

Doug Blank
In reply to this post by Jon Wilson
On Thu, Sep 18, 2014 at 5:44 PM, Jon Wilson <[hidden email]> wrote:
Hi Thomas,
Yes, it does break that, which is unfortunate. 

Jon, further reflection in the forced renumbering of cells (even when clearing output) seems like a Really Bad Idea.... it is mucking around with the reproducibility of the notebook---sorta like photoshopping a model to make them like they don't. But, what about an automatic *labelling* of cells? I'm thinking about a tool that could add a markdown cell above each code cell that could label it, like the attached picture. 
 
What about automatic figure numbering?

Then we can treat code cells like figures, and renumber both, for reference purposes.

-Doug
 

Of course, the low-tech solution is to tell everyone that they have to make sequentially-numbered section headings or something similar.
Regards,
Jon


On 09/18/2014 04:41 PM, Thomas Kluyver wrote:
On 18 September 2014 14:36, Jon Wilson <[hidden email]> wrote:
That sounds great, but some of our notebooks can take hours or even days to execute, so I don't think that this is an option.  The notebook that prompted this email, according to the student whose notebook it is, takes 20-30 minutes to run.

I had a feeling you were going to say that. ;-) It should be fairly straightforward to build an extension that renumbers cells without running them, but I'd rather not promote that, because it breaks the model of cell numbers representing execution order.

Thomas


_______________________________________________
IPython-dev mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-dev


_______________________________________________
IPython-dev mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-dev



_______________________________________________
IPython-dev mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-dev

Screenshot from 2014-09-18 18:35:23.png (54K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Renumber cells for nbconvert

Jon Wilson

On 09/18/2014 05:41 PM, Doug Blank wrote:
On Thu, Sep 18, 2014 at 5:44 PM, Jon Wilson <[hidden email]> wrote:
Hi Thomas,
Yes, it does break that, which is unfortunate. 

Jon, further reflection in the forced renumbering of cells (even when clearing output) seems like a Really Bad Idea.... it is mucking around with the reproducibility of the notebook---sorta like photoshopping a model to make them like they don't. But, what about an automatic *labelling* of cells? I'm thinking about a tool that could add a markdown cell above each code cell that could label it, like the attached picture. 
 
Hi Doug,
I like the attached screenshot, but I'd want to muck around with the CSS a bit.  The positioning of the cell numbers off the to left makes them a draw for the eye when you're looking for index-like information.  I think that de-emphasizing those numbers and moving the sequential cell numbers off to the left would be good.  But, the most important thing is to be able to find what the presenter is talking about, and this already accomplishes that.

Regarding reproducibility, renumbering the cells might actually improve it in some cases.  If I've been working on a notebook for a while, I sometimes have executed and re-executed various cells so many times that, if you executed the cells in the order listed, you would use things before they were defined.  Example: define a variable, then make two figures.  Then edit the variable definition, re-run it, re-run one of the figures, then change it back and run that figure again.  Now, the order of the cell numbering is figure 1, definition, figure 2.  If you ran the cells in that order, it would raise an exception on figure 1.  If you re-numbered the cells, then you would run the cells as definition, figure 1, figure 2, and everything would be fine.  Of course, all that is just sloppy discipline on my part and an argument for periodically restarting the kernel and running everything from the beginning.  But sometimes that is too expensive to do.
What about automatic figure numbering?

Then we can treat code cells like figures, and renumber both, for reference purposes.
I like it.  The only thing I would change is that I would not number every code cell.  When we're talking about notebooks, we're only very rarely talking about the code itself.  Instead, plots and tables and numbers are the most important things.  So if I had my "druthers", only cells that produce meaningful output would be numbered.

Thanks for all the great ideas, guys!
Regards,
Jon

_______________________________________________
IPython-dev mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-dev
Reply | Threaded
Open this post in threaded view
|

Re: Renumber cells for nbconvert

Nathan Goldbaum


On Thu, Sep 18, 2014 at 6:08 PM, Jon Wilson <[hidden email]> wrote:

On 09/18/2014 05:41 PM, Doug Blank wrote:
On Thu, Sep 18, 2014 at 5:44 PM, Jon Wilson <[hidden email]> wrote:
Hi Thomas,
Yes, it does break that, which is unfortunate. 

Jon, further reflection in the forced renumbering of cells (even when clearing output) seems like a Really Bad Idea.... it is mucking around with the reproducibility of the notebook---sorta like photoshopping a model to make them like they don't. But, what about an automatic *labelling* of cells? I'm thinking about a tool that could add a markdown cell above each code cell that could label it, like the attached picture. 
 
Hi Doug,
I like the attached screenshot, but I'd want to muck around with the CSS a bit.  The positioning of the cell numbers off the to left makes them a draw for the eye when you're looking for index-like information.  I think that de-emphasizing those numbers and moving the sequential cell numbers off to the left would be good.  But, the most important thing is to be able to find what the presenter is talking about, and this already accomplishes that.

Regarding reproducibility, renumbering the cells might actually improve it in some cases.  If I've been working on a notebook for a while, I sometimes have executed and re-executed various cells so many times that, if you executed the cells in the order listed, you would use things before they were defined.  Example: define a variable, then make two figures.  Then edit the variable definition, re-run it, re-run one of the figures, then change it back and run that figure again.  Now, the order of the cell numbering is figure 1, definition, figure 2.  If you ran the cells in that order, it would raise an exception on figure 1.  If you re-numbered the cells, then you would run the cells as definition, figure 1, figure 2, and everything would be fine.  Of course, all that is just sloppy discipline on my part and an argument for periodically restarting the kernel and running everything from the beginning.  But sometimes that is too expensive to do.

Using a memoization patterns can be very useful for quickly regenerating the results of a long-running computation (although that comes with all issues inherent in caching data and adding state to your notebook, so buyer beware).

I've had some success with joblib [0] in the past to manage caching.  One nice feature is it takes a cryptographic hash of numpy arrays that are provided as input to a function, so it's able to efficiently determine whether a function you want to memoize has had as input in the past some arbitrarily filled out numpy array, making it very straightforward to memoize functions that have numpy arrays as input.


-Nathan
 

What about automatic figure numbering?

Then we can treat code cells like figures, and renumber both, for reference purposes.
I like it.  The only thing I would change is that I would not number every code cell.  When we're talking about notebooks, we're only very rarely talking about the code itself.  Instead, plots and tables and numbers are the most important things.  So if I had my "druthers", only cells that produce meaningful output would be numbered.

Thanks for all the great ideas, guys!
Regards,
Jon

_______________________________________________
IPython-dev mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-dev



_______________________________________________
IPython-dev mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-dev
Reply | Threaded
Open this post in threaded view
|

Re: Renumber cells for nbconvert

Sylvain Corlay
Forcing renumbering in nbconvert would still be useful when converting
to script. Spyder for example has an "outline explorer" that gathers
all the cell separators in a Python file, since 2.3, (# In[*], #
<codecell> and # %%), possibly generated from nbconvert. In this
context, it would make more sense to use the natural ordering than the
execution order of the notebook.
S.

On Thu, Sep 18, 2014 at 9:14 PM, Nathan Goldbaum <[hidden email]> wrote:

>
>
> On Thu, Sep 18, 2014 at 6:08 PM, Jon Wilson <[hidden email]> wrote:
>>
>>
>> On 09/18/2014 05:41 PM, Doug Blank wrote:
>>
>> On Thu, Sep 18, 2014 at 5:44 PM, Jon Wilson <[hidden email]> wrote:
>>>
>>> Hi Thomas,
>>> Yes, it does break that, which is unfortunate.
>>
>>
>> Jon, further reflection in the forced renumbering of cells (even when
>> clearing output) seems like a Really Bad Idea.... it is mucking around with
>> the reproducibility of the notebook---sorta like photoshopping a model to
>> make them like they don't. But, what about an automatic *labelling* of
>> cells? I'm thinking about a tool that could add a markdown cell above each
>> code cell that could label it, like the attached picture.
>>
>>
>> Hi Doug,
>> I like the attached screenshot, but I'd want to muck around with the CSS a
>> bit.  The positioning of the cell numbers off the to left makes them a draw
>> for the eye when you're looking for index-like information.  I think that
>> de-emphasizing those numbers and moving the sequential cell numbers off to
>> the left would be good.  But, the most important thing is to be able to find
>> what the presenter is talking about, and this already accomplishes that.
>>
>> Regarding reproducibility, renumbering the cells might actually improve it
>> in some cases.  If I've been working on a notebook for a while, I sometimes
>> have executed and re-executed various cells so many times that, if you
>> executed the cells in the order listed, you would use things before they
>> were defined.  Example: define a variable, then make two figures.  Then edit
>> the variable definition, re-run it, re-run one of the figures, then change
>> it back and run that figure again.  Now, the order of the cell numbering is
>> figure 1, definition, figure 2.  If you ran the cells in that order, it
>> would raise an exception on figure 1.  If you re-numbered the cells, then
>> you would run the cells as definition, figure 1, figure 2, and everything
>> would be fine.  Of course, all that is just sloppy discipline on my part and
>> an argument for periodically restarting the kernel and running everything
>> from the beginning.  But sometimes that is too expensive to do.
>
>
> Using a memoization patterns can be very useful for quickly regenerating the
> results of a long-running computation (although that comes with all issues
> inherent in caching data and adding state to your notebook, so buyer
> beware).
>
> I've had some success with joblib [0] in the past to manage caching.  One
> nice feature is it takes a cryptographic hash of numpy arrays that are
> provided as input to a function, so it's able to efficiently determine
> whether a function you want to memoize has had as input in the past some
> arbitrarily filled out numpy array, making it very straightforward to
> memoize functions that have numpy arrays as input.
>
> [0] https://pythonhosted.org/joblib/
>
> -Nathan
>
>>
>>
>>> What about automatic figure numbering?
>>
>>
>> Then we can treat code cells like figures, and renumber both, for
>> reference purposes.
>>
>> I like it.  The only thing I would change is that I would not number every
>> code cell.  When we're talking about notebooks, we're only very rarely
>> talking about the code itself.  Instead, plots and tables and numbers are
>> the most important things.  So if I had my "druthers", only cells that
>> produce meaningful output would be numbered.
>>
>> Thanks for all the great ideas, guys!
>> Regards,
>> Jon
>>
>> _______________________________________________
>> IPython-dev mailing list
>> [hidden email]
>> http://mail.scipy.org/mailman/listinfo/ipython-dev
>>
>
>
> _______________________________________________
> IPython-dev mailing list
> [hidden email]
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
_______________________________________________
IPython-dev mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-dev
Reply | Threaded
Open this post in threaded view
|

Re: Renumber cells for nbconvert

Fernando Perez
In reply to this post by Doug Blank

On Thu, Sep 18, 2014 at 3:12 PM, Doug Blank <[hidden email]> wrote:
Fair enough :) But, I did some more experimenting on master and found that floating-point numbers seem to pass as valid (eg, it at least saves and loads).

That's because Javascript doesn't really have a proper integer type, as per the language spec. Stupid, idiotic, crazy, absurd to have a language built like that, but that's JS for you.


--
Fernando Perez (@fperez_org; http://fperez.org)
fperez.net-at-gmail: mailing lists only (I ignore this when swamped!)
fernando.perez-at-berkeley: contact me here for any direct mail

_______________________________________________
IPython-dev mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-dev
Reply | Threaded
Open this post in threaded view
|

Re: Renumber cells for nbconvert

rossant
In reply to this post by Jon Wilson
FYI here is a simple JS extension that linearly renumber all cells in
the notebook:

http://nbviewer.ipython.org/github/ipython-books/cookbook-code/blob/master/notebooks/chapter03_notebook/03_controls.ipynb

2014-09-18 23:10 GMT+02:00 Jon Wilson <[hidden email]>:

> Hi,
> We often share around nbconverted notebooks in my research group. But,
> it is difficult to refer (when in a phone meeting) to specific figures
> or pieces of code or other output in the notebook.  This is because the
> cells are often executed out of order, so they have non-sequential numbers.
>
> Now, in some situations, knowing the order of execution is crucial.
> But usually in this case, the order is unimportant.  The non-sequential
> ordering is due to things like "oh, I made a mistake in the fifth
> figure, let me try a few things to fix it, now the 4th figure needs to
> be fixed too," etc.
>
> So, if it were possible to re-number the cells, either in the notebook
> proper or in the nbconvert step, that would make our lives a little bit
> easier.
>
> Alternatively, it would be pretty awesome if figures could have
> automatic (sequential) figure numbering.  Then the cell numbering
> wouldn't matter nearly as much.
> Regards,
> Jon
> _______________________________________________
> IPython-dev mailing list
> [hidden email]
> http://mail.scipy.org/mailman/listinfo/ipython-dev
_______________________________________________
IPython-dev mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-dev
Reply | Threaded
Open this post in threaded view
|

Re: Renumber cells for nbconvert

Kiko
For the cell renumbering I did this:

I add additional info in the prompt area. It is made using Brython (see https://github.com/kikocorreoso/brythonmagic for more info) but you could easily translate that to JS.

Warning: I don't know if I am breaking something of the nb structure or if what I'm using to get the cell numbers will be available on later versions.

2014-09-19 21:18 GMT+02:00 Cyrille Rossant <[hidden email]>:
FYI here is a simple JS extension that linearly renumber all cells in
the notebook:

http://nbviewer.ipython.org/github/ipython-books/cookbook-code/blob/master/notebooks/chapter03_notebook/03_controls.ipynb

2014-09-18 23:10 GMT+02:00 Jon Wilson <[hidden email]>:
> Hi,
> We often share around nbconverted notebooks in my research group. But,
> it is difficult to refer (when in a phone meeting) to specific figures
> or pieces of code or other output in the notebook.  This is because the
> cells are often executed out of order, so they have non-sequential numbers.
>
> Now, in some situations, knowing the order of execution is crucial.
> But usually in this case, the order is unimportant.  The non-sequential
> ordering is due to things like "oh, I made a mistake in the fifth
> figure, let me try a few things to fix it, now the 4th figure needs to
> be fixed too," etc.
>
> So, if it were possible to re-number the cells, either in the notebook
> proper or in the nbconvert step, that would make our lives a little bit
> easier.
>
> Alternatively, it would be pretty awesome if figures could have
> automatic (sequential) figure numbering.  Then the cell numbering
> wouldn't matter nearly as much.
> Regards,
> Jon
> _______________________________________________
> IPython-dev mailing list
> [hidden email]
> http://mail.scipy.org/mailman/listinfo/ipython-dev
_______________________________________________
IPython-dev mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-dev


_______________________________________________
IPython-dev mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-dev