Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b97abc9

Browse files
committed
Merge pull request matplotlib#3507 from cimarronm/pep8_fixes
PEP8 : general pep8 fixes
2 parents 5f25b5e + bf4fa9a commit b97abc9

File tree

9 files changed

+803
-664
lines changed

9 files changed

+803
-664
lines changed

lib/matplotlib/__init__.py

Lines changed: 108 additions & 78 deletions
Large diffs are not rendered by default.

lib/matplotlib/_pylab_helpers.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
unicode_literals)
66

77
import six
8-
9-
import sys, gc
10-
8+
import sys
9+
import gc
1110
import atexit
1211

1312

1413
def error_msg(msg):
1514
print(msg, file=sys.stderr)
1615

16+
1717
class Gcf(object):
1818
"""
1919
Singleton to manage a set of integer-numbered figures.
@@ -54,7 +54,8 @@ def destroy(num):
5454
In the interactive backends, this is bound to the
5555
window "destroy" and "delete" events.
5656
"""
57-
if not Gcf.has_fignum(num): return
57+
if not Gcf.has_fignum(num):
58+
return
5859
manager = Gcf.figs[num]
5960
manager.canvas.mpl_disconnect(manager._cidgcf)
6061

@@ -67,7 +68,6 @@ def destroy(num):
6768
Gcf._activeQue.append(f)
6869

6970
del Gcf.figs[num]
70-
#print len(Gcf.figs.keys()), len(Gcf._activeQue)
7171
manager.destroy()
7272
gc.collect(1)
7373

@@ -118,9 +118,10 @@ def get_active():
118118
"""
119119
Return the manager of the active figure, or *None*.
120120
"""
121-
if len(Gcf._activeQue)==0:
121+
if len(Gcf._activeQue) == 0:
122122
return None
123-
else: return Gcf._activeQue[-1]
123+
else:
124+
return Gcf._activeQue[-1]
124125

125126
@staticmethod
126127
def set_active(manager):
@@ -130,7 +131,8 @@ def set_active(manager):
130131
oldQue = Gcf._activeQue[:]
131132
Gcf._activeQue = []
132133
for m in oldQue:
133-
if m != manager: Gcf._activeQue.append(m)
134+
if m != manager:
135+
Gcf._activeQue.append(m)
134136
Gcf._activeQue.append(manager)
135137
Gcf.figs[manager.num] = manager
136138

lib/matplotlib/afm.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
import re
4545
from ._mathtext_data import uni2type1
4646

47-
#Convert string the a python type
47+
# Convert string the a python type
4848

4949
# some afm files have floats where we are expecting ints -- there is
5050
# probably a better way to handle this (support floats, round rather
@@ -155,13 +155,13 @@ def _parse_header(fh):
155155
if line.startswith(b'Comment'):
156156
continue
157157
lst = line.split(b' ', 1)
158-
#print '%-s\t%-d line :: %-s' % ( fh.name, len(lst), line )
158+
159159
key = lst[0]
160160
if len(lst) == 2:
161161
val = lst[1]
162162
else:
163163
val = b''
164-
#key, val = line.split(' ', 1)
164+
165165
try:
166166
d[key] = headerConverters[key](val)
167167
except ValueError:
@@ -170,7 +170,7 @@ def _parse_header(fh):
170170
continue
171171
except KeyError:
172172
print('Found an unknown keyword in AFM header (was %s)' % key,
173-
file=sys.stderr)
173+
file=sys.stderr)
174174
continue
175175
if key == b'StartCharMetrics':
176176
return d
@@ -517,7 +517,8 @@ def get_familyname(self):
517517

518518
# FamilyName not specified so we'll make a guess
519519
name = self.get_fullname()
520-
extras = br'(?i)([ -](regular|plain|italic|oblique|bold|semibold|light|ultralight|extra|condensed))+$'
520+
extras = (br'(?i)([ -](regular|plain|italic|oblique|bold|semibold|'
521+
br'light|ultralight|extra|condensed))+$')
521522
return re.sub(extras, '', name)
522523

523524
def get_weight(self):

