Skip to content
This repository

PEP8 compliance on artist.py #1168

Merged
merged 1 commit into from over 1 year ago

4 participants

Varoquaux Phil Elson Don't Add Me To Your Organization a.k.a The Travis Bot Michael Droettboom
Varoquaux
Collaborator

This is a new pull request on the pep8 compliance of patches.py, as asked by @pelson

Phil Elson
Collaborator

+1. Replaces #1153.

Don't Add Me To Your Organization a.k.a The Travis Bot

This pull request fails (merged 453e0ec into a7aaa83).

Michael Droettboom mdboom merged commit 028c959 into from
Michael Droettboom mdboom closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Sep 03, 2012
Varoquaux PEP8 453e0ec
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 122 additions and 111 deletions. Show diff stats Hide diff stats

  1. 233  lib/matplotlib/artist.py
233  lib/matplotlib/artist.py
... ...
@@ -1,5 +1,6 @@
1 1
 from __future__ import division, print_function
2  
-import re, warnings
  2
+import re
  3
+import warnings
3 4
 import matplotlib
4 5
 import matplotlib.cbook as cbook
5 6
 from matplotlib import docstring, rcParams
@@ -24,8 +25,6 @@
24 25
 # http://groups.google.com/groups?hl=en&lr=&threadm=mailman.5090.1098044946.5135.python-list%40python.org&rnum=1&prev=/groups%3Fq%3D__doc__%2Bauthor%253Ajdhunter%2540ace.bsd.uchicago.edu%26hl%3Den%26btnG%3DGoogle%2BSearch
25 26
 
26 27
 
27  
-
28  
-
29 28
 def allow_rasterization(draw):
30 29
     """
31 30
     Decorator for Artist.draw method. Provides routines
@@ -41,7 +40,6 @@ def before(artist, renderer):
41 40
         if artist.get_agg_filter() is not None:
42 41
             renderer.start_filter()
43 42
 
44  
-
45 43
     def after(artist, renderer):
46 44
 
47 45
         if artist.get_agg_filter() is not None:
@@ -59,7 +57,7 @@ def draw_wrapper(artist, renderer, *args, **kwargs):
59 57
     # "safe wrapping" to exactly replicate anything we haven't overridden above
60 58
     draw_wrapper.__name__ = draw.__name__
61 59
     draw_wrapper.__dict__ = draw.__dict__
62  
-    draw_wrapper.__doc__  = draw.__doc__
  60
+    draw_wrapper.__doc__ = draw.__doc__
63 61
     draw_wrapper._supports_rasterization = True
64 62
     return draw_wrapper
65 63
 
@@ -72,6 +70,7 @@ class Artist(object):
72 70
 
73 71
     aname = 'Artist'
74 72
     zorder = 0
  73
+
75 74
     def __init__(self):
76 75
         self.figure = None
77 76
 
@@ -92,7 +91,7 @@ def __init__(self):
92 91
 
93 92
         self.eventson = False  # fire events only if eventson
94 93
         self._oid = 0  # an observer id
95  
-        self._propobservers = {} # a dict from oids to funcs
  94
+        self._propobservers = {}  # a dict from oids to funcs
96 95
         try:
97 96
             self.axes = None
98 97
         except AttributeError:
@@ -125,18 +124,18 @@ def remove(self):
125 124
         Note: there is no support for removing the artist's legend entry.
126 125
         """
127 126
 
128  
-        # There is no method to set the callback.  Instead the parent should set
129  
-        # the _remove_method attribute directly.  This would be a protected
130  
-        # attribute if Python supported that sort of thing.  The callback
131  
-        # has one parameter, which is the child to be removed.
  127
+        # There is no method to set the callback.  Instead the parent should
  128
+        # set the _remove_method attribute directly.  This would be a
  129
+        # protected attribute if Python supported that sort of thing.  The
  130
+        # callback has one parameter, which is the child to be removed.
132 131
         if self._remove_method is not None:
133 132
             self._remove_method(self)
134 133
         else:
135 134
             raise NotImplementedError('cannot remove artist')
