Skip to content

Commit 466a6ac

Browse files
committed
Merged revisions 8573 via svnmerge from
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v1_0_maint ........ r8573 | efiring | 2010-07-24 11:59:55 -1000 (Sat, 24 Jul 2010) | 3 lines rcParams: don't include deprecated keys. Some other rc cleanups are included in this changeset. ........ svn path=/trunk/matplotlib/; revision=8574
1 parent 7db4af0 commit 466a6ac

File tree

2 files changed

+43
-18
lines changed

2 files changed

+43
-18
lines changed

lib/matplotlib/__init__.py

+32-7
Original file line numberDiff line numberDiff line change
@@ -632,24 +632,49 @@ class RcParams(dict):
632632

633633
validate = dict([ (key, converter) for key, (default, converter) in \
634634
defaultParams.iteritems() ])
635+
msg_depr = "%s is deprecated and replaced with %s; please use the latter."
636+
msg_depr_ignore = "%s is deprecated and ignored. Use %s"
635637

636638
def __setitem__(self, key, val):
637639
try:
638640
if key in _deprecated_map.keys():
639641
alt = _deprecated_map[key]
640-
warnings.warn('%s is deprecated in matplotlibrc. Use %s \
641-
instead.'% (key, alt))
642+
warnings.warn(self.msg_depr % (key, alt))
642643
key = alt
643644
elif key in _deprecated_ignore_map:
644645
alt = _deprecated_ignore_map[key]
645-
warnings.warn('%s is deprecated. Use %s instead.'% (key, alt))
646+
warnings.warn(self.msg_depr_ignore % (key, alt))
646647
return
647648
cval = self.validate[key](val)
648649
dict.__setitem__(self, key, cval)
649650
except KeyError:
650651
raise KeyError('%s is not a valid rc parameter.\
651-
See rcParams.keys() for a list of valid parameters.'%key)
652+
See rcParams.keys() for a list of valid parameters.' % (key,))
652653

654+
def __getitem__(self, key):
655+
if key in _deprecated_map.keys():
656+
alt = _deprecated_map[key]
657+
warnings.warn(self.msg_depr % (key, alt))
658+
key = alt
659+
elif key in _deprecated_ignore_map:
660+
alt = _deprecated_ignore_map[key]
661+
warnings.warn(self.msg_depr_ignore % (key, alt))
662+
key = alt
663+
return dict.__getitem__(self, key)
664+
665+
def keys(self):
666+
"""
667+
Return sorted list of keys.
668+
"""
669+
k = dict.keys(self)
670+
k.sort()
671+
return k
672+
673+
def values(self):
674+
"""
675+
Return values in order of sorted keys.
676+
"""
677+
return [self[k] for k in self.keys()]
653678

654679
def rc_params(fail_on_error=False):
655680
'Return the default params updated from the values in the rc file'
@@ -810,12 +835,12 @@ def rc(group, **kwargs):
810835
for k,v in kwargs.items():
811836
name = aliases.get(k) or k
812837
key = '%s.%s' % (g, name)
813-
if key not in rcParams:
838+
try:
839+
rcParams[key] = v
840+
except KeyError:
814841
raise KeyError('Unrecognized key "%s" for group "%s" and name "%s"' %
815842
(key, g, name))
816843

817-
rcParams[key] = v
818-
819844
def rcdefaults():
820845
"""
821846
Restore the default rc params - the ones that were created at

lib/matplotlib/rcsetup.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,8 @@ def __call__(self, s):
347347
defaultParams = {
348348
'backend' : ['Agg', validate_backend], # agg is certainly present
349349
'backend_fallback' : [True, validate_bool], # agg is certainly present
350-
'numerix' : ['obsolete', validate_numerix],
351-
'maskedarray' : ['obsolete', validate_maskedarray], #to be removed
350+
#'numerix' : ['obsolete', validate_numerix],
351+
#'maskedarray' : ['obsolete', validate_maskedarray], #to be removed
352352
'toolbar' : ['toolbar2', validate_toolbar],
353353
'datapath' : [None, validate_path_exists], # handled by _get_data_path_cached
354354
'units' : [False, validate_bool],
@@ -385,7 +385,7 @@ def __call__(self, s):
385385
'font.variant' : ['normal', str], #
386386
'font.stretch' : ['normal', str], #
387387
'font.weight' : ['normal', str], #
388-
'font.size' : [12.0, validate_float], #
388+
'font.size' : [12, validate_float], # Base font size in points
389389
'font.serif' : [['Bitstream Vera Serif', 'DejaVu Serif',
390390
'New Century Schoolbook', 'Century Schoolbook L',
391391
'Utopia', 'ITC Bookman', 'Bookman',
@@ -412,13 +412,16 @@ def __call__(self, s):
412412
'text.latex.preamble' : [[''], validate_stringlist],
413413
'text.latex.preview' : [False, validate_bool],
414414
'text.dvipnghack' : [None, validate_bool_maybe_none],
415-
'text.fontstyle' : ['normal', str],
416-
'text.fontangle' : ['normal', str],
417-
'text.fontvariant' : ['normal', str],
418-
'text.fontweight' : ['normal', str],
419-
'text.fontsize' : ['medium', validate_fontsize],
420415
'text.hinting' : [True, validate_bool],
421416

417+
# The following are deprecated and replaced by, e.g., 'font.style'
418+
#'text.fontstyle' : ['normal', str],
419+
#'text.fontangle' : ['normal', str],
420+
#'text.fontvariant' : ['normal', str],
421+
#'text.fontweight' : ['normal', str],
422+
#'text.fontsize' : ['medium', validate_fontsize],
423+
424+
422425
'mathtext.cal' : ['cursive', validate_font_properties],
423426
'mathtext.rm' : ['serif', validate_font_properties],
424427
'mathtext.tt' : ['monospace', validate_font_properties],
@@ -483,9 +486,6 @@ def __call__(self, s):
483486

484487
'legend.shadow' : [False, validate_bool],
485488

486-
487-
488-
489489
# tick properties
490490
'xtick.major.size' : [4, validate_float], # major xtick size in points
491491
'xtick.minor.size' : [2, validate_float], # minor xtick size in points

0 commit comments

Comments
 (0)