107
107
import distutils .version
108
108
from itertools import chain
109
109
110
+ from collections import MutableMapping
110
111
import io
111
112
import inspect
112
113
import locale
@@ -870,7 +871,7 @@ def matplotlib_fname():
870
871
_obsolete_set ))
871
872
872
873
873
- class RcParams (dict ):
874
+ class RcParams (MutableMapping , dict ):
874
875
875
876
"""
876
877
A dictionary object including validation
@@ -891,8 +892,7 @@ class RcParams(dict):
891
892
892
893
# validate values on the way in
893
894
def __init__ (self , * args , ** kwargs ):
894
- for k , v in six .iteritems (dict (* args , ** kwargs )):
895
- self [k ] = v
895
+ self .update (* args , ** kwargs )
896
896
897
897
def __setitem__ (self , key , val ):
898
898
try :
@@ -942,16 +942,6 @@ def __getitem__(self, key):
942
942
else :
943
943
return val
944
944
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
-
955
945
def __repr__ (self ):
956
946
import pprint
957
947
class_name = self .__class__ .__name__
@@ -965,17 +955,12 @@ def __str__(self):
965
955
return '\n ' .join ('{0}: {1}' .format (k , v )
966
956
for k , v in sorted (self .items ()))
967
957
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 ):
975
959
"""
976
- Return values in order of sorted keys.
960
+ Yield sorted list of keys.
977
961
"""
978
- return [self [k ] for k in self ]
962
+ for k in sorted (dict .__iter__ (self )):
963
+ yield k
979
964
980
965
def find_all (self , pattern ):
981
966
"""
0 commit comments