I cleaned up a few utility Python scripts for the GitHub:
fetch_python_docs.py sets
up a local mirror of docs.python.org on
http://localhost:8004 for offline reference. It can also provide and enable
a systemd unit file, so you can run the script once, bookmark the local URL,
and forget about it.
typography.py (which I mentioned
here) checks for ASCII typography
that can be better rendered as Unicode. For example, it recommends changing
the hyphen in the page range 278-81 to an en dash.
dated.py applies my obnoxious
filename convention to create
a dated working copy of a file—useful when collaborating with people who
aren’t comfortable with version control systems.
GitHub has a tool called Dependabot that automatically finds outdated package
versions pinned in project configuration files and issues a pull request to
update them. Support for conda environment.yml files has long been one of the
most requested
features in the Dependabot repo. At long last, GitHub has now added partial
support for conda to Dependabot, first as a
beta announced last week,
and now
generally available.
But there have been some issues with the rollout.
The main appeal of conda over something like
Poetry, uv, or
plain-old requirements.txt is that conda can manage arbitrary dependencies,
even beyond Python packages. You can set up a mean Fortran dev environment using
conda create --no-default-packages git micro compilers if you want. But
Dependabot’s conda support includes only Python packages. A few folks grumbled
about this limitation in the GitHub issue comments, but it’s understandable: The
space of “all conda installable packages” is vast indeed, and the Dependabot
team had to start somewhere.
A more compelling criticism of the new feature stems from the fact that
Dependabot determines the latest versions of Python packages by looking up the
names given in environment.yml on PyPI. This is a problem because PyPI is an
entirely different package ecosystem from conda. Some package versions are
released on PyPI well before they appear in conda repos, and some packages have
different names between the two.
For a nasty example, Ipopt is a nonlinear
programming solver written in C, and
cyipopt provides Python
bindings. conda install ipopt installs the C library, and
conda install cyipopt installs the Python wrapper. But pip install ipopt
actually refers to cyipopt. The upshot, if I
understand correctly, is that if you pin ipopt in your environment.yml, then
Dependabot will check its version number against that of the latest version of
cyipopt, a flawed comparison.
Luckily, Ipopt/cyipopt is the only such case I could find in
this Rosetta stone
(the fact that this exists …) mapping package names across ecosystems. But
anyone(ish) can post packages on PyPI, so
the current behavior of Dependabot creates new opportunities for typo-squatting
attacks on conda users. As
Jannis Leidel
(a conda maintainer) put it, “This premature rollout makes the conda ecosystem
less secure and shouldn’t have occurred.”
I’m not sure what the right move is for Dependabot. For a start, they could use
the Rosetta stone to map conda packages to the correct PyPI names, but this
would only solve the naming issue, and not the possibility of different versions
between the two repositories.
Suppose we have data and a model that expresses as a noisy function
of a parameter vector . We want to determine a value of
that fits the data. For the purposes of this post, we’re concerned with models
that are “difficult,” meaning we cannot write down a simple expression for the
likelihood function and maximize it, whether analytically (as in ordinary least
squares) or numerically (as in nonlinear regression). In fact, all we really
know how to do is sample data from the model when given an arbitrary .
(We’ll get a different every time, because the model is nondeterministic.)
If you enjoy Bayesian statistics, then you may have already pattern-matched this
problem statement to the ABC-SMC algorithm. But if you are like me and view
parameter estimation as an optimization problem (there is no reason to privilege
this view; it’s just how I turned out), then you might instead apply an
evolutionary algorithm. Below, I describe such an algorithm, then argue that
ABC-SMC is a special case. This insight suggests improvements to the
implementation and usage of both evolution and ABC-SMC.
I’m obsessed with this essay
“Raising a person in a culture full of types”
by Dan Brooks. Before we get to the author’s message, let’s take a moment to
appreciate his sense of comedic timing, e.g.:
My son talks incessantly about VSCO girls and Karens and other categories of
people he has learned about from YouTube. He described a classmate as “the
kind of person who borrows your pencil and doesn’t give it back,” i.e. she
borrowed his pencil and didn’t give it back. For a while he tried to propagate
a type of his own invention, “the Suzan,” whose behavior was ill-defined but
tracked closely with that of my mother of the same name. It did not catch on,
and eventually he concluded that he was not the kind of person who could come
up with memes.
Is it just me, or is this a highly clever paragraph?
Brooks’s point, expressed better there than I will here, is that our culture’s
emphasis on “being“ over “doing” prevents us from separating people’s actions
from their destiny. At best, the idea that people belong to fixed, inescapable
categories is merely the antithesis of the growth mindset; it saps motivation
from our desire to try new things (why learn programming if I am not a “math
person”?). At worst, as Brooks points out, “The illusion of a fixed nature gives
us an excuse to repeat bad behavior,” because every mistake is like a movie
trailer for the rest of your life. And like a TV commercial, the fixed mindset
is an illusion with a slope (sorry): it inclines us toward the most automatic
decision instead of assessing the alternatives on their merits.
I will not pretend to be a paragon of the growth mindset. I talk myself out of
good ideas, such as learning how to actually cook, all the time. But if I could
choose to have one impact on the world, it would be to motivate those around me
to reject limiting beliefs and embrace challenge—even at the risk of failure.
And if linking you
again
to this essay, which has a wonderful subplot about fatherhood, is the way to do
it, then, OK.
I wrote my first plugin for the Jekyll static website builder: a tool that
recommends related posts
at the end of each page. It determines the similarity between post pairs using
a fairly unremarkable token-counting algorithm, so it’s fast enough to rerun on
every site build. You can configure the number of posts to recommend and a
parameter factor which determines the algorithm’s sensitivity to rare vs.
common words.
I made a little demo of the plugin with a fake
blog whose posts are the articles of the UN Universal Declaration of Human
Rights. You can also see a demo on the current version of this site if you click
the “read more” link below to go to this post’s individual page. I think it
works pretty well!