-
Notifications
You must be signed in to change notification settings - Fork 300
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 for nested Jupyter code cells #5045
Comments
Hi @PALuczak, if you select code with your mouse you can right click and select the option "Run Selection/Line in Interactive Window". You can even adjust the keyboard shortcut for this if you would like a different one. |
That is more of a workaround than a solution. Selection is quite error-prone and oftentimes it leads to selecting either one too many or one too few lines. The proposed subcells would significantly reduce such errors. Furthermore, this additional structure would be very useful in teaching, as we would be able to show the processing step-by-step before running it on the whole dataset without having to duplicate code or having to ensure that they select the exact line numbers that describe a particular step. |
Hi @claudiaregio, I agree with @PALuczak. The problem with here is UI ergonomics and usability. In your approach you have to use a mouse, select a part of your code, right click, select an option. Or, with keyboard shortcuts - select a part of code (with shift and arrows) and then press the Run Selection shortcut. In contrary to this a single shortcut (e.g. Ctrl+Enter) in a subcell sounds quite effective. Moreover, such feature would be very helpful during code tuning/debugging sessions - you make a small change and execute it to see the result asap. |
Another approach to this is the proposal to auto-detect code blocks around the cursor, with Shift+Enter executing the whole block: #1471 Then you could run the whole for loop when the cursor is on the |
While there is some slight overlap with #1471, the approach proposed here is significantly more flexible as it would allow for more incremental splits. Oftentimes, either the first or the last step in the loop is costly (i.e. getting/saving data) so being able to split it from the other steps would be quite useful. Additionally, as mentioned in my previous comment, being able to specify blocks manually would be very useful in education as it would allow for creating step-by-step tutorials for students. |
thanks for the suggestion, unfortunately I don't think there is enough interest for us to prioritize this feature |
It would be very useful to be able to nest Jupyter code calls based on indentation. This would make it possible to run for example just a part of a loop. For example:
in this scenario triggering the outer cell would run the entire loop, while the inner cell would only run the code inside the loop.
This would be especially useful during data cleaning, where the processing step needs to be fine-tuned before being run on the whole dataset. If it makes the implementation more convenient, the inner cells could also be designated by adding additional percent characters for each nesting level, i.e.:
# %%
- top-level cell,# %%%
- subcell,# %%%%
- subsubcell etc.The text was updated successfully, but these errors were encountered: