A blog of Python-related topics and code.
The Daily Telegraph publishes an announcements page online. The death announcements category consists of a series of short paragraphs placed by readers communicating the recent death of a relative. The fact that these relatives often expire either "peacefully" or "suddenly" (and sometimes both) is the basis of the peacefully/suddenly game: a popular pastime for long train journeys in the United Kingdom.
A family of curves in the complex plane may be generated by the formula:
Here is a short Python program to visualize the table of multiplication modulo $n$. The integers $i$ and $j = 1,2,3,\cdots,N-1$ number the rows and columns of the image plot produced. $n$ and $N$ are supplied as command line arguments (if $N$ is not supplied, it defaults to $n$).
LineTicks
is a simple class that I put together to add tick marks and labels to a plotted line (not the axes, which Matplotlib already handles well with lots of methods for customization). The code is available on github and released under the Apache 2.0 licence.
This article presents a Python script to map a spectrum of wavelengths to a representation of a colour. There is no unique way to do this, but the formulation used here is based on the CIE colour matching functions, $\bar{x}(\lambda)$, $\bar{y}(\lambda)$ and $\bar{z}(\lambda)$. These model the chromatic response of a "standard observer" by mapping a power spectrum of wavelengths, $P(\lambda)$, to a set of tristimulus values, $X$, $Y$ and $Z$, analogous to the actual response of the three types of cone cell in the human eye.