Ask Your Question
2

alternative to jupyter notebook?

asked 2021-02-23 06:11:34 +0100

Ingrid gravatar image

I have a number of problems using Jupyter notebook, windows 10. When my .ipynb file reaches a certain length, sage basically grinds to a halt, and I need to start a new file. When doing a long calculation, where each bit needs the calculations from the previous part, this isn't practical. Also, when I "save" an .ipynb file, the actual calculations aren't saved, and each file takes about half a day to go through and recalculate everything again. I have about 5 files now, and the power keeps flickering on and off briefly... Also, it happens constantly that sage won't let me type anything in. This can last for up to 10 minutes at a time, and seems to have something to do with the way the file is saved. I haven't even reached the final part of my calculation, which is the part I expect to be the slowest by far. My husband tells me to stop messing around with windows and learn Linux. Any other suggestions? Thanks very much!

edit retag flag offensive close merge delete

Comments

At least as a workaround you can save and load intermediate results (see the examples there).

rburing gravatar imagerburing ( 2021-02-23 09:52:31 +0100 )edit
1

You may also save/load the whole session:

save_session('first_computations.sobj')

Then, in another notebook:

load_session('first_computations.sobj')
Sébastien gravatar imageSébastien ( 2021-02-23 09:59:59 +0100 )edit
1

Basically, your problem seems not to be Jupyter per se, but the size of your problem's computation.

When my .ipynb file reaches a certain length, sage basically grinds to a halt, and I need to start a new file.

You may have hit a (new ?) bug. Further exploration may be in order.

Also, when I "save" an .ipynb file, the actual calculations aren't saved, and each file takes about half a day to go through and recalculate everything again.

Correct. You should explicitly save the computed objects, and load them when needed. See also save_session, but take note of its limits...

'rburning`'s suggestion to split your work by saving each part's results as needed is sound. BTW, your husband's is also sound, and might reap benefits unrelated to Sagemath ;-)...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2021-02-23 10:21:50 +0100 )edit
1

Thanks, saving does help. I have no understanding of this process; why most of my stuff can be saved individually but is not saved when I save the session, or the ipynb file. For the moment, as long as it works. I've started on a newer computer, with more RAM, which also helps with some of the issues. Learning Linux will have to wait until we get IT support :-)

Ingrid gravatar imageIngrid ( 2021-02-24 03:15:27 +0100 )edit

It is a good question. When you "save" a Jupyter notebook, you save the string representation of the inputs and the string representation of the outputs, but not the input themselves or the output themselves, nor the global variables. For example, you can see that the lists In and Out (which contains all inputs and all outputs when you save) are empty when you close and open the notebook again : it starts at 1 again with In[1] and Out[1]. By using save_session('a.sobj') and load_session('a.sobj') you reload all variables in the namespace including the In and Out lists.

Sébastien gravatar imageSébastien ( 2021-02-24 09:19:40 +0100 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2021-02-23 10:10:25 +0100

Sébastien gravatar image

I enjoy the Jupyter notebook when lot of plots are in my outputs. But, remember that interactive computations can be done in the console as well. Also when code becomes large with hundred if not thousands of line of codes, a basic text file edited with a text editor is sometimes more efficient than a Jupyter cell.

Did you try jupyterlab? I allows to open a text file like file.sage or file.py on one side and a sage console in the other side. Then, you can call %runfile file.sage in the console or even better %attach file.sage which automatically reloads the file when it changes.

You may install jupyterlab on Sage in Windows as explained in this other ask question.

edit flag offensive delete link more

Comments

To complementSebastien's suggestion, may I point to the sage-shell package that adds sage-related features to emacs, including a quite powerful inferior-sage to (one or many) "live" Sage session(s), in parallel with the extremely powerful editing abilities of emacs.

IMNSHO, this is the best IDE currently available for Sagemath. However, emacs is not in everyone's taste. If you use a computer for anything even vaguely related to programming, you should try to learn it (at least to see if it suits your taste).

This is even more true if you plan to create documents mixing text and "live" code (reproducible reports).

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2021-02-23 17:43:36 +0100 )edit

I haven't got jupyterlab working yet, but yes, I do have thousands of lines. If everything works out, I will want to put the results into a .tex file Long term this definitely sounds like what I need. Thanks.

Ingrid gravatar imageIngrid ( 2021-02-24 03:41:48 +0100 )edit

.tex file is for LaTeX. I guess you mean .py or .sage ? If you have thousands of lines of code, I strongly suggest to put that in a file called let's say file.sage and then simply do %runfile file.sage in the first cell of a Jupyter notebook or in the Sage console.

Sébastien gravatar imageSébastien ( 2021-02-24 09:11:08 +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: 2021-02-23 06:11:34 +0100

Seen: 836 times

Last updated: Feb 23 '21