Blog
An occassional series of posts on physics and computing.
Python functions taking float and array-like arguments
Published on Thursday 26 October 2023 at 12:30 WEST
I often find myself wanting to write a Python function that accepts scalars and array-like objects for each argument. In these cases I have to make a decision about that function's return type. Typically the function performs Numpy operations on the arguments passed to it. But the return type of Numpy functions often surprises me. If a scalar or 0d array-like object is passed to such a Numpy function then it returns a numpy.float64
object. Only otherwise does it return a numpy.ndarray
object. For example, using numpy.sin
I find the following.
Backing up your Linux machine
Published on Saturday 8 April 2023 at 12:00 WEST
I wrote the following advice for members of the Astrophysics Research Group at the University of Surrey. I publish it here, unchanged, in the hope that it might be of use to others too.
The University does not provide automated backup of Linux machines, but instead leaves you to worry about this yourself. I suspect that most Linux users back up their data in a happy-go-lucky way, using GitLab and external storage, performing commits and file transfers only when they remember. But with some intermediate-level Bash tinkering you can arrange for full backups to be made automatically to a schedule. Setting this up should take half an hour or so. The first backup will take considerably longer but will not need your attention (my home drive is currently 180 Gb in size and took 15 hrs to first backup) while subsequent backups will take only minutes.
Citation handling in Emacs
Published on Wednesday 5 April 2023 at 12:00 WEST
Until recently Emacs's Org mode had no native support for citation handling, which was done by third-party packages such as Org Ref. But as of Org version 9.5, released in October 2021, native citation handling has been provided by the built-in library Org Cite. Org Cite is intentionally basic, providing no more than core citation-handling functionality. On its own it has nothing like the capabilities of Org Ref. But it can be extended (this is Emacs, after all) with the Citar package. In turn, further packages can be used to enhance the combined functionality and appearance of Org Cite and Citar. Together these provide a near-complete citation-handling framework for Org.