107107import distutils .version
108108from itertools import chain
109109
110+ from collections import MutableMapping
110111import io
111112import inspect
112113import locale
@@ -870,7 +871,7 @@ def matplotlib_fname():
870871 _obsolete_set ))
871872
872873
873- class RcParams (dict ):
874+ class RcParams (MutableMapping , dict ):
874875
875876 """
876877 A dictionary object including validation
@@ -891,8 +892,7 @@ class RcParams(dict):
891892
892893 # validate values on the way in
893894 def __init__ (self , * args , ** kwargs ):
894- for k , v in six .iteritems (dict (* args , ** kwargs )):
895- self [k ] = v
895+ self .update (* args , ** kwargs )
896896
897897 def __setitem__ (self , key , val ):
898898 try :
@@ -942,16 +942,6 @@ def __getitem__(self, key):
942942 else :
943943 return val
944944
945- # http://stackoverflow.com/questions/2390827
946- # (how-to-properly-subclass-dict-and-override-get-set)
947- # the default dict `update` does not use __setitem__
948- # so rcParams.update(...) (such as in seaborn) side-steps
949- # all of the validation over-ride update to force
950- # through __setitem__
951- def update (self , * args , ** kwargs ):
952- for k , v in six .iteritems (dict (* args , ** kwargs )):
953- self [k ] = v
954-
955945 def __repr__ (self ):
956946 import pprint
957947 class_name = self .__class__ .__name__
@@ -965,17 +955,12 @@ def __str__(self):
965955 return '\n ' .join ('{0}: {1}' .format (k , v )
966956 for k , v in sorted (self .items ()))
967957
968- def keys (self ):
969- """
970- Return sorted list of keys.
971- """
972- return sorted (self )
973-
974- def values (self ):
958+ def __iter__ (self ):
975959 """
976- Return values in order of sorted keys.
960+ Yield sorted list of keys.
977961 """
978- return [self [k ] for k in self ]
962+ for k in sorted (dict .__iter__ (self )):
963+ yield k
979964
980965 def find_all (self , pattern ):
981966 """
0 commit comments