Yesterday was a momentous day for me. I wrote a dead easy script that 
converts Jupyter notebooks to @file nodes. I immediately saw (Aha!) that 
Leo is a far better platform than Jupyter Lab!


I have forgotten exactly how the Aha came about. As usual, the Aha changed 
everything, including my memory!


But the historical details don't matter. What matters is that I now have an 
excellent workflow and environment for studying math.


math.leo 
<https://github.com/leo-editor/leo-editor-contrib/blob/master/math.leo>, in 
the leo-editor-contrib <https://github.com/leo-editor/leo-editor-contrib> 
repo, shows the results of yesterday's work.


*The breakthrough script*


The *@button import-ipynb* script converts .ipynb files to .py files. It 
practically wrote itself. math.leo contains the latest version.


The guts of the script are these lines:


p = parent.insertAsLastChild()

p.h = f"@jupytext {the_file}"

c.selectPosition(p)

c.refreshFromDisk()

new_fn = os.path.basename(the_file).replace('.ipynb', '.py')

p.h = f"# @file {dir_s}{os.sep}{new_fn}"


Wow. @jupytext does all the heavy lifting!!


*Aha: Leo is the best math platform!*


After converting the notebooks to Leo outlines, I immediately saw that Leo 
is *much* more powerful than Matlab or Jupyter.


To complete my new workflow, another @button script runs files externally:


import os

# Execute the script in the proper folder.

dir_ = os.path.dirname(c.fileName())

os.chdir(dir_)

# Use the common naming convention.

chapter = 'CH01'

section = r'SEC03_Rotation.py'

path = fr'{chapter}/{chapter}_{section}'

g.execute_shell_commands(f"&python {path}")


*Summary*


Yesterday was a golden day. Such milestones do not happen often.


math.leo 
<https://github.com/leo-editor/leo-editor-contrib/blob/master/math.leo>, in 
the leo-editor-contrib <https://github.com/leo-editor/leo-editor-contrib>, 
shows my latest work. Those wishing to use my work should carefully read 
the "Read me" node in math.leo.


For me, Leo is (by far!) the best platform for doing math. This insight 
could not have happened without @jupytext!


Questions? Comments? Acclaim?


Edward


P.S. There is still a place for Jupyter notebooks :-) They are an excellent 
way of collaborating. But I have no further interest in them.


EKR

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/leo-editor/f47a8d76-4bbf-45a9-b4e3-3aaf342647b8n%40googlegroups.com.

Reply via email to