Python advocacy in scientific computation
Michael McNeil Forbes
mforbes at lnsDOTmit.edu
Thu Mar 9 08:18:29 CET 2006
Robert Kern <robert.kern at gmail.com> writes:
> sturlamolden wrote:
> > 5. Versioning control? For each program there is only one
> > developer and a single or a handful users.
> This is one thing that a lot of people seem to get wrong: version
> control is not a burden on software development. It is a great
> enabler of software development. It helps you get your work done
> faster and easier even if you are a development team of one. You can
> delete code (intentionally!) because it's not longer used in your
> code, but you won't lose it. You can always look at your history and
> get it again. You can make sweeping changes to your code, and if
> that experiment fails, you can go back to what was working
> before. Now you can do this by making copies of your code, but
> that's annoying, clumsy, and more effort than it's worth. Version
> control makes the process easier and lets you do more interesting
> I would go so far as to say that version control enables the
> application of the scientific method to software development. When
> you are in lab, do you say to yourself, "Nah, I won't write anything
> in my lab notebook. If the experiment works at the end of the day,
> only that result matters"?
A slightly off topic note:
I find that version control (VC) has many advantages for
scientific research (I am a physicist).
1) For software as Robert mentions I find it indispensable.
2) Keeping track of changes to papers (as long as they are plain text
like LaTeX). This is especially useful for collaborations: using
the diff tools one can immediately see any changes a coauthor may
(I even use branching: maintaining one branch for the journal
submission which typically has space restrictions, and another for
preprint archives which may contain more information.)
3) Using VC allows you to easily bring another computer up to date
with your current work. If I go to a long workshop and use local
computing resources, I simply checkout my current projects and I
can work locally. When I am done, I check everything back in and
when I get home, I can sync my local files.
Another aspect of python I really appreciate are the unit testing
facilities. The doctest, unittest, and test modules make it easy to
include thorough tests: crucial for making sure that you can trust the
results of your programs. Organizing these tests in MATLAB and with
other languages was such a pain that I would often be tempted to omit
the unit tests and just run a few simulations, finding errors on the
Now I almost always write unit tests along with---or sometimes
before---I write the code.
More information about the Python-list