@@ -706,8 +706,8 @@ class RcParams(dict):
706706 :mod:`matplotlib.rcsetup`
707707 """
708708
709- validate = dict ([ (key , converter ) for key , (default , converter ) in \
710- defaultParams .iteritems () ] )
709+ validate = dict ((key , converter ) for key , (default , converter ) in \
710+ defaultParams .iteritems ())
711711 msg_depr = "%s is deprecated and replaced with %s; please use the latter."
712712 msg_depr_ignore = "%s is deprecated and ignored. Use %s"
713713
@@ -738,6 +738,17 @@ def __getitem__(self, key):
738738 key = alt
739739 return dict .__getitem__ (self , key )
740740
741+ def __repr__ (self ):
742+ import pprint
743+ class_name = self .__class__ .__name__
744+ indent = len (class_name ) + 1
745+ repr_split = pprint .pformat (dict (self ), indent = 1 , width = 80 - indent ).split ('\n ' )
746+ repr_indented = ('\n ' + ' ' * indent ).join (repr_split )
747+ return '{}({})' .format (class_name , repr_indented )
748+
749+ def __str__ (self ):
750+ return '\n ' .join ('{}: {}' .format (k , v ) for k , v in sorted (self .items ()))
751+
741752 def keys (self ):
742753 """
743754 Return sorted list of keys.
@@ -750,22 +761,24 @@ def values(self):
750761 """
751762 Return values in order of sorted keys.
752763 """
753- return [self [k ] for k in self .iterkeys ()]
764+ return [self [k ] for k in self .keys ()]
754765
755- def find_all (self , key_contains ):
766+ def find_all (self , pattern ):
756767 """
757768 Return the subset of this RcParams dictionary for which the given
758- ``key_contains `` string is found somewhere in the key.
769+ ``pattern `` string is found, by :func:`re.search`, somewhere in the key.
759770
760771 .. note::
761772
762773 Changes to the returned dictionary are *not* propagated to
763774 the parent RcParams dictionary.
764775
765776 """
777+ import re
778+ pattern_re = re .compile (pattern )
766779 return RcParams ((key , value )
767780 for key , value in self .items ()
768- if key_contains in key )
781+ if pattern_re . search ( key ) )
769782
770783
771784def rc_params (fail_on_error = False ):
0 commit comments