datadave / GADS9-NYC-Spring2014-Students

Student repo for Spring 2014 Data Science Course at GA NYC
4 stars 22 forks source link

Does ipython notebook reorder cells? #104

Closed jdleg closed 10 years ago

jdleg commented 10 years ago

When I open a saved ipython notebook and click "run all cells" (or something comparable), I frequently get error messages. Often, I discover that the commands are not in order. For instance, a cell will return an error because it references a data frame that is created in a cell further down. It's hard to imagine that I wrote it that way.***

Related question: Is there any method or shortcut that makes it easy to review links between cells? For instance, anything that would show you at a glance that cell #20 refers to a variable that was changed in cell #16? (For this purpose, I've been using "Find" to page through the cells.)

***This is an update on issue #95. I asked that that one be closed because at the time I couldn't think of a way to conceptualize the question that would make it possible for someone to answer it without reviewing multiple instantiations of my .ipynb file.

podopie commented 10 years ago

@jdleg I haven't seen a case where iPython does this, but I have seen the case where the user can get somewhat lost in "where they are" in their work (myself included when I first learned how to use notebook!)

The reason why I doubt iPython notebook reorders is because that'd be a really inconsistent way to share notebooks. People would not share them if there was no guarantee that their work would be in the correct order on presentation.

One thing I like to do is close my notebook once it's done saving (it'll say 'autosaved' or something similar on the top), close the window, and then open my window back up to clear the in memory variables. then I just run the all cells command and double check if anything messed up. If it does, find what's going on and move things around.

Cells run in the order you run them, so I don't believe you can "Reference" other cells unless you just run the cells out of order by individually clicking on them in the order you want to run them on.