error in add_subplot

Current SVN (r6540) raise an error for the following code.

import matplotlib.pyplot as plt
import matplotlib.axes as maxes

fig = plt.figure()
ax = maxes.Subplot(fig, 1, 1, 1)
fig.add_subplot(ax)

/Users/jjlee/.virtualenvs/default/lib/python2.5/site-packages/matplotlib/figure.pyc
in add_subplot(self, *args, **kwargs)
    687 self._axstack.remove(ax)
    688
--> 689 a = subplot_class_factory(projection_class)(self,
*args, **kwargs)
    690 self.axes.append(a)
    691 self._axstack.push(a)

UnboundLocalError: local variable 'projection_class' referenced before
assignment

It seems that some of the code Mike recently introduced in "figure.py"
have incorrect indentation, but I'm not 100% sure.
I'm attaching a patch which seems to work for me, and It would be
great if Mike or others review it and apply.

-JJ

figure.diff (1.35 KB)

Arg, bad timing. Charlie released 0.98.4 hours before you found this. Fortunately, the use case,

fig = plt.figure()
ax = maxes.Subplot(fig, 1, 1, 1)

fig.add_subplot(ax)

is pretty rare, since most use the fig.add_subplot(111) construction. In fact, we didn’t catch this because none of the examples use it in backend_driver.

I just added a units/notes_tests.py with this example added to it. Please add other regression tests here as you develop.

JDH

···

On Wed, Dec 10, 2008 at 12:36 AM, Jae-Joon Lee <lee.j.joon@…149…> wrote:

Current SVN (r6540) raise an error for the following code.