136 135
         # TODO: the fix for the collections relim problem is to move the
137  
-        # limits calculation into the artist itself, including the property
138  
-        # of whether or not the artist should affect the limits.  Then there
139  
-        # will be no distinction between axes.add_line, axes.add_patch, etc.
  136
+        # limits calculation into the artist itself, including the property of
  137
+        # whether or not the artist should affect the limits.  Then there will
  138
+        # be no distinction between axes.add_line, axes.add_patch, etc.
140 139
         # TODO: add legend support
141 140
 
142 141
     def have_units(self):
@@ -161,7 +160,8 @@ def convert_yunits(self, y):
161 160
         convert *y* using yaxis unit type
162 161
         """
163 162
         ax = getattr(self, 'axes', None)
164  
-        if ax is None or ax.yaxis is None: return y
  163
+        if ax is None or ax.yaxis is None:
  164
+            return y
165 165
         return ax.yaxis.convert_units(y)
166 166
 
167 167
     def set_axes(self, axes):
@@ -203,8 +203,10 @@ def remove_callback(self, oid):
203 203
                For adding callbacks
204 204
 
205 205
         """
206  
-        try: del self._propobservers[oid]
207  
-        except KeyError: pass
  206
+        try:
  207
+            del self._propobservers[oid]
  208
+        except KeyError:
  209
+            pass
208 210
 
209 211
     def pchanged(self):
210 212
         """
@@ -239,7 +241,7 @@ def get_transform(self):
239 241
         """
240 242
         if self._transform is None:
241 243
             self._transform = IdentityTransform()
