Magic Time Saving

Magic

Or How I Discovered I Could Save Seconds

A frustrating feature of the jupyter notebooks has been that every time they're opened the magic functions have to be called. Having only simple needs, if only two of them could open up when I initiated a python notebook, that would be great. Fortunately within jupyter it's really easy to save those few seconds a day. Through throwing in a simple .ipy file to the startup folder of ipython any time a new jupyter notebook is made no hoops need to be jumped through.

Although this has only been done on linux and mac systems personally, it could certainly be done on windows as well. The process is rather neat and clean. It starts with creating a .ipy file.

This .ipy file contains the magic commands that one wants to use in the day-to-day. Since making graphs is something that's frequent in many workflows it's nice to have the inline graphs be expected on the start. Unless you really like playing hide and seek with the graphs. Here's the content of my current .ipy file:

#/Users/sebozek/.ipython/profile_default/startup
%matplotlib inline
%config InlineBackend.figure_format = 'retina' # Pretty Hi-Res Graphs

There are additional capabilities. If you have a lot of libraries you need to open frequently you could create a .py file as well in the same location with the appropriate import x as y statements. Personally I think that causes the work being done to be slightly more opaque than I'm comfortable with.

One final thing to note is the naming of these files is important. The ipython will go through them in an ascending manner. Starting with 00-xyz.ipy and then going in increasing order.