Category "Python"

The IDL Data Point recently had an article about writing a simple main-level program at the bottom of each file which would give an example or test of the routine(s) in the files. I like this idea and have been doing it for quite a while, but one of the annoyances of this approach is that I also typically want the code to be included in the documentation for the routine, so I end up copy-and-pasting the code into the examples section of the docs (and, of course, reformatting it for the doc syntax). Also, the main-level program just is a place to put some code, I have to do all the work if I actually want to write multiple pass/fail tests.

Continue reading “Doc testing thoughts.”

This history of programming languages is hilarious:

1957 – John Backus and IBM create FORTRAN. There’s nothing funny about IBM or FORTRAN. It is a syntax error to write FORTRAN while not wearing a blue tie.


1972 – Dennis Ritchie invents a powerful gun that shoots both forward and backward simultaneously. Not satisfied with the number of deaths and permanent maimings from that invention he invents C and Unix.

I wonder what IDL’s entry would look like?

Link via BoingBoing.

Matplotlib is a popular 2-dimensional plotting library used with Python. While Matplotlib is fairly powerful, I have always had trouble figuring out how to do what I needed from the documentation. I have found the online Matplotlib documentation adequate as a reference, but not very good for getting started (especially since Matplotlib uses some terms in what I would call a “non-standard” way).

Matplotlib for Python Developers by Sandro Tosi is a welcome addition to my bookshelf. It focuses on embedding Matplotlib in applications in GTK+, Qt 4, wxWidgets, and even various web frameworks such as Pylons and Django. But the fundamental elements of the scientific Python tool chain, such as NumPy and IPython, as well as a thorough tutorial of Matplotlib itself are discussed. Both the pylab/pyplot procedural interface (useful for interactive plotting) and object-oriented interface (useful for fine-tuning and more advanced usage) are covered. Over 2000 lines of example code are downloadable from the book site.

Seeing as I don’t use Matplotlib regularly, I’m sure I will using this book frequently to brush up on Matplotlib basics. And this book would have saved me a lot of time when I was writing my only major Python project, a PyQt 4 application which embedded interactive Matplotlib graphics. While this book doesn’t cover every detail of Matplotlib (the online docs are good for that), it will get you started no matter how you are using it.

The publisher has made a sample chapter on embedding Matplotlib in Qt4 available for download. More information, such as a full table of contents, is also available on the publisher’s site.

Full disclosure: I received a review copy of this book.

Proceedings of the 8th Python in Science Conference are now available. I would love to have something like this for IDL.

Link via Gaël Varoquaux.

IDLSave is a Python module to read IDL save files from Python. IDLSave converts IDL types to Python types: arrays are converted to NumPy arrays, structures are converted to NumPy record types. NumPy is required.

(Mentioned by Brian Larsen in this comp.lang.idl-pvwave thread about migrating from IDL to Python.)

Guido van Rossum, creator of Python, recently showed up for a Py4science meeting in the San Francisco Bay Area (video, slides). There are several accounts of the discussion by attendees: Guido himself; Matthew Brett, of Neuroimaging in Python (NiPy); Jarrod Millman, of NumPy, NiPy, and SciPy; and Fernando Perez, of IPython. It looks like people are starting to see the benefits of porting to Python 3.

Win a free Wii in the Opticks Open Source Programming Contest by writing an Opticks extension in C++, Python, or IDL. I’m not familiar with Opticks, but it looks like an ENVI competitor:

Opticks is an expandable remote sensing and imagery analysis software platform that is free and open source.

Early this year, Nokia/Trolltech changed the Qt license from a dual-licensed model (GPL/proprietary) to the more permissive LGPL. But the existing Python bindings for Qt are made by a small company named Riverbank Computing who decided to stick with Qt’s original license.

To fix this, Nokia has launched PySide to make Python bindings available with an LGPL license. From the ArsTechnica article:

Python and Qt have the potential to be an extremely compelling solution for cross-platform rapid application development. The PySide project will address the licensing problems posed by PyQt, but it will also have to simplify cross-platform deployment and resolve other technical challenges in order to really gain traction.

I developed a GUI using PyQt a few years ago and must say that it was the nicest platform to write a GUI in that I have experienced. Qt has an incredibly rich cross-platform toolkit and Python is a great language to work with. Too bad Nokia could not reach a deal with Riverbank Computing; I can’t imagine using PyQt once PySide is available on all the platforms required.

By the way, part of the PySide project is a Binding Generator which can be used to generate bindings for other high-level languages. Hmm.

Jacquette Consulting announced Slither 1.0 today:

Announcing the first official release of Slither, the IDL to Python bridge. Slither allows Python modules to be used in IDL as IDL objects, so you can use the large number of publicly available Python modules, and your own Python code, directly within your IDL application.

In particular, this caught my attention:

In conjunction with this release, we’re making a demo version available that expires on 10/31/09.

Contact them via email to get a copy of the demo version. The user manual contains a lot of details about the API and is also available online.

Slither calls Python from IDL. If you need the opposite direction, i.e., calling IDL from Python, try pyIDL.

Peter Norvig, Director of Research at Google, gave the keynote at SciPy 2009, “What to demand from a Scientific Computing Language—Even if you don’t care about computing or languages”, a conference about scientific programming in Python. His requirements were:

  1. Batteries included means the standard distribution of the language gives all the tools to do standard things. Here’s where IDL beats Python hands down because the standard distribution of Python is not geared to scientific analysis at all. There are 3rd party distributions such as Python(x,y) or the Enthought Toolkit, but these still need to make progress on ease of install, cross-platform availability, and matching all the functionality of IDL. Of course, Python comes with much greater non-scientific functionality and it is free (as in beer and as in speech).
  2. Expressions, not statements means the syntax of the language mimics the syntax of mathematics. The vectorized operations of IDL and NumPy in Python go along way here. The garbage collection in Python makes it a bit easier to create objects within expressions instead of creating a variable to contain them so that they can be freed later.
  3. Parallelize is the ability to use multiple cores. IDL actually uses multiple cores fairly well for many of its core operations, unlike Python.
  4. Documentation, examples, unit tests, tutorials, mentoring is a mixed bag for both Python and IDL. I think the API documentation for IDL is better than for Python’s scientific routines, but Python has a more active online community (even for just the scientific routines). There are many more resources for core Python.

Norvig worked at NASA Ames and brings his experience of the needs of scientific computing to the talk.

« newer postsolder posts »