Category "Python"

Numba is a Python package that uses the LLVM compiler to compile Python code to native code. Numba 0.13, released a few weeks ago, offers support for automatically creating CUDA kernels from Python code.

I created a notebook1 (HTML) to show off the demo code.

  1. I’m not sure which is cooler, IPython notebooks or Numba. 

In Modern IDL, I give a short demo of using pyIDL to use IDL from within a Python session. I have had problems with installing pyIDL lately, but didn’t have an alternative until I found pIDLy recently. It easy_installs nicely and has an even nicer interface:

>>> import pidly
>>> idl = pidly.IDL()
>>> idl('x = total([1, 1], /int)')
>>> print idl.ev('x')
>>> print idl.ev('x ^ 2')
>>> idl.reform(range(4), 2, 2)
array([[0, 1],
       [2, 3]])
>>> idl.histogram(range(4), binsize=3, L64=True)
array([3, 1], dtype=int64)
>>>'plot', range(10), range(10), xstyle=True, ystyle=True)
>>> idl.interact()
IDL> print, x
IDL> exit
>>> idl.close()

I don’t see any versioned releases since 2008, but there are commits to the GitHub repo in the last few months so I believe the project is still alive. In any case, it does what I need right now and I can install it. Updating book to use pIDLy…

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.

« newer postsolder posts »