IJulia allows running Julia from within the web browser-based Jupyter IDE.
In general (for all operating systems) it’s recommended to install and update Julia via the
downloads from Julia website.
Install Jupyter: locate Jupyter binary location
Windows: where jupyter
Linux, macOS: which jupyter
If Jupyter is not installed, just do
conda install jupyter
Install IJulia: start Julia with this environment variable (only necessary once)
Linux / macOS:
JUPYTER=$(which jupyter) julia
Windows:
$Env:JUPYTER=$(where.exe jupyter)
julia
Finally, type at Julia prompt:
using Pkg
Pkg.add("IJulia")
This installs numerous packages via conda automatically.
Existing .jl files are NOT runnable from IJulia.
Start the Notebook by EITHER:
Terminal/Command Prompt: jupyter lab
Julia: using IJulia; notebook()
Create an interactive Julia .ipynb Julia notebook by clicking New → Julia.
Some Raspberry Pi models such as the Zero and Zero W do not have an Ethernet port on the board.
While one can use a USB-Ethernet adapter in the USB OTG port, if one wants to use only the Pi itself without adapters, the procedure below is required.
Install
Raspberry Pi operating system on micro SD card.
On the SD card, edit /boot/config.txt, adding the line:
Edit boot/cmdline.txt, adding after rootwait on the same line with a space:
rootwait modules-load=dwc2,g_ether
Boot the Pi with the micro SD card inserted, waiting 90 seconds or so.
Then type from laptop (username, hostname are those picked for the Pi by the Raspberry Pi Imager program):
ssh username@hostname.local
If this doesn’t work, ensure that you see the new Ethernet port on your laptop.
On Linux this would be seen in
Since PyPI accepts Markdown formatted README.md, there is less reason to use the more complicated syntax of ReStructured Text .rst files.
We have converted hundreds of README.rst to README.md with the process below.
Bulk convert RST .rst to Markdown .md:
pandoc -f rst -t markdown README.rst -o README.md
Slight hand correction: remove most \ that were inserted (find and replace with nothing)
Eliminating unnecessary (particularly large) files and removing needless historical development details are two significant parts of preparing a Git repo for public release.
The general public users, even if of a limited group don’t need large amounts of code development history, probably littered with large files.
Here are several straightforward steps to prepare code for public Git release.
GitHub is an obvious first choice, as GitHub has by far the largest number of users and excellent integration with third party tools.
Bitbucket and GitLab are two worthy alternatives.
Create an empty Git repo at the website, then clone the empty repo you created to the computer.
git clone https://github.invalid/username/myrepo
Copy the files you want into the myrepo directory–we’ll clean up extra files next
Matplotlib pcolormesh() is 10-100x or more faster than pcolor(), especially when using cartopy.
However, the mesh generation requires valid edge coordinates–NaN is not allowed.
A workaround for certain scenarios like geospatial plots is to “smear” the last valid x,y (say, latitude, longitude) out to replace the NaN’s.
Like pcolor(), this method hides the invalid values.
There may be slight aberrations at the edges.
Some Raspberry Pi modles have Bluetooth and 2.4 / 5 GHz 802.11ac WiFi built in or can use a USB dongle for WiFi and Bluetooth.
Raspberry Pi and many other embedded single board computers can connect to the internet via Bluetooth WPAN a.k.a. tethering or connection sharing.
This method avoids tying up the WiFi connection of a phone, or putting sensitive WiFi credentials on an embedded device.
This method inherently limits internet bandwidth to the embedded device to about 1.6 Mbps practical throughput due to the legacy Bluetooth WPAN specification.
NetworkManager can be used from the command line “nmcli” to make the Bluetooth internet connection.
Create a script and “@reboot” cron job to make a semi-permanent WPAN connection.
Connect to the internet host device e.g. smartphone with
Bluetooth tethering turned on
Bluetooth UUID like:
nmcli device connect AA:BB:CC:DD:EE:FF
It’s also possible to configure USB tethering to the phone; I’ve done that via the NetworkManager GUI from the desktop environment.
BlueZ5 allows using Bluetooth on Linux for useful tasks like:
playing sound from the Linux device over Bluetooth headphones
send text with Android phones
This works for Linux computers in general, from laptops to Raspberry Pi or other single board computers with Bluetooth on-board or via USB adapter.
BlueZ is very handy for command line Bluetooth on Linux:
apt install bluez5
From any Linux computer with Bluetooth, pair the Bluetooth device from Terminal:
Hardware enable Bluetooth adapter
rfkill unblock bluetooth
start HCI UART service
systemctl start hciuart
Go into Bluetooth interactive mode. Use sudo if “no default controller available” error occurs.
bluetoothctl
shows a list of devices already paired, and goes into an interactive Bluez program.
show Bluetooth adapters usable (there must be at least one).
list
software enable Bluetooth adapter
power on
agent on
Find Bluetooth devices to pair with
scan on
A list of Bluetooth pairing-mode UUIDs stream in continuously.
Wait several seconds if you don’t immediately see your device.
Be sure the device (e.g. smartphone/laptop) is in visible/pairing mode.
Stop the scan:
scan off
Pair with Bluetooth device, where uuid is your device
pair uuid
trust uuid
Connect to the Bluetooth device:
connect uuid
bluetoothctl commands: from within bluetoothctl interactive prompt.
paired-devices: list devices this computer is paired with
info UUID: for device with UUID, list capabilities (Bluetooth service profiles).
For example, PANU is PAN user.
Here are several basic Bluetooth commands from the Linux terminal.
List installed Bluetooth devices from Linux:
rfkill list
The listing will look like:
0: phy0 Bluetooth: bluetooth
Soft blocked: yes
Hard blocked: no
enable Bluetooth devices:
rfkill unblock bluetooth
Which reveals another device:
1: hci0: bluetooth
Soft blocked: no
Hard blocked: no
Pytest cleanly handles many continuous integration issues.
Pytest is worthwhile to setup tests and improve test coverage.
It’s straightforward to incrementally upgrade from obsolete nose and legacy unittest modules to Pytest.
A frequent CI task is comparing floating point numbers.
Computer representations of floating point numbers have
finite precision.
Real numbers associativity doesn’t completely apply to digital floating point representations.
A practical solution to this problem is to compare numbers (scalars or arrays) to within an absolute and relative tolerance.
Widely known functions exist to compare “equality” of floating point numbers in
Python
and
Fortran real/assert.F90
among other numerical languages.
pytest.approx
provides a syntactically clean approach that may be more intuitive and readable for CI applications.
It works with scalars and arrays of all sorts including the ubiquitous numpy.ndarray.
pytest.approx() can be used to compare Numpy ndarrays, lists, tuples, and scalars.
However, for Numpy ndarrays, a richer feature set and text output is available with numpy.testing.assert_allclose().
importnumpyasnpfrompytestimport approx
deftest_mynums():
x = np.array([2.00000000001, 1.99999999999])
assert x == approx(2.)
# or np.testing.assert_allclose(x, 2.)
NaN is an unrepresentable, undefined quantity as results from invalid computations like:
∞ / ∞
0 / 0
NaN are also useful as sentinel values to indicate a problem with a computation for example.
Python sentinel
values include NaN and None.
In Julia, performance is approximately the same for nan vs. nothing sentinel values.
The option pytest.approx(nan_ok=True) allows one or more NaN’s in the test array.
Absolute and relative tolerance are important considerations for CI, particularly across OS and computer types, where order of operation and numerical CPU/GPU/APU/etc. tolerances and low level math routines (BLAS, AVX, etc.) differ.
Especially (perhaps obviously) for single precision arithmetic vs. double precision arithmetic, tolerances will be larger.
pytest.approx() default tolerances work for many situations.
Absolute tolerance shouldn’t be 0 to avoid unexpected effects near 0.
Depending on the parameter, rel=1e-4 may be more appropriate for CI tests that need to work on a variety of systems.
DO NOT USE -ac 1 even with monaural audio as you’ll get lots of errors like
non-monotonous DTS in output stream 0:1;
-c:a libmp3lame -ar 44100
encode audio as MP3 with a 44.1 kHz sampling frequency (passing audio up to about 22 kHz, which is CD-quality).
List PulseAudio devices:
pactl list sources
Control audio sources with:
pavucontrol
Video config -framerate 10 -f x11grab -i :0.0+0,0 screengrab at 10 fps, starting in the upper left hand corner, send a 1024x720 pixel video.
If your screen resolution is more than 1024x720, there would be unsent regions at the bottom and/or right side.