Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2aa6683

Browse files
committed
Warning instead of exception if matplotlib.use() is called too late.
svn path=/trunk/matplotlib/; revision=4790
1 parent aaf1cad commit 2aa6683

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2007-12-26 Reduce too-late use of matplotlib.use() to a warning
2+
instead of an exception, for backwards compatibility - EF
3+
14
2007-12-25 Fix bug in errorbar, identified by Noriko Minakawa - EF
25

36
2007-12-25 Changed masked array importing to work with the upcoming

lib/matplotlib/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -727,8 +727,11 @@ def rcdefaults():
727727
except:
728728
from config import rcParams, rcdefaults
729729

730-
_use_error_msg = """ matplotlib.use() must be called *before* pylab
731-
or matplotlib.backends is imported for the first time."""
730+
_use_error_msg = """ This call to matplotlib.use() has no effect
731+
because the the backend has already been chosen;
732+
matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
733+
or matplotlib.backends is imported for the first time.
734+
"""
732735

733736
def use(arg):
734737
"""
@@ -747,7 +750,7 @@ def use(arg):
747750
be called before importing matplotlib.backends.
748751
"""
749752
if 'matplotlib.backends' in sys.modules:
750-
raise RuntimeError(_use_error_msg)
753+
warnings.warn(_use_error_msg)
751754
be_parts = arg.split('.')
752755
name = validate_backend(be_parts[0])
753756
rcParams['backend'] = name

0 commit comments

Comments
 (0)