|
From: <jd...@us...> - 2008-06-02 15:07:18
|
Revision: 5360
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5360&view=rev
Author: jdh2358
Date: 2008-06-02 08:06:41 -0700 (Mon, 02 Jun 2008)
Log Message:
-----------
added switch_backend bugfix from sf patch 1979402
Modified Paths:
--------------
branches/v0_91_maint/lib/matplotlib/__init__.py
branches/v0_91_maint/lib/matplotlib/pyplot.py
Modified: branches/v0_91_maint/lib/matplotlib/__init__.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/__init__.py 2008-06-02 14:54:41 UTC (rev 5359)
+++ branches/v0_91_maint/lib/matplotlib/__init__.py 2008-06-02 15:06:41 UTC (rev 5360)
@@ -733,7 +733,7 @@
or matplotlib.backends is imported for the first time.
"""
-def use(arg):
+def use(arg, warn=True):
"""
Set the matplotlib backend to one of the known backends.
@@ -745,12 +745,17 @@
will specify a default of pdf output generated by Cairo.
- Note: this function must be called *before* importing pylab
- for the first time; or, if you are not using pylab, it must
- be called before importing matplotlib.backends.
+ Note: this function must be called *before* importing pylab for
+ the first time; or, if you are not using pylab, it must be called
+ before importing matplotlib.backends. If warn is True, a warning
+ is issued if you try and callthis after pylab or pyplot have been
+ loaded. In certain black magic use cases, eg
+ pyplot.switch_backends, we are doing the reloading necessary to
+ make the backend switch work (in some cases, eg pure image
+ backends) so one can set warn=False to supporess the warnings
"""
if 'matplotlib.backends' in sys.modules:
- warnings.warn(_use_error_msg)
+ if warn: warnings.warn(_use_error_msg)
be_parts = arg.split('.')
name = validate_backend(be_parts[0])
rcParams['backend'] = name
Modified: branches/v0_91_maint/lib/matplotlib/pyplot.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/pyplot.py 2008-06-02 14:54:41 UTC (rev 5359)
+++ branches/v0_91_maint/lib/matplotlib/pyplot.py 2008-06-02 15:06:41 UTC (rev 5360)
@@ -50,12 +50,12 @@
"""
close('all')
global new_figure_manager, draw_if_interactive, show
- matplotlib.use(newbackend)
- reload(backends)
- from backends import new_figure_manager, draw_if_interactive, show
+ matplotlib.use(newbackend, warn=False)
+ reload(matplotlib.backends)
+ from matplotlib.backends import pylab_setup
+ new_figure_manager, draw_if_interactive, show = pylab_setup()
-
def isinteractive():
"""
Return the interactive status
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|