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.,…
Category: python
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…
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…
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….
ERROR: Not a supported wheel on this platform
Installing spacy on a new Windows 7 virtual machine, and running into trouble (per usual). The appropriate way to do this is to usually to install Build Tools, but it always seems quicker to grab the necessary wheels from Christoph Gohlke’s website: https://www.lfd.uci.edu/~gohlke/pythonlibs/. Selecting the appropriate set under spacy along with cytoolz and sometimes ujson….
Configuring TensorFlow to use GPU on Windows
A couple years ago, I had attempted to get involved in Tensorflow/Keras but go waylaid with a few projects. Anyway, I have a new use case to be able to touch my toe in that water (more to come). The configuration is not difficult, but can be time consuming, so I thought it worth recording…
Adding PyPI Update Github Action to Existing Project
I’ve now been updating a few projects to also automatically update PyPI with each new release (see https://foggyprogrammer.com/github-actions-updates-pypi-package for context), but have run into a couple snags: TestPyPI submission fails when the version is not updated. I mostly work on the master branch and each new commit tries to push a new build with the…