Mar 28, 2022

Using Wolfram Engine with Jupyter Notebook

I’ve been using the free Wolfram cloud for a while; it is actually very capable for small projects. Several tips:

  1. It can’t upload any files, put the data somewhere online, then use Import[url] to get the data

  2. Each command can only run in a limited time (several minutes?), and sometimes reducing the size of data can help the job run through, for example, ImageResize[image,Scaled[1/2]].

  3. Learn some keyboard shortcuts, especially on cell formatting: Keyboard Shortcut Listing for the Wolfram Cloud.

  4. The most important thing: download your notebooks and also save a pdf copy. The file expires after 60 days, the user can’t open and download the expired files.


You probably can guess what happened to my files, they are all expired. I am not complaining here, it is free service anyway. To avoid this issue, I decided to try Free Wolfram Engine with Jupyter Notebook. They can be connected by WolframLanguageForJupyter. I am not going through the installation part; it is well documented for each product. I’ve created a sample notebook ImageStitch.ipynb with JupyterLab (a better interface than the classic Jupyter notebook). (Note: if it doesn’t load properly, try to reload it again). I may try other connectors later, the one used here is directly from Wolfram, however it doesn’t support auto-completion.  




Mar 24, 2022

Update: Learning Mathematica Slowly

I am on an extremely slow journey to pick up Mathematica again, one is that the current Mathematica is massive, the second is on me, in short “small brain”, that it is difficult to switch among several different programming languages. I mainly do coding with Python and JavaScript. I’ve tried to learn Julia and Mathematica at the same time since January, and got confused very quickly. So, in the next several months, I will focus on Mathematica first.


Currently reading: Wolfram Language Tutorial: Fast Introduction for Programmers

This book mainly explores Wolfram language on the level of grammar and syntax, it may fall short on emphasizing the importance of functional programming. Even though it plays a much minor role in Python, the basic idea of functioning programming lives well inside the Python ecosystem, for example, pure function (lambda) and map() are used frequently. If this book can absorb more materials from Functional Programming—Wolfram Language Documentation, it definitely helps a Python programmer understand the paradigm of Wolfram Language better.


The book comes with the notes for Java and Python programmers. The notes on Python are too simple and almost lose their purpose. The following are two examples:

  1. List comprehension: 

In Iterators | Wolfram Language Fast Introduction for Programmers, it says "Using Table in this way is analogous to using the [... for ... in ...] list comprehension construct in Python, though it has somewhat richer semantics.”. What’s the richer semantics? The list comprehension in Python is versatile, it has a basic format: newList = [ expression(element) for element in iterable], and combined with conditions(if/else), lambda function and nesting, it can do lots of things in a concise syntax. Here is not arguing the feature in which language is more powerful, it is mostly a missed opportunity for a better explanation on Wolfram language.

  

  1. f-string formatting:

In Strings | Wolfram Language Fast Introduction for Programmers, it says “TemplateApply in the Wolfram Language works similarly to Python's % or format function, except inline computations using <* ... *> are not supported in Python.” This claim is not accurate, Python’s f-string (introduced in Python 3.6) does the exact same thing. The screenshot shows some examples.