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

Skip to content

Commit 6a5791d

Browse files
committed
Fixed some PEP8 violations to leave the code cleaner than I found it.
1 parent 7dfa646 commit 6a5791d

File tree

3 files changed

+27
-20
lines changed

3 files changed

+27
-20
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
from numpy import ma
1414

1515
import matplotlib
16-
rcParams = matplotlib.rcParams
17-
1816
from matplotlib import cbook
1917
from matplotlib.cbook import _string_to_bool
2018
from matplotlib import docstring
@@ -31,10 +29,9 @@
3129
import matplotlib.text as mtext
3230
import matplotlib.image as mimage
3331
from matplotlib.artist import allow_rasterization
34-
35-
3632
from matplotlib.cbook import iterable
3733

34+
rcParams = matplotlib.rcParams
3835

3936
is_string_like = cbook.is_string_like
4037
is_sequence_of_strings = cbook.is_sequence_of_strings
@@ -1241,8 +1238,9 @@ def apply_aspect(self, position=None):
12411238
Xsize = ysize / data_ratio
12421239
Xmarg = Xsize - xr
12431240
Ymarg = Ysize - yr
1244-
xm = 0 # Setting these targets to, e.g., 0.05*xr does not seem to
1245-
# help.
1241+
# Setting these targets to, e.g., 0.05*xr does not seem to
1242+
# help.
1243+
xm = 0
12461244
ym = 0
12471245
#print 'xmin, xmax, ymin, ymax', xmin, xmax, ymin, ymax
12481246
#print 'xsize, Xsize, ysize, Ysize', xsize, Xsize, ysize, Ysize
@@ -1402,7 +1400,7 @@ def get_yticklines(self):
14021400
return cbook.silent_list('Line2D ytickline',
14031401
self.yaxis.get_ticklines())
14041402

1405-
#### Adding and tracking artists
1403+
# Adding and tracking artists
14061404

14071405
def _sci(self, im):
14081406
"""
@@ -1984,7 +1982,7 @@ def autoscale_view(self, tight=None, scalex=True, scaley=True):
19841982
y0, y1 = ylocator.view_limits(y0, y1)
19851983
self.set_ybound(y0, y1)
19861984

1987-
#### Drawing
1985+
# Drawing
19881986

19891987
@allow_rasterization
19901988
def draw(self, renderer=None, inframe=False):
@@ -2133,7 +2131,7 @@ def redraw_in_frame(self):
21332131
def get_renderer_cache(self):
21342132
return self._cachedRenderer
21352133

2136-
#### Axes rectangle characteristics
2134+
# Axes rectangle characteristics
21372135

21382136
def get_frame_on(self):
21392137
"""
@@ -2430,7 +2428,7 @@ def set_axis_bgcolor(self, color):
24302428
self._axisbg = color
24312429
self.patch.set_facecolor(color)
24322430

2433-
### data limits, ticks, tick labels, and formatting
2431+
# data limits, ticks, tick labels, and formatting
24342432

24352433
def invert_xaxis(self):
24362434
"Invert the x-axis."
@@ -3004,7 +3002,7 @@ def minorticks_off(self):
30043002
self.xaxis.set_minor_locator(mticker.NullLocator())
30053003
self.yaxis.set_minor_locator(mticker.NullLocator())
30063004

3007-
#### Interactive manipulation
3005+
# Interactive manipulation
30083006

30093007
def can_zoom(self):
30103008
"""

lib/matplotlib/backends/backend_pdf.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,8 @@ def __init__(self, filename):
462462
self.fontNames = {} # maps filenames to internal font names
463463
self.nextFont = 1 # next free internal font name
464464
self.dviFontInfo = {} # information on dvi fonts
465-
self.type1Descriptors = {} # differently encoded Type-1 fonts may
466-
# share the same descriptor
465+
# differently encoded Type-1 fonts may share the same descriptor
466+
self.type1Descriptors = {}
467467
self.used_characters = {}
468468

469469
self.alphaStates = {} # maps alpha values to graphics state objects
@@ -1233,8 +1233,8 @@ def imageObject(self, image):
12331233
self.images[image] = (name, ob)
12341234
return name
12351235

1236-
## These two from backend_ps.py
1237-
## TODO: alpha (SMask, p. 518 of pdf spec)
1236+
# These two from backend_ps.py
1237+
# TODO: alpha (SMask, p. 518 of pdf spec)
12381238

12391239
def _rgb(self, im):
12401240
h, w, s = im.as_rgba_str()
@@ -1452,9 +1452,18 @@ def writeXref(self):
14521452
def writeInfoDict(self):
14531453
"""Write out the info dictionary, checking it for good form"""
14541454

1455-
is_date = lambda x: isinstance(x, datetime)
1456-
check_trapped = (lambda x: isinstance(x, Name) and
1457-
x.name in ('True', 'False', 'Unknown'))
1455+
# is_date = lambda x: isinstance(x, datetime)
1456+
# check_trapped = (lambda x: isinstance(x, Name) and
1457+
# x.name in ('True', 'False', 'Unknown'))
1458+
def is_date(x):
1459+
boolean = isinstance(x, datetime)
1460+
return(boolean)
1461+
1462+
def check_trapped(x):
1463+
boolean = isinstance(x, Name) and \
1464+
x.name in ('True', 'False', 'Unknown')
1465+
return(boolean)
1466+
14581467
keywords = {'Title': is_string_like,
14591468
'Author': is_string_like,
14601469
'Subject': is_string_like,

lib/matplotlib/tests/test_backend_pdf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_multipage_pagecount():
5757
def test_multipage_keep_empty():
5858
from matplotlib.backends.backend_pdf import PdfPages
5959
from tempfile import NamedTemporaryFile
60-
### test empty pdf files
60+
# test empty pdf files
6161
# test that an empty pdf is left behind with keep_empty=True (default)
6262
with NamedTemporaryFile(delete=False) as tmp:
6363
with PdfPages(tmp) as pdf:
@@ -68,7 +68,7 @@ def test_multipage_keep_empty():
6868
with PdfPages(filename, keep_empty=False) as pdf:
6969
pass
7070
assert not os.path.exists(filename)
71-
### test pdf files with content, they should never be deleted
71+
# test pdf files with content, they should never be deleted
7272
fig = plt.figure()
7373
ax = fig.add_subplot(111)
7474
ax.plot([1, 2, 3])

0 commit comments

Comments
 (0)