@@ -835,7 +835,16 @@ def __len__(self):
835
835
return sum (len (mapping ) for mapping in self ._namespace_maps )
836
836
837
837
def __repr__ (self ):
838
- return repr (dict (self .items ()))
838
+ class_name = self .__class__ .__name__
839
+ indent = len (class_name ) + 1
840
+ with _api .suppress_matplotlib_deprecation_warning ():
841
+ repr_split = pprint .pformat (dict (self .items ()), indent = 1 ,
842
+ width = 80 - indent ).split ('\n ' )
843
+ repr_indented = ('\n ' + ' ' * indent ).join (repr_split )
844
+ return f'{ class_name } ({ repr_indented } )'
845
+
846
+ def __str__ (self ):
847
+ return '\n ' .join (map ('{0[0]}: {0[1]}' .format , sorted (self .items ())))
839
848
840
849
def keys (self ):
841
850
keys = (
@@ -897,7 +906,21 @@ def update(self, other=(), /, **kwds):
897
906
def copy (self ):
898
907
return deepcopy (self )
899
908
900
- # MutableMapping.register(RcParams)
909
+ def find_all (self , pattern ):
910
+ """
911
+ Return the subset of this RcParams dictionary whose keys match,
912
+ using :func:`re.search`, the given ``pattern``.
913
+
914
+ .. note::
915
+
916
+ Changes to the returned dictionary are *not* propagated to
917
+ the parent RcParams dictionary.
918
+
919
+ """
920
+ pattern_re = re .compile (pattern )
921
+ return RcParams ((key , value )
922
+ for key , value in self .items ()
923
+ if pattern_re .search (key ))
901
924
902
925
903
926
def rc_params (fail_on_error = False ):
0 commit comments