Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

general pep8 fixes #3507

Merged
merged 2 commits into from Sep 13, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
186 changes: 108 additions & 78 deletions lib/matplotlib/__init__.py

Large diffs are not rendered by default.

18 changes: 10 additions & 8 deletions lib/matplotlib/_pylab_helpers.py
Expand Up @@ -5,15 +5,15 @@
unicode_literals)

import six

import sys, gc

import sys
import gc
import atexit


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


class Gcf(object):
"""
Singleton to manage a set of integer-numbered figures.
Expand Down Expand Up @@ -54,7 +54,8 @@ def destroy(num):
In the interactive backends, this is bound to the
window "destroy" and "delete" events.
"""
if not Gcf.has_fignum(num): return
if not Gcf.has_fignum(num):
return
manager = Gcf.figs[num]
manager.canvas.mpl_disconnect(manager._cidgcf)

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

del Gcf.figs[num]
#print len(Gcf.figs.keys()), len(Gcf._activeQue)
manager.destroy()
gc.collect(1)

Expand Down Expand Up @@ -118,9 +118,10 @@ def get_active():
"""
Return the manager of the active figure, or *None*.
"""
if len(Gcf._activeQue)==0:
if len(Gcf._activeQue) == 0:
return None
else: return Gcf._activeQue[-1]
else:
return Gcf._activeQue[-1]

@staticmethod
def set_active(manager):
Expand All @@ -130,7 +131,8 @@ def set_active(manager):
oldQue = Gcf._activeQue[:]
Gcf._activeQue = []
for m in oldQue:
if m != manager: Gcf._activeQue.append(m)
if m != manager:
Gcf._activeQue.append(m)
Gcf._activeQue.append(manager)
Gcf.figs[manager.num] = manager

Expand Down
11 changes: 6 additions & 5 deletions lib/matplotlib/afm.py
Expand Up @@ -44,7 +44,7 @@
import re
from ._mathtext_data import uni2type1

#Convert string the a python type
# Convert string the a python type

# some afm files have floats where we are expecting ints -- there is
# probably a better way to handle this (support floats, round rather
Expand Down Expand Up @@ -155,13 +155,13 @@ def _parse_header(fh):
if line.startswith(b'Comment'):
continue
lst = line.split(b' ', 1)
#print '%-s\t%-d line :: %-s' % ( fh.name, len(lst), line )

key = lst[0]
if len(lst) == 2:
val = lst[1]
else:
val = b''
#key, val = line.split(' ', 1)

try:
d[key] = headerConverters[key](val)
except ValueError:
Expand All @@ -170,7 +170,7 @@ def _parse_header(fh):
continue
except KeyError:
print('Found an unknown keyword in AFM header (was %s)' % key,
file=sys.stderr)
file=sys.stderr)
continue
if key == b'StartCharMetrics':
return d
Expand Down Expand Up @@ -517,7 +517,8 @@ def get_familyname(self):

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

def get_weight(self):
Expand Down
24 changes: 12 additions & 12 deletions lib/matplotlib/artist.py
Expand Up @@ -9,11 +9,11 @@
import matplotlib
import matplotlib.cbook as cbook
from matplotlib import docstring, rcParams
from .transforms import Bbox, IdentityTransform, TransformedBbox, \
TransformedPath, Transform
from .transforms import (Bbox, IdentityTransform, TransformedBbox,
TransformedPath, Transform)
from .path import Path

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

Expand Down Expand Up @@ -584,7 +583,7 @@ def set_clip_path(self, path, transform=None):
if transform is None:
if isinstance(path, Rectangle):
self.clipbox = TransformedBbox(Bbox.unit(),
path.get_transform())
path.get_transform())
self._clippath = None
success = True
elif isinstance(path, Patch):
Expand Down Expand Up @@ -866,8 +865,8 @@ def matchfunc(x):
if matchfunc(c):
artists.append(c)
artists.extend([thisc for thisc in
c.findobj(matchfunc, include_self=False)
if matchfunc(thisc)])
c.findobj(matchfunc, include_self=False)
if matchfunc(thisc)])

if include_self and matchfunc(self):
artists.append(self)
Expand Down Expand Up @@ -924,7 +923,8 @@ def get_aliases(self):
return aliases

_get_valid_values_regex = re.compile(
r"\n\s*ACCEPTS:\s*((?:.|\n)*?)(?:$|(?:\n\n))")
r"\n\s*ACCEPTS:\s*((?:.|\n)*?)(?:$|(?:\n\n))"
)

def get_valid_values(self, attr):
"""
Expand All @@ -934,7 +934,8 @@ def get_valid_values(self, attr):
for a line that begins with ACCEPTS:

e.g., for a line linestyle, return
"[ ``'-'`` | ``'--'`` | ``'-.'`` | ``':'`` | ``'steps'`` | ``'None'`` ]"
"[ ``'-'`` | ``'--'`` | ``'-.'`` | ``':'`` | ``'steps'`` | ``'None'``
]"
"""

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

lines.append('')
lines.append(table_formatstr)
lines.append(pad + 'Property'.ljust(col0_len + 3) + \
lines.append(pad + 'Property'.ljust(col0_len + 3) +
'Description'.ljust(col1_len))
lines.append(table_formatstr)

Expand All @@ -1121,7 +1122,6 @@ def properties(self):
getters = [name for name in dir(o)
if name.startswith('get_')
and six.callable(getattr(o, name))]
#print getters
getters.sort()
d = dict()
for name in getters:
Expand Down Expand Up @@ -1323,7 +1323,7 @@ def kwdoc(a):
hardcopy = matplotlib.rcParams['docstring.hardcopy']
if hardcopy:
return '\n'.join(ArtistInspector(a).pprint_setters_rest(
leadingspace=2))
leadingspace=2))
else:
return '\n'.join(ArtistInspector(a).pprint_setters(leadingspace=2))

Expand Down