Question to OO matplotlub tutorial

Well, I'll be damned. I really can't believe this hasn't cropped up
before -- it's a real bug.

The errant code is in matplotlib/backends/__init___.py

# Import the requested backend into a generic module object
backend_name = 'backend_'+backend.lower()
backend_mod = __import__('matplotlib.backends.'+backend_name,
                         globals(),locals(),[backend_name])

Where the default backend is being imported. These changes were
introduced many moons ago by Fernando when he was cleaning up the
backend import for ipython/pylab. Then need top be moved to a
function or otherwise deferred until pylab asks for them, to prevent
the kind of problem you are seeing.

As a workaround, add these two lines at the top of your script:

import matplotlib
matplotlib.use('Agg')

or change the default backend in the rc file to 'Agg'. Even though
there are 2 good workarounds, I still consider this to be a little bug,
because the OO interface shouldn't be doing any magic like importing a
backend implicitly. Would you be willing to file a bug report on the
sourceforge site?

Thanks,
JDH

···

Am Freitag, 13. Mai 2005 18:49 schrieb John Hunter:

    >> >>>>> "Florian" == Florian Lindner <mailinglists@...606...>
    >> writes:
    >>
    > No. I pasted the complete script into the mail. There is
    > nothing else I execute...
    >> Please post the following commands, or their equivalent for
    >> your platform, and their output. Please include the commands
    >> you actually type in your post.
    >>
    >> > cat test.py > /usr/bin/python2.4 ./test.py --verbose-helpful

    > Here we go:

Quoting John Hunter <jdhunter@...8...>:

Well, I'll be damned. I really can't believe this hasn't cropped up
before -- it's a real bug.

The errant code is in matplotlib/backends/__init___.py

# Import the requested backend into a generic module object
backend_name = 'backend_'+backend.lower()
backend_mod = __import__('matplotlib.backends.'+backend_name,
                         globals(),locals(),[backend_name])

Where the default backend is being imported. These changes were
introduced many moons ago by Fernando when he was cleaning up the
backend import for ipython/pylab. Then need top be moved to a
function or otherwise deferred until pylab asks for them, to prevent
the kind of problem you are seeing.

sorry 'bout that, a pure effect of my modifying code in an overall system (the
mpl OO structure) I knew nothing about...

Cheers,

f

Could you file the backreport? I'm not very involved in the matplotlib
development and therefore I'm sure your report could be much more precise.

Regards,

Florian

···

Am Samstag, 14. Mai 2005 23:05 schrieb John Hunter:

    > Am Freitag, 13. Mai 2005 18:49 schrieb John Hunter:
    >> >>>>> "Florian" == Florian Lindner <mailinglists@...606...>
    >>
    >> writes:

    > No. I pasted the complete script into the mail. There is
    > nothing else I execute...

    >> Please post the following commands, or their equivalent for
    >> your platform, and their output. Please include the commands
    >> you actually type in your post.
    >>
    >> > cat test.py > /usr/bin/python2.4 ./test.py --verbose-helpful

    > Here we go:

Well, I'll be damned. I really can't believe this hasn't cropped up
before -- it's a real bug.

The errant code is in matplotlib/backends/__init___.py

# Import the requested backend into a generic module object
backend_name = 'backend_'+backend.lower()
backend_mod = __import__('matplotlib.backends.'+backend_name,
                         globals(),locals(),[backend_name])

Where the default backend is being imported. These changes were
introduced many moons ago by Fernando when he was cleaning up the
backend import for ipython/pylab. Then need top be moved to a
function or otherwise deferred until pylab asks for them, to prevent
the kind of problem you are seeing.

As a workaround, add these two lines at the top of your script:

import matplotlib
matplotlib.use('Agg')

or change the default backend in the rc file to 'Agg'. Even though
there are 2 good workarounds, I still consider this to be a little bug,
because the OO interface shouldn't be doing any magic like importing a
backend implicitly. Would you be willing to file a bug report on the
sourceforge site?

I think before asking this you might ask yourself:
Would I prefer John to spend his time on this,
or on development?

Just my opion,
Alan Isaac

···

On Sun, 15 May 2005, Florian Lindner apparently wrote:

Could you file the backreport? I'm not very involved in
the matplotlib development and therefore I'm sure your
report could be much more precise.

Whatever. Done.

···

Am Sonntag, 15. Mai 2005 19:35 schrieb Alan G Isaac:

On Sun, 15 May 2005, Florian Lindner apparently wrote:
> Could you file the backreport? I'm not very involved in
> the matplotlib development and therefore I'm sure your
> report could be much more precise.

I think before asking this you might ask yourself:
Would I prefer John to spend his time on this,
or on development?

Just my opion,