lib/matplotlib/artist.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
import matplotlib
1010
import matplotlib.cbook as cbook
1111
from matplotlib import docstring, rcParams
12-
from .transforms import Bbox, IdentityTransform, TransformedBbox, \
13-
TransformedPath, Transform
12+
from .transforms import (Bbox, IdentityTransform, TransformedBbox,
13+
TransformedPath, Transform)
1414
from .path import Path
1515

16-
## Note, matplotlib artists use the doc strings for set and get
16+
# Note, matplotlib artists use the doc strings for set and get
1717
# methods to enable the introspection methods of setp and getp. Every
1818
# set_* method should have a docstring containing the line
1919
#
@@ -158,7 +158,6 @@ def convert_xunits(self, x):
158158
"""
159159
ax = getattr(self, 'axes', None)
160160
if ax is None or ax.xaxis is None:
161-
#print 'artist.convert_xunits no conversion: ax=%s'%ax
162161
return x
163162
return ax.xaxis.convert_units(x)
164163

@@ -584,7 +583,7 @@ def set_clip_path(self, path, transform=None):
584583
if transform is None:
585584
if isinstance(path, Rectangle):
586585
self.clipbox = TransformedBbox(Bbox.unit(),
587-
path.get_transform())
586+
path.get_transform())
588587
self._clippath = None
589588
success = True
590589
elif isinstance(path, Patch):
@@ -866,8 +865,8 @@ def matchfunc(x):
866865
if matchfunc(c):
867866
artists.append(c)
868867
artists.extend([thisc for thisc in
869-
c.findobj(matchfunc, include_self=False)
870-
if matchfunc(thisc)])
868+
c.findobj(matchfunc, include_self=False)
869+
if matchfunc(thisc)])
871870

872871
if include_self and matchfunc(self):
873872
artists.append(self)
@@ -924,7 +923,8 @@ def get_aliases(self):
924923
return aliases
925924

926925
_get_valid_values_regex = re.compile(
927-
r"\n\s*ACCEPTS:\s*((?:.|\n)*?)(?:$|(?:\n\n))")
926+
r"\n\s*ACCEPTS:\s*((?:.|\n)*?)(?:$|(?:\n\n))"
927+
)
928928

929929
def get_valid_values(self, attr):
930930
"""
@@ -934,7 +934,8 @@ def get_valid_values(self, attr):
934934
for a line that begins with ACCEPTS:
935935
936936
e.g., for a line linestyle, return
937-
"[ ``'-'`` | ``'--'`` | ``'-.'`` | ``':'`` | ``'steps'`` | ``'None'`` ]"
937+
"[ ``'-'`` | ``'--'`` | ``'-.'`` | ``':'`` | ``'steps'`` | ``'None'``
938+
]"
938939
"""
939940

940941
name = 'set_%s' % attr
@@ -1094,7 +1095,7 @@ def pprint_setters_rest(self, prop=None, leadingspace=2):
10941095

10951096
lines.append('')
10961097
lines.append(table_formatstr)
1097-
lines.append(pad + 'Property'.ljust(col0_len + 3) + \
1098+
lines.append(pad + 'Property'.ljust(col0_len + 3) +
10981099
'Description'.ljust(col1_len))
10991100
lines.append(table_formatstr)
11001101

@@ -1121,7 +1122,6 @@ def properties(self):
11211122
getters = [name for name in dir(o)
11221123
if name.startswith('get_')
11231124
and six.callable(getattr(o, name))]
1124-
#print getters
11251125
getters.sort()
11261126
d = dict()
11271127
for name in getters:
@@ -1323,7 +1323,7 @@ def kwdoc(a):
13231323
hardcopy = matplotlib.rcParams['docstring.hardcopy']
13241324
if hardcopy:
13251325
return '\n'.join(ArtistInspector(a).pprint_setters_rest(
1326-
leadingspace=2))
1326+
leadingspace=2))
13271327
else:
13281328
return '\n'.join(ArtistInspector(a).pprint_setters(leadingspace=2))
13291329

0 commit comments

Comments
 (0)