-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow sections to be collapsed and expanded in the notebook #2030
Comments
We haven't been creating Issues for most such things, as Issues are too heavyweight for the very large number of improvements/little fixes we have planned. The current notebook is very far from where we see it going. We do need a lighter weight palace to put these, which probably means the wiki. Though Issues probably do make sense for the slightly larger-scale things like this one, such as integrating with git, better printing/publishing, etc. |
We would keep the notebook as a linear sequence of cells. We would introduce different levels of heading cells, but these would be flat/inline (like latex section/subsection/subsubsection) rather than nested like the Mathematica notebook. We feel this style of document will be easier to import/export to different formats and is much simpler for users to manage and for us to develop a UI for. To introduce grouping like functionality, we thought about using the locations of different heading levels to identify logical groups that could be collapsed, moved and treated as a unit. We feel this would give the desired benefits of grouping without the complexity of nesting. The first step along with path is to create the heading cells, them we can start to think about a UI for using them as logical groups. |
I also think performing actions on a group is more straightforward with nested structures (e.g. increase/decrease level, relocation, collapse/expand) because you invariably have the whole group as a single element in the structure, no matter what level. When the list is flat, you have to reconstruct the group every time you perform group actions. |
From the computer science/data structure perspective, I completely
While agree at the theoretical level, I have never found this to be |
|
|
As a side note: @ellisonbg, I haven't experienced in Mathematica the indent/dedent problem you described: to indent you just have to introduce a new heading level with a lower precedence from the previous one and Mathematica will create the group automatically until the next higher heading it finds. To dedent you change the type of your group heading to a higher precedence one. To conclude: I'm not saying that Mathematica's way of doing things is the only possible one but that IMHO the cases I described are worth considering when you're taking the next design decisions about grouping. Just my two cents, |
There is no reason at all why we can't add other group level actions such as move, delete, evaluate, etc. We have to develop the UI for this, but I think the it is clear at the conceptual level. The core underlying logic we will need is the following: Given a Heading cell, we need to be able to walk the following cell and figure out which of them are "under" that heading. I think the basic logic is that you keep going until you encounter another heading that has the same level or less as the starting one. Once you have the list of contained cells, you can start to apply actions to the group of them. The challenging part will be designing a clean and functional UI for all of this. |
The one thing where even the notebook doesn't work very well if you want to mix text-based explanations with code, is the definition of complex objects. The reason is a limitation imposed by Python itself: Python does not allow you to declare a class in multiple execution chunks (well, you can, but only using dynamic hacks that aren't very readable and which I will henceforth ignore). This means that if we start using the notebook for declaring more complex classes, right now they have to live in a single, long cell. This prevents you for example from inserting a text paragraph with a mathematical explanation before continuing with the next method. It occurred to me that if we had a concept of a 'cell group' where all the cells in the group would be unconditionally executed always together, all of them, then we'd solve this problem. Consider creating a cell group as stated above, then when you hit Shift-Enter from any cell in the group, we actually send for execution the union of all the code cells in the group ignoring non-code ones. Then, Python would always see them as a single cell, while the human could break up the visual layout between code and text as best fit the problem. There are some UI challenges in how to best do this, but the more I think about it the more I like this idea. It would make the notebook a very nice environment for literate programming in a way that no existing python tool allows. Thoughts? |
A. atom of execution And @fperez' proposal is to have some situation where one A-Cell refers to multiple B-Cells. Another phrasing of the same thing is essentially to have rich text comments without having to split a code block into separate executions. With the implicit cell groups given by headings, we can actually make this work quite easily with optional behavior in 'run group', where it is not run as separate completely independent executions, but concatenated prior to execution. This is not difficult, but would lack the enforcement of a special notion of multi-textarea cell, and running the cells individually would be permitted, if not necessarily valid. |
%mycell ...a Markdown cell or so... %mycell It would be trivial to piece together and execute the union of these. I do like Min's idea of having a "Run Union of Cell Group" action that I think this would make the notebook extremely literate - more so than On Wed, Feb 1, 2012 at 7:53 PM, Fernando Perez
Brian E. Granger |
I think it would be great if there was an outline window in which this hierarchy was explicitly visible, and that could be used to navigate, reorder, and rename entire subtrees. Note that a tree structure or hierarchy need not be imposed; rather, it can be inferred on the fly from the content, like many LaTeX editors do. |
|
|
I am convinced this would be a great UI notebook improvement. PS: I am not talking here about output cells hiding (which is already in ipython 0.13) but the ability to hide or show any part of notebook as well as creating group of cells to be able to hide and show severals cells at the same time. |
|
|
In any case, I believe folding is a key feature; I have seen many people ask for it; personnally that would make me switch to using notebooks rather than terminal sessions (inside emacs). Kuddos in advance to whoever puts energy into it! |
|
Things I believe would remain to do:
Thanks! |
|
|
I would find it very interesting. Is there any update on that? Thanks a lot. |
|
I was not able to apply the following label(s): notebook |
I see that some usernames where not but in backticks when doing the migration. Apologies if you were mentioned and subscribed. |
How is this going? The vertical visible area of a notebook is only about half (between half and 2/3) of screen on her moderate mac book (the top bar, the browser bars, the tab bar, the scroll bar, then the Jupyter banner) So usually a cell and the figure for that cell occupies more than the full available screen estate, hiding all context information for locating the cell in the full document. Thus it is crucial to have some navigate aids, be it folding or a live TOC. TOC may be more efficient because it makes use of the extra horizontal space on wide monitors, without cluttering the existing notebook cells. We may actually want a horizontal cell input/output layout too. |
There is a notebook extension for this: https://github.com/ipython-contrib/jupyter_contrib_nbextensions/tree/master/src/jupyter_contrib_nbextensions/nbextensions/collapsible_headings I'm not sure about its current state or compatibility, but if nothing else it's a reference implementation. |
Thanks for the link. The particular case was affecting |
Colab has a rather good implementation (visually). |
But that's only a since cell, no a section with many possible cells. |
Ok, good point! Collapsible sections make more sense than individual cells in my opinion. Let's move this discussion over to jupyterlab/jupyterlab#2636 (comment) because new features like this will be implemented in JupyterLab vs. Jupyter Notebook. |
I haven't seen this discussed or planned so I thought I should bring it to the table. By cell grouping I mean exactly what Mathematica has: the possibility to group your cells in sections, subsections, etc, which let you easily move, evaluate and eliminate them.
I think one of the most important usability problems with the Sage notebook is the lack of this capability. That's why I don't use anymore but I've also seen on the Sage lists that a lot of people request it.
The only python notebook I know of that has this feature is codenode, now a defunct project by the same guy who developed the Sage notebook. Maybe you can use some of its ideas to implement it here, since it is BSD licensed.
Originally opened as ipython/ipython#805 by @ccordoba12, migration requested by @Carreau
The text was updated successfully, but these errors were encountered: