When Jupyter Aligns ...

December 18, 2020 | 4 minute read
John Featherly
Cloud Native Architect
Text Size 100%:
Jupyter Aligns

When Jupyter Aligns ...

What makes a good blog editor? Obviously the answer will depend to some degree on your blog hosting service. This blog is an experiment to see if Jupyter + (I'll elaborate + as we go) is worth considering as a creator for blogs on Compendium. The main leverage to explore is the ability to export a Jupyter notebook as HTML and load that HTML result into Compendium.

Text and Typesetting

Markdown is the lead item in this category, particularly for software developers. Markdown has ubiquitous presence from software documentation to project management to CI/CD tools. The popularity of Markdown makes it an easy, comfortable choice that covers the basic necessities of text formatting. There are plenty of straight Markdown editors, GitLab, GitHub, StackEdit etc. which can be used to generate HTML but for Jupyter that is just the beginning.

$\LaTeX$

Convenient to have for simple subscripts and Greek letters but also if you happen to need any substantial math typesetting. $$-\frac{\hbar^2}{2m} \frac{d^2 \psi}{dx^2} + V\psi = E\psi$$ If you use Jupyter with a symbolic math system like SageMath you can display expressions typeset using LaTeX.

In [5]:
rotm = 1/sqrt(2)*matrix(SR, 2, [1, -1, 1, 1])
rotm
Out[5]:

Diagrams & Images

Diagram and image embedding is done with the usual Markdown ![ ]( ) or HTML <img src="">. Diagram editors that are able to produce SVG exports I find to be the best approach. I recommend diagrams.net (aka draw.io) which has an online editor as well as desktop versions for Linux, Mac and Windows. There is also a JupyterLab extension at JupyterLab draw.io which is a bit limited but capable of making a quick diagram and writing SVG. Note there are OCI icon sets available at OCI Icons for draw.io

The image embedding options with Markdown are all present. Link to external images by simply using an image URL.

Local images can be added as attachments to the notebook but will not be bundled with HTML export so of no use in this case. Just drag and drop an image file in a Jupyter cell to attach it to the notebook.

One option to bundle an image into the HTML export is to base 64 encode the image and paste it into a (data:image ...) link directly in the Markdown.

The Plus

The heritage of Jupyter is a Python development environment so the big plus for blogging is showing code pieces in cells with the accompanying output from executing the code. Say you wanted to discuss list comprehension you might have a code bit to show as follows:

In [7]:
unit_square = [(0,0), (1,0), (1,1), (0,1)]
P = plot(polygon(unit_square, color='blue', fill=False))
P += plot(polygon([vector(i)*rotm for i in unit_square], color='green', fill=False))
P.show()

and maybe show the values of the rotated vertex vectors

In [8]:
[vector(i)*rotm for i in unit_square]
Out[8]:

Conclusion

There is still annoying adjustments that need to be made to the HTML export when loading it into Compendium, mainly adjusting the links for images that are uploaded to Compendium to be local to the blog. The net is all the src= values end up being external references. The advantages of showing not only code but the results of executing code along with symbolic calculations and plotting available with Jupyter cohorts like SageMath are enough to make it an attractive option for blog writing. There is great potential for ML and data science workers as their work is often done in Jupyter notebooks. That also applies to ODS users.

If you happen to read this before December 21, 2020 make sure you look up at Jupiter that evening. Jupiter and Saturn will be in conjunction for a once in 800 year show.

John Featherly

Cloud Native Architect

");else if(O._boomrl=function(){t()},O.addEventListener)O.addEventListener("load",O._boomrl,!1);else if(O.attachEvent)O.attachEvent("onload",O._boomrl);d.close()}function a(e){window.BOOMR_onload=e&&e.timeStamp||(new Date).getTime()}if(!window.BOOMR||!window.BOOMR.version&&!window.BOOMR.snippetExecuted){window.BOOMR=window.BOOMR||{},window.BOOMR.snippetStart=(new Date).getTime(),window.BOOMR.snippetExecuted=!0,window.BOOMR.snippetVersion=12,window.BOOMR.url=n+"35ZX8-M5PF3-M74BW-PTTYL-UT8VU";var i=document.currentScript||document.getElementsByTagName("script")[0],o=!1,r=document.createElement("link");if(r.relList&&"function"==typeof r.relList.supports&&r.relList.supports("preload")&&"as"in r)window.BOOMR.snippetMethod="p",r.href=window.BOOMR.url,r.rel="preload",r.as="script",r.addEventListener("load",e),r.addEventListener("error",function(){t(!0)}),setTimeout(function(){if(!o)t(!0)},3e3),BOOMR_lstart=(new Date).getTime(),i.parentNode.appendChild(r);else t(!1);if(window.addEventListener)window.addEventListener("load",a,!1);else if(window.attachEvent)window.attachEvent("onload",a)}}(),"".length>0)if(e&&"performance"in e&&e.performance&&"function"==typeof e.performance.setResourceTimingBufferSize)e.performance.setResourceTimingBufferSize();!function(){if(BOOMR=e.BOOMR||{},BOOMR.plugins=BOOMR.plugins||{},!BOOMR.plugins.AK){var n=""=="true"?1:0,t="",a="aoiqz4tipiwu2zrmoawq-f-dc54e4dfa-clientnsv4-s.akamaihd.net",i="false"=="true"?2:1,o={"ak.v":"37","ak.cp":"896286","ak.ai":parseInt("573366",10),"ak.ol":"0","ak.cr":9,"ak.ipv":4,"ak.proto":"h2","ak.rid":"49e913","ak.r":35910,"ak.a2":n,"ak.m":"dscx","ak.n":"essl","ak.bpcip":"3.145.12.0","ak.cport":63744,"ak.gh":"104.114.79.52","ak.quicv":"","ak.tlsv":"tls1.3","ak.0rtt":"","ak.csrc":"-","ak.acc":"","ak.t":"1714188333","ak.ak":"hOBiQwZUYzCg5VSAfCLimQ==r1JKDndPloBQxblS9h28aSnWCBmdVkFm4rV8Champi9zfZ1By8/1J/ZK4e/36UXZ4rTw+1cRjcghaIY0dbKb1w20riDoQcp39qSQTDXd1/FxXjJSs3qufo3IM8/3nD0Z1Qpv0yIEdLublDYaK6k/bm5mdMexWfiaCxWe/nHVWSmsurWeUBZoihNn4CjZPR8hfFzrAWo7BSuv6AV3u0EfJrxYgGkGso39VwTvZHaYIg+jrQFYHOkE39PrB4lclY+VRDp2GBPmrSJuhQ5fHhfWaAm4wFoKOr5gZd/wez5oKoaUDRiM71FnLrt979j6Blk0Yej9OMxN5/e6LT+YfbV8y9CE6SBq/HRNYDII3vuUPKkt1VjoQt1QLP58+U7UWe+T/Auio2nOkiLZ7JYExeksAf/E5LSTLdfNpDYNk5mJpqs=","ak.pv":"21","ak.dpoabenc":"","ak.tf":i};if(""!==t)o["ak.ruds"]=t;var r={i:!1,av:function(n){var t="http.initiator";if(n&&(!n[t]||"spa_hard"===n[t]))o["ak.feo"]=void 0!==e.aFeoApplied?1:0,BOOMR.addVar(o)},rv:function(){var e=["ak.bpcip","ak.cport","ak.cr","ak.csrc","ak.gh","ak.ipv","ak.m","ak.n","ak.ol","ak.proto","ak.quicv","ak.tlsv","ak.0rtt","ak.r","ak.acc","ak.t","ak.tf"];BOOMR.removeVar(e)}};BOOMR.plugins.AK={akVars:o,akDNSPreFetchDomain:a,init:function(){if(!r.i){var e=BOOMR.subscribe;e("before_beacon",r.av,null,null),e("onbeacon",r.rv,null,null),r.i=!0}return this},is_complete:function(){return!0}}}}()}(window);\n\n
\n
\n\n
\n
\n
\n

When Jupyter Aligns ...&#182;

What makes a good blog editor? Obviously the answer will depend to some degree on your blog hosting service. This blog is an experiment to see if Jupyter + (I'll elaborate + as we go) is worth considering as a creator for blogs on Compendium. The main leverage to explore is the ability to export a Jupyter notebook as HTML and load that HTML result into Compendium.

\n\n
\n
\n
\n
\n
\n
\n

Text and Typesetting&#182;

Markdown is the lead item in this category, particularly for software developers. Markdown has ubiquitous presence from software documentation to project management to CI/CD tools. The popularity of Markdown makes it an easy, comfortable choice that covers the basic necessities of text formatting. There are plenty of straight Markdown editors, GitLab, GitHub, StackEdit etc. which can be used to generate HTML but for Jupyter that is just the beginning.

\n\n
\n
\n
\n
\n
\n
\n

$\\LaTeX$&#182;

Convenient to have for simple subscripts and Greek letters but also if you happen to need any substantial math typesetting. $$-\\frac{\\hbar^2}{2m} \\frac{d^2 \\psi}{dx^2} + V\\psi = E\\psi$$\nIf you use Jupyter with a symbolic math system like SageMath you can display expressions typeset using LaTeX.

\n\n
\n
\n
\n
\n
\n
In&nbsp;[5]:
\n
\n
\n
rotm = 1/sqrt(2)*matrix(SR, 2, [1, -1, 1, 1])\nrotm\n
\n\n
\n
\n
\n\n
\n
\n\n\n
\n\n
Out[5]:
\n\n\n\n
\n\n
\n\n
\n\n
\n
\n\n
\n
\n
\n
\n

Diagrams &amp; Images&#182;

Diagram and image embedding is done with the usual Markdown ![ ]( ) or HTML &lt;img src=\"\"&gt;. Diagram editors that are able to produce SVG exports I find to be the best approach. I recommend diagrams.net (aka draw.io) which has an online editor as well as desktop versions for Linux, Mac and Windows. There is also a JupyterLab extension at JupyterLab draw.io which is a bit limited but capable of making a quick diagram and writing SVG. Note there are OCI icon sets available at OCI Icons for draw.io

\n

\n

The image embedding options with Markdown are all present. Link to external images by simply using an image URL.

\n

\n

Local images can be added as attachments to the notebook but will not be bundled with HTML export so of no use in this case. Just drag and drop an image file in a Jupyter cell to attach it to the notebook.

\n

\n

One option to bundle an image into the HTML export is to base 64 encode the image and paste it into a (data:image ...) link directly in the Markdown.

\n

\"\"

\n\n
\n
\n
\n
\n
\n
\n

The Plus&#182;

The heritage of Jupyter is a Python development environment so the big plus for blogging is showing code pieces in cells with the accompanying output from executing the code. Say you wanted to discuss list comprehension you might have a code bit to show as follows:

\n\n
\n
\n
\n
\n
\n
In&nbsp;[7]:
\n
\n
\n
unit_square = [(0,0), (1,0), (1,1), (0,1)]\nP = plot(polygon(unit_square, color=&#39;blue&#39;, fill=False))\nP += plot(polygon([vector(i)*rotm for i in unit_square], color=&#39;green&#39;, fill=False))\nP.show()\n
\n\n
\n
\n
\n\n
\n
\n\n\n
\n\n
\n\n\n\n\n
\n\n
\n\n
\n\n
\n
\n\n
\n
\n
\n
\n

and maybe show the values of the rotated vertex vectors

\n\n
\n
\n
\n
\n
\n
In&nbsp;[8]:
\n
\n
\n
[vector(i)*rotm for i in unit_square]\n
\n\n
\n
\n
\n\n
\n
\n\n\n
\n\n
Out[8]:
\n\n\n\n
\n\n
\n\n
\n\n
\n
\n\n
\n
\n
\n
\n

Conclusion&#182;

There is still annoying adjustments that need to be made to the HTML export when loading it into Compendium, mainly adjusting the links for images that are uploaded to Compendium to be local to the blog. The net is all the src= values end up being external references.\nThe advantages of showing not only code but the results of executing code along with symbolic calculations and plotting available with Jupyter cohorts like SageMath are enough to make it an attractive option for blog writing. There is great potential for ML and data science workers as their work is often done in Jupyter notebooks. That also applies to ODS users.

\n

If you happen to read this before December 21, 2020 make sure you look up at Jupiter that evening. Jupiter and Saturn will be in conjunction for a once in 800 year show.

\n\n
\n
\n
\n
\n
\n\n\n \n\n\n\n","translate":null,"og_description":null,"featuredpost":false,"audience":null,"product":null,"comments":false,"meta_title":null,"time_to_read":4,"author":[{"id":"CORE181AC6D287EC42A297128D6A512EE57D","type":"Blog-Author","typeCategory":"ContentType","links":[]}],"translated-pages":null,"canonical_url":null,"featured_image":null,"og_image":null,"meta_description":null,"meta_robots":null,"primary_channel":"ateam","globalhomepagefeaturedpost":false,"publish_date":{"value":"2020-12-18T09:46:00.000Z","timezone":"UTC","formated":"December 18, 2020"},"desc":"Jupyter Aligns When Jupyter Aligns ...¶ What makes a good blog editor? Obviously the answer will depend to some degree on your blog hosting service. This blog is an experiment to see if Jupyter + (I'll elaborate + as we go) is worth considering as a creator for blogs on Compendium. The main leverage...","author_id":"CORE3AC2B3EC422D4C1C82DCD9B4A5F50F65","categories":[]}}">

Previous Post

Reference Architecture - EPM Cloud Data Replication into FAW ADW : Using ODI Marketplace

Matthieu Lombard | 13 min read

Next Post


Four Re-usable Custom Components for Oracle Digital Assistant

Siming Mu | 4 min read