Perhaps inspired by Brian Okken’s pytest book, I have been experimenting with a new approach to writing code. Most of my work consists of a long list of one-off scripts which serve a single purpose: moving data around, performing some relatively simple NLP operation, etc. While they will likely be run a few times (e.g.,…
Ignoring Tests with `pytest.param`
Testing applications is very important, but must be creatively exercised — perhaps we can follow the wearied expression of testing being more of an art than a science? Even packages like hypothesis still require some creative initialisation. What exactly should I test? How do I test that, and only that? Perhaps there are tests that…
Upgrading to Python 3.10
I just upgraded my Windows machines to Python 3.10.1. I’ve shied away from 3.X.0 releases ever since one of them broke something on Windows — I don’t recall the version, or the reason, and I’d assume release testing has improved so that it’s unlikely to recur, but I suppose I’ve become superstitious in my age….
Retrieve UMLS Data with API Key
The basic need I have is to convert the codes in a MEDDRA dataset to CUIs (UMLS concept unique identifiers). If there were only 10 or so, I’d look them up on the Metathesaurus manually…but I have a dataset of 155 related to COVID-19. Once I have the CUIs, I can limit the output from…
Disable New Microsoft Office “Save As” Menu
Perhaps I’m old-fashioned, or perhaps I haven’t invested enough learning how great Microsoft Office’s new(-ish) save dialog is. Typically, when I want to save something, I want to type/paste in the path I want to save my file, or click through the folders as I’m accustomed to in Windows Explorer. I can’t really figure out…
Default Values for max and min
I rely pretty heavily on Python’s min and max function when trying to take the highest or lowest values from a particular algorithm. For example, a regular expression extracts scores (these could be grades, number of pages in a book, distance run, etc.) from an input document. The document may contain multiple scores (e.g., describing…
Simplify Project Setup with Cookiecutter
Nearly every time I kick-off a new Python project, I follow the same set of steps: And then I feel about ready to grab some lunch or call it a hard-worked day at the office. Each time I follow these steps, I have realized that this should be automated. In fact, the only non-automatable part…
Outlook: Improve Delay Delivery (Part 2)
A couple months ago, I wrote up an initial implementation of adding a button to Outlook that would allow me to ‘delay delivery’. I took the basics of the code from a SuperUser post and turned it into a macro. Basically, the VB code checked to see if I was sending the email at weird…
Install Package from within Jupyter Notebook
I often use Jupyter Notebooks, usually from within the (default) web browser interface, though I’ve been increasingly liking the direction that PyCharm’s interface has been going (e.g., see the feature page: https://www.jetbrains.com/pycharm/features/scientific_tools.html). One of the problems I regularly encounter, however, is that some package (e.g., pandas) is not installed on whichever virtual environment I’m using….
Non-technical Guide to Running a Docker Project
This guide will lead you through the steps to install and run an existing Docker project using docker-compose.yaml, but provides no help in starting a Docker project from scratch. Also, it assumes you are using Windows. Step 1: Enable Virtualization The Windows features ‘Containers’ and ‘Hyper-V’ must both be enabled. To check if this is…