John, is this due to the recent __init__ patch in
> matplotlib? I haven't committed any of that, as I am in
> the middle of the cvs->svn transition at ipython's site,
> and without net access at home (moving), so I'm sort of
> crippled right now.
> I tried to fix backends/__init__.py to work with existing
> ipython distributions. But I only tested calling plot
> commands from ipython and not run. The latter exposes the
> bug. I think this should be fixed on the matplotlib end,
> since I don't want to require everyone to always have the
> latest ipython. I'll take a look and see if I can figure
> out a workaround.
The problem appears to be that the draw_if_interactive function pylab
gets by calling pylab_setup is not the same as the
backends.draw_if_interactive. Thus the "called" flag you set in
backend.draw_if_interactive = flag_calls(backend.draw_if_interactive)
is not set on the pylab.draw_if_interactive. I tried to fix this by
modifying backends_init.py as follows, so that both functions would be
the same (in CVS).
'return new_figure_manager, draw_if_interactive and show for pylab'
# Import the requested backend into a generic module object
if pylabcache is not None: return pylabcache
backend_name = 'backend_'+backend.lower()
backend_mod = __import__('matplotlib.backends.'+backend_name,
return new_figure_manager, draw_if_interactive, show
# a hack to keep old versions of ipython working with mpl after bug
# fix #1209354
pylabcache = None
if 'IPython.Shell' in sys.modules:
pylabcache = pylab_setup()
new_figure_manager, draw_if_interactive, show = pylabcache
Thus the symbols new_figure_manager, draw_if_interactive, show are
still defined at module level when pylab is imported from ipython.
pylab gets it draw_if_interactive symbol with
from backends import pylab_setup
new_figure_manager, draw_if_interactive, show = pylab_setup()
The goal is for backends.draw_if_interactive and
pylab.draw_if_interactive to be the same symbol (so Shell.py will not
But it is clear that they are not the same function
In : import matplotlib.backends
In : matplotlib.backends.draw_if_interactive.jdh = 'test'
In : draw_if_interactive.jdh
Traceback (most recent call last):
File "<console>", line 1, in ?
AttributeError: 'function' object has no attribute 'jdh'
What am I missing? I verified that pylab_setup is returning
pylabcache when run from ipython, and yet the draw_if_interactive
function is not shared??