242  
-        elif (not isinstance(self._transform, Transform) 
  244
+        elif (not isinstance(self._transform, Transform)
243 245
               and hasattr(self._transform, '_as_mpl_transform')):
244 246
             self._transform = self._transform._as_mpl_transform(self.axes)
245 247
         return self._transform
@@ -250,14 +252,13 @@ def hitlist(self, event):
250 252
         """
251 253
         L = []
252 254
         try:
253  
-            hascursor,info = self.contains(event)
  255
+            hascursor, info = self.contains(event)
254 256
             if hascursor:
255 257
                 L.append(self)
256 258
         except:
257 259
             import traceback
258 260
             traceback.print_exc()
259  
-            print("while checking",self.__class__)
260  
-
  261
+            print("while checking", self.__class__)
261 262
 
262 263
         for a in self.get_children():
263 264
             L.extend(a.hitlist(event))
@@ -277,12 +278,12 @@ def contains(self, mouseevent):
277 278
         selection, such as which points are contained in the pick radius.  See
278 279
         individual artists for details.
279 280
         """
280  
-        if callable(self._contains): return self._contains(self,mouseevent)
281  
-        #raise NotImplementedError,str(self.__class__)+" needs 'contains' method"
  281
+        if callable(self._contains):
  282
+            return self._contains(self, mouseevent)
282 283
         warnings.warn("'%s' needs 'contains' method" % self.__class__.__name__)
283  
-        return False,{}
  284
+        return False, {}
284 285
 
285  
-    def set_contains(self,picker):
  286
+    def set_contains(self, picker):
286 287
         """
287 288
         Replace the contains test used by this artist. The new picker
288 289
         should be a callable function which determines whether the
@@ -323,9 +324,9 @@ def pick(self, mouseevent):
323 324
         if self.pickable():
324 325
             picker = self.get_picker()
325 326
             if callable(picker):
326  
-                inside,prop = picker(self,mouseevent)
  327
+                inside, prop = picker(self, mouseevent)
327 328
             else:
328  
-                inside,prop = self.contains(mouseevent)
  329
+                inside, prop = self.contains(mouseevent)
329 330
             if inside:
330 331
                 self.figure.canvas.pick_event(mouseevent, self, **prop)
331 332
 
@@ -333,7 +334,7 @@ def pick(self, mouseevent):
333 334
         for a in self.get_children():
334 335
             # make sure the event happened in the same axes
335 336
             ax = getattr(a, 'axes', None)
336  
-            if mouseevent.inaxes is None or mouseevent.inaxes==ax:
  337
+            if mouseevent.inaxes is None or mouseevent.inaxes == ax:
337 338
                 # we need to check if mouseevent.inaxes is None
338 339
                 # because some objects associated with an axes (eg a
339 340
                 # tick label) can be outside the bounding box of the
@@ -399,7 +400,6 @@ def set_url(self, url):
399 400
         """
400 401
         self._url = url
401 402
 
402  
-
403 403
     def get_gid(self):
404 404
         """
405 405
         Returns the group id
@@ -499,7 +499,8 @@ def set_clip_path(self, path, transform=None):
499 499
         success = False
500 500
         if transform is None:
501 501
             if isinstance(path, Rectangle):
502  
-                self.clipbox = TransformedBbox(Bbox.unit(), path.get_transform())
  502
+                self.clipbox = TransformedBbox(Bbox.unit(),
  503
+                                              path.get_transform())
503 504
                 self._clippath = None
504 505
                 success = True
505 506
             elif isinstance(path, Patch):
@@ -612,7 +613,8 @@ def set_agg_filter(self, filter_func):
612 613
 
613 614
     def draw(self, renderer, *args, **kwargs):
614 615
         'Derived classes drawing method'
615  
-        if not self.get_visible(): return
  616
+        if not self.get_visible():
  617
+            return
616 618
 
617 619
     def set_alpha(self, alpha):
618 620
         """
@@ -644,7 +646,6 @@ def set_visible(self, b):
644 646
         self._visible = b
645 647
         self.pchanged()
646 648
 
647  
-
648 649
     def set_animated(self, b):
649 650
         """
650 651
         Set the artist's animation state.
@@ -662,15 +663,15 @@ def update(self, props):
662 663
         store = self.eventson
663 664
         self.eventson = False
664 665
         changed = False
665  
-        for k,v in props.iteritems():
666  
-            func = getattr(self, 'set_'+k, None)
  666
+        for k, v in props.iteritems():
  667
+            func = getattr(self, 'set_' + k, None)
667 668
             if func is None or not callable(func):
668  
-                raise AttributeError('Unknown property %s'%k)
  669
+                raise AttributeError('Unknown property %s' % k)
669 670
             func(v)
670 671
             changed = True
671 672
         self.eventson = store
672  
-        if changed: self.pchanged()
673  
-
  673
+        if changed:
  674
+            self.pchanged()
674 675
 
675 676
     def get_label(self):
676 677
         """
@@ -716,7 +717,6 @@ def update_from(self, other):
716 717
         self._label = other._label
717 718
         self.pchanged()
718 719
 
719  
-
720 720
     def properties(self):
721 721
         """
722 722
         return a dictionary mapping property name -> value for all Artist props
@@ -728,11 +728,11 @@ def set(self, **kwargs):
728 728
         A tkstyle set command, pass *kwargs* to set properties
729 729
         """
730 730
         ret = []
731  
-        for k,v in kwargs.iteritems():
  731
+        for k, v in kwargs.iteritems():
732 732
             k = k.lower()
733  
-            funcName = "set_%s"%k
734  
-            func = getattr(self,funcName)
735  
-            ret.extend( [func(v)] )
  733
+            funcName = "set_%s" % k
  734
+            func = getattr(self, funcName)
  735
+            ret.extend([func(v)])
736 736
         return ret
737 737
 
738 738
     def findobj(self, match=None, include_self=True):
@@ -760,15 +760,17 @@ def findobj(self, match=None, include_self=True):
760 760
         .. plot:: mpl_examples/pylab_examples/findobj_demo.py
761 761
         """
762 762
 
763  
-        if match is None: # always return True
764  
-            def matchfunc(x): return True
  763
+        if match is None:  # always return True
  764
+            def matchfunc(x):
  765
+                return True
765 766
         elif cbook.issubclass_safe(match, Artist):
766 767
             def matchfunc(x):
767 768
                 return isinstance(x, match)
768 769
         elif callable(match):
769 770
             matchfunc = match
770 771
         else:
771  
-            raise ValueError('match must be None, a matplotlib.artist.Artist subclass, or a callable')
  772
+            raise ValueError('match must be None, a matplotlib.artist.Artist '
  773
+                             'subclass, or a callable')
772 774
 
773 775
         artists = []
774 776
 
@@ -784,10 +786,6 @@ def matchfunc(x):
784 786
         return artists
785 787
 
786 788
 
787  
-
788  
-
789  
-
790  
-
791 789
 class ArtistInspector:
792 790
     """
793 791
     A helper class to inspect an :class:`~matplotlib.artist.Artist`
@@ -797,12 +795,13 @@ class ArtistInspector:
797 795
     def __init__(self, o):
798 796
         """
799 797
         Initialize the artist inspector with an
800  
-        :class:`~matplotlib.artist.Artist` or sequence of
801  
-        :class:`Artists`.  If a sequence is used, we assume it is a
802  
-        homogeneous sequence (all :class:`Artists` are of the same
803  
-        type) and it is your responsibility to make sure this is so.
  798
+        :class:`~matplotlib.artist.Artist` or sequence of :class:`Artists`.
  799
+        If a sequence is used, we assume it is a homogeneous sequence (all
  800
+        :class:`Artists` are of the same type) and it is your responsibility
  801
+        to make sure this is so.
804 802
         """
805  
-        if cbook.iterable(o) and len(o): o = o[0]
  803
+        if cbook.iterable(o) and len(o):
  804
+            o = o[0]
806 805
 
807 806
         self.oorig = o
808 807
         if not isinstance(o, type):
@@ -825,17 +824,20 @@ def get_aliases(self):
825 824
         """
826 825
         names = [name for name in dir(self.o) if
827 826
                  (name.startswith('set_') or name.startswith('get_'))
828  
-                 and callable(getattr(self.o,name))]
  827
+                 and callable(getattr(self.o, name))]
829 828
         aliases = {}
830 829
         for name in names:
831 830
             func = getattr(self.o, name)
832  
-            if not self.is_alias(func): continue
  831
+            if not self.is_alias(func):
  832
+                continue
833 833
             docstring = func.__doc__
834 834
             fullname = docstring[10:]
835 835
             aliases.setdefault(fullname[4:], {})[name[4:]] = None
836 836
         return aliases
837 837
 
838  
-    _get_valid_values_regex = re.compile(r"\n\s*ACCEPTS:\s*((?:.|\n)*?)(?:$|(?:\n\n))")
  838
+    _get_valid_values_regex = re.compile(
  839
+                r"\n\s*ACCEPTS:\s*((?:.|\n)*?)(?:$|(?:\n\n))")
  840
+
839 841
     def get_valid_values(self, attr):
840 842
         """
841 843
         Get the legal arguments for the setter associated with *attr*.
@@ -847,13 +849,14 @@ def get_valid_values(self, attr):
847 849
         "[ ``'-'`` | ``'--'`` | ``'-.'`` | ``':'`` | ``'steps'`` | ``'None'`` ]"
848 850
         """
849 851
 
850  
-        name = 'set_%s'%attr
  852
+        name = 'set_%s' % attr
851 853
         if not hasattr(self.o, name):
852  
-            raise AttributeError('%s has no function %s'%(self.o,name))
  854
+            raise AttributeError('%s has no function %s' % (self.o, name))
853 855
         func = getattr(self.o, name)
854 856
 
855 857
         docstring = func.__doc__
856  
-        if docstring is None: return 'unknown'
  858
+        if docstring is None:
  859
+            return 'unknown'
857 860
 
858 861
         if docstring.startswith('alias for '):
859 862
             return None
@@ -871,11 +874,14 @@ def _get_setters_and_targets(self):
871 874
 
872 875
         setters = []
873 876
         for name in dir(self.o):
874  
-            if not name.startswith('set_'): continue
  877
+            if not name.startswith('set_'):
  878
+                continue
875 879
             o = getattr(self.o, name)
876  
-            if not callable(o): continue
  880
+            if not callable(o):
  881
+                continue
877 882
             func = o
878  
-            if self.is_alias(func): continue
  883
+            if self.is_alias(func):
  884
+                continue
879 885
             source_class = self.o.__module__ + "." + self.o.__name__
880 886
             for cls in self.o.mro():
881 887
                 if name in cls.__dict__:
@@ -898,7 +904,8 @@ def is_alias(self, o):
898 904
         function.
899 905
         """
900 906
         ds = o.__doc__
901  
-        if ds is None: return False
  907
+        if ds is None:
  908
+            return False
902 909
         return ds.startswith('alias for ')
903 910
 
904 911
     def aliased_name(self, s):
@@ -912,11 +919,12 @@ def aliased_name(self, s):
912 919
         """
913 920
 
914 921
         if s in self.aliasd:
915  
-            return s + ''.join([' or %s' % x for x in self.aliasd[s].iterkeys()])
  922
+            return s + ''.join([' or %s' % x
  923
+                                for x
  924
+                                in self.aliasd[s].iterkeys()])
916 925
         else:
917 926
             return s
918 927
 
919  
-
920 928
     def aliased_name_rest(self, s, target):
921 929
         """
922 930
         return 'PROPNAME or alias' if *s* has an alias, else return
@@ -928,13 +936,13 @@ def aliased_name_rest(self, s, target):
928 936
         """
929 937
 
930 938
         if s in self.aliasd:
931  
-            aliases = ''.join([' or %s' % x for x in self.aliasd[s].iterkeys()])
  939
+            aliases = ''.join([' or %s' % x
  940
+                               for x
  941
+                               in self.aliasd[s].iterkeys()])
932 942
         else:
933 943
             aliases = ''
934 944
         return ':meth:`%s <%s>`%s' % (s, target, aliases)
935 945
 
936  
-
937  
-
938 946
     def pprint_setters(self, prop=None, leadingspace=2):
939 947
         """
940 948
         If *prop* is *None*, return a list of strings of all settable properies
@@ -945,12 +953,12 @@ def pprint_setters(self, prop=None, leadingspace=2):
945 953
         values.
946 954
         """
947 955
         if leadingspace:
948  
-            pad = ' '*leadingspace
  956
+            pad = ' ' * leadingspace
949 957
         else:
950  
-            pad  = ''
  958
+            pad = ''
951 959
         if prop is not None:
952 960
             accepts = self.get_valid_values(prop)
953  
-            return '%s%s: %s' %(pad, prop, accepts)
  961
+            return '%s%s: %s' % (pad, prop, accepts)
954 962
 
955 963
         attrs = self._get_setters_and_targets()
956 964
         attrs.sort()
@@ -960,7 +968,7 @@ def pprint_setters(self, prop=None, leadingspace=2):
960 968
             accepts = self.get_valid_values(prop)
961 969
             name = self.aliased_name(prop)
962 970
 
963  
-            lines.append('%s%s: %s' %(pad, name, accepts))
  971
+            lines.append('%s%s: %s' % (pad, name, accepts))
964 972
         return lines
965 973
 
966 974
     def pprint_setters_rest(self, prop=None, leadingspace=2):
@@ -973,32 +981,34 @@ def pprint_setters_rest(self, prop=None, leadingspace=2):
973 981
         values.
974 982
         """
975 983
         if leadingspace:
976  
-            pad = ' '*leadingspace
  984
+            pad = ' ' * leadingspace
977 985
         else:
978  
-            pad  = ''
  986
+            pad = ''
979 987
         if prop is not None:
980 988
             accepts = self.get_valid_values(prop)
981  
-            return '%s%s: %s' %(pad, prop, accepts)
  989
+            return '%s%s: %s' % (pad, prop, accepts)
982 990
 
983 991
         attrs = self._get_setters_and_targets()
984 992
         attrs.sort()
985 993
         lines = []
986 994
 
987 995
         ########
988  
-        names = [self.aliased_name_rest(prop, target) for prop, target in attrs]
  996
+        names = [self.aliased_name_rest(prop, target)
  997
+                 for prop, target
  998
+                 in attrs]
989 999
         accepts = [self.get_valid_values(prop) for prop, target in attrs]
990 1000
 
991 1001
         col0_len = max([len(n) for n in names])
992 1002
         col1_len = max([len(a) for a in accepts])
993  
-        table_formatstr = pad + '='*col0_len + '   ' + '='*col1_len
  1003
+        table_formatstr = pad + '=' * col0_len + '   ' + '=' * col1_len
994 1004
 
995 1005
         lines.append('')
996 1006
         lines.append(table_formatstr)
997  
-        lines.append(pad + 'Property'.ljust(col0_len+3) + \
  1007
+        lines.append(pad + 'Property'.ljust(col0_len + 3) + \
998 1008
                      'Description'.ljust(col1_len))
999 1009
         lines.append(table_formatstr)
1000 1010
 
1001  
-        lines.extend([pad + n.ljust(col0_len+3) + a.ljust(col1_len)
  1011
+        lines.extend([pad + n.ljust(col0_len + 3) + a.ljust(col1_len)
1002 1012
                       for n, a in zip(names, accepts)])
1003 1013
 
1004 1014
         lines.append(table_formatstr)
@@ -1010,10 +1020,9 @@ def pprint_setters_rest(self, prop=None, leadingspace=2):
1010 1020
             accepts = self.get_valid_values(prop)
1011 1021
             name = self.aliased_name_rest(prop, path)
1012 1022
 
1013  
-            lines.append('%s%s: %s' %(pad, name, accepts))
  1023
+            lines.append('%s%s: %s' % (pad, name, accepts))
1014 1024
         return lines
1015 1025
 
1016  
-
1017 1026
     def properties(self):
1018 1027
         """
1019 1028
         return a dictionary mapping property name -> value
@@ -1027,11 +1036,15 @@ def properties(self):
1027 1036
         d = dict()
1028 1037
         for name in getters:
1029 1038
             func = getattr(o, name)
1030  
-            if self.is_alias(func): continue
  1039
+            if self.is_alias(func):
  1040
+                continue
1031 1041
 
1032  
-            try: val = func()
1033  
-            except: continue
1034  
-            else: d[name[4:]] = val
  1042
+            try:
  1043
+                val = func()
  1044
+            except:
  1045
+                continue
  1046
+            else:
  1047
+                d[name[4:]] = val
1035 1048
 
1036 1049
         return d
1037 1050
 
@@ -1046,19 +1059,17 @@ def pprint_getters(self):
1046 1059
         lines = []
1047 1060
         for name in names:
1048 1061
             val = d[name]
1049  
-            if getattr(val, 'shape', ()) != () and len(val)>6:
  1062
+            if getattr(val, 'shape', ()) != () and len(val) > 6:
1050 1063
                 s = str(val[:6]) + '...'
1051 1064
             else:
1052 1065
                 s = str(val)
1053 1066
             s = s.replace('\n', ' ')
1054  
-            if len(s)>50:
  1067
+            if len(s) > 50:
1055 1068
                 s = s[:50] + '...'
1056 1069
             name = self.aliased_name(name)
1057  
-            lines.append('    %s = %s' %(name, s))
  1070
+            lines.append('    %s = %s' % (name, s))
1058 1071
         return lines
1059 1072
 
1060  
-
1061  
-
1062 1073
     def findobj(self, match=None):
1063 1074
         """
1064 1075
         Recursively find all :class:`matplotlib.artist.Artist`
@@ -1072,34 +1083,34 @@ def findobj(self, match=None):
1072 1083
 
1073 1084
         used to filter matches.
1074 1085
         """
1075  
-
1076  
-        if match is None: # always return True
1077  
-            def matchfunc(x): return True
  1086
+        if match is None:  # always return True
  1087
+            def matchfunc(x):
  1088
+                return True
1078 1089
         elif issubclass(match, Artist):
1079 1090
             def matchfunc(x):
1080 1091
                 return isinstance(x, match)
1081 1092
         elif callable(match):
1082 1093
             matchfunc = func
1083 1094
         else:
1084  
-            raise ValueError('match must be None, an matplotlib.artist.Artist subclass, or a callable')
1085  
-
  1095
+            raise ValueError('match must be None, an '
  1096
+                             'matplotlib.artist.Artist '
  1097
+                             'subclass, or a callable')
1086 1098
 
1087 1099
         artists = []
1088 1100
 
1089 1101
         for c in self.get_children():
1090 1102
             if matchfunc(c):
1091 1103
                 artists.append(c)
1092  
-            artists.extend([thisc for thisc in c.findobj(matchfunc) if matchfunc(thisc)])
  1104
+            artists.extend([thisc
  1105
+                            for thisc
  1106
+                            in c.findobj(matchfunc)
  1107
+                            if matchfunc(thisc)])
1093 1108
 
1094 1109
         if matchfunc(self):
1095 1110
             artists.append(self)
1096 1111
         return artists
1097 1112
 
1098 1113
 
1099  
-
1100  
-
1101  
-
1102  
-
1103 1114
 def getp(obj, property=None):
1104 1115
     """
1105 1116
     Return the value of object's property.  *property* is an optional string
@@ -1128,8 +1139,6 @@ def getp(obj, property=None):
1128 1139
 
1129 1140
       linewidth or lw = 2
1130 1141
     """
1131  
-
1132  
-
1133 1142
     if property is None:
1134 1143
         insp = ArtistInspector(obj)
1135 1144
         ret = insp.pprint_getters()
@@ -1142,6 +1151,7 @@ def getp(obj, property=None):
1142 1151
 # alias
1143 1152
 get = getp
1144 1153
 
  1154
+
1145 1155
 def setp(obj, *args, **kwargs):
1146 1156
     """
1147 1157
     Set a property on an artist object.
@@ -1189,11 +1199,11 @@ def setp(obj, *args, **kwargs):
1189 1199
 
1190 1200
     insp = ArtistInspector(obj)
1191 1201
 
1192  
-    if len(kwargs)==0 and len(args)==0:
  1202
+    if len(kwargs) == 0 and len(args) == 0:
1193 1203
         print('\n'.join(insp.pprint_setters()))
1194 1204
         return
1195 1205
 
1196  
-    if len(kwargs)==0 and len(args)==1:
  1206
+    if len(kwargs) == 0 and len(args) == 1:
1197 1207
         print(insp.pprint_setters(prop=args[0]))
1198 1208
         return
1199 1209
 
@@ -1202,28 +1212,29 @@ def setp(obj, *args, **kwargs):
1202 1212
     else:
1203 1213
         objs = cbook.flatten(obj)
1204 1214
 
1205  
-
1206  
-    if len(args)%2:
  1215
+    if len(args) % 2:
1207 1216
         raise ValueError('The set args must be string, value pairs')
1208 1217
 
1209 1218
     funcvals = []
1210  
-    for i in range(0, len(args)-1, 2):
1211  
-        funcvals.append((args[i], args[i+1]))
  1219
+    for i in range(0, len(args) - 1, 2):
  1220
+        funcvals.append((args[i], args[i + 1]))
1212 1221
     funcvals.extend(kwargs.iteritems())
1213 1222
 
1214 1223
     ret = []
1215 1224
     for o in objs:
1216 1225
         for s, val in funcvals:
1217 1226
             s = s.lower()
1218  
-            funcName = "set_%s"%s
  1227
+            funcName = "set_%s" % s
1219 1228
             func = getattr(o, funcName)
1220  
-            ret.extend( [func(val)] )
  1229
+            ret.extend([func(val)])
1221 1230
     return [x for x in cbook.flatten(ret)]
1222 1231
 
  1232
+
1223 1233
 def kwdoc(a):
1224 1234
     hardcopy = matplotlib.rcParams['docstring.hardcopy']
1225 1235
     if hardcopy:
1226  
-        return '\n'.join(ArtistInspector(a).pprint_setters_rest(leadingspace=2))
  1236
+        return '\n'.join(ArtistInspector(a).pprint_setters_rest(
  1237
+                                            leadingspace=2))
1227 1238
     else:
1228 1239
         return '\n'.join(ArtistInspector(a).pprint_setters(leadingspace=2))
1229 1240
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.