Better pyplot wrappers

John Hunter <jdh2358@...149...> writes:

This looks like a very good idea.

I agree -- the presence of *args and **kwargs in the pyplot
docstrings, the interface most people use, is a major wart. I suggest
committing this to HEAD when you are ready to go.

I would like to ask the opinion of other developers before checking it
in. I now have two different implementations in two branches of my
github repository (patches attached):

http://github.com/jkseppan/matplotlib/tree/boilerplate
http://github.com/jkseppan/matplotlib/tree/autoboiler

The first one in an improved boilerplate.py as before, so it can be used
to write a large part of pyplot.py so that the signatures and docstrings
are all in there. I still haven't added any automation to call it while
building matplotlib, but that's something of a separate problem.

The second one is a version of pyplot.py that inspects the methods of
Axes objects and creates corresponding functions automatically. It uses
decorator.py, which I have included with the matplotlib source.

I think I personally like the boilerplate branch better. While the code
is a little hairy, you can see its output in pyplot.py, so if it ever
needs to be modified, there is something to run "diff" on. The code in
the autoboiler branch was more difficult to get right, and it creates
the functions at runtime via "exec" (which is how decorator.py can set
the signature of the functions it creates).

In the autoboiler branch, importing pyplot seems to be very slightly
slower. Here is the average time per example it took to run the examples
in the pylab_examples subdirectory in the three branches using the
template backend, in two different runs:

       master boilerplate autoboiler
run 1 1.013 1.028 1.043
run 2 1.028 1.027 1.043

It looks like there is a difference, but it is as large as the
difference between runs in the master branch; much more careful
experimentation would be needed to be sure about the magnitude of
the difference.

boilerplate.patch (204 KB)

autoboiler.patch (52.6 KB)

···

On Sun, Jun 7, 2009 at 8:05 PM, Eric Firing<efiring@...229...> wrote:

--
Jouni K. Sepp�nen
http://www.iki.fi/jks