Skip to content

Commit 1938b44

Browse files
committed
PEP8 fixes on patches
1 parent 6fa35aa commit 1938b44

File tree

1 file changed

+31
-28
lines changed

1 file changed

+31
-28
lines changed

lib/matplotlib/patches.py

+31-28
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ def set_hatch(self, hatch):
376376
Hatching is supported in the PostScript, PDF, SVG and Agg
377377
backends only.
378378
379-
ACCEPTS: [ '/' | '\\\\' | '|' | '-' | '+' | 'x' | 'o' | 'O' | '.' | '*' ]
379+
ACCEPTS: ['/' | '\\\\' | '|' | '-' | '+' | 'x' | 'o' | 'O' | '.' | '*']
380380
"""
381381
self._hatch = hatch
382382

@@ -872,7 +872,6 @@ def __init__(self, center, r, theta1, theta2, width=None, **kwargs):
872872
self.theta1, self.theta2 = theta1, theta2
873873

874874
# Inner and outer rings are connected unless the annulus is complete
875-
delta = theta2 - theta1
876875
if abs((theta2 - theta1) - 360) <= 1e-12:
877876
theta1, theta2 = 0, 360
878877
connector = Path.MOVETO
@@ -956,8 +955,8 @@ def __str__(self):
956955
return "FancyArrow()"
957956

958957
@docstring.dedent_interpd
959-
def __init__(self, x, y, dx, dy, width=0.001, length_includes_head=False, \
960-
head_width=None, head_length=None, shape='full', overhang=0, \
958+
def __init__(self, x, y, dx, dy, width=0.001, length_includes_head=False,
959+
head_width=None, head_length=None, shape='full', overhang=0,
961960
head_starts_at_zero=False, **kwargs):
962961
"""
963962
Constructor arguments
@@ -1493,7 +1492,7 @@ def iter_circle_intersect_on_line_seg(x0, y0, x1, y1):
14931492
path_original = self._path
14941493
for theta in thetas:
14951494
if inside:
1496-
_path = Path.arc(last_theta, theta, 8)
1495+
Path.arc(last_theta, theta, 8)
14971496
Patch.draw(self, renderer)
14981497
inside = False
14991498
else:
@@ -1600,6 +1599,7 @@ def _pprint_styles(_styles, leadingspace=2):
16001599
(stylename : styleclass), return a formatted string listing all the
16011600
styles. Used to update the documentation.
16021601
"""
1602+
# FIXME pad isn't used, which means leadingspace is not use.
16031603
if leadingspace:
16041604
pad = ' ' * leadingspace
16051605
else:
@@ -2143,7 +2143,7 @@ def transmute(self, x0, y0, width, height, mutation_size):
21432143
width, height,
21442144
mutation_size)
21452145

2146-
cp = [Path.MOVETO] + ([Path.CURVE3, Path.CURVE3] \
2146+
cp = [Path.MOVETO] + ([Path.CURVE3, Path.CURVE3]
21472147
* ((len(saw_vertices) - 1) // 2))
21482148
path = Path(saw_vertices, cp)
21492149

@@ -2244,7 +2244,7 @@ def set_boxstyle(self, boxstyle=None, **kw):
22442244
ACCEPTS: %(AvailableBoxstyles)s
22452245
22462246
"""
2247-
if boxstyle == None:
2247+
if boxstyle is None:
22482248
return BoxStyle.pprint_styles()
22492249

22502250
if isinstance(boxstyle, BoxStyle._Base):
@@ -2847,8 +2847,8 @@ def _point_along_a_line(x0, y0, x1, y1, d):
28472847
distance from (x0, y0) is d.
28482848
"""
28492849
dx, dy = x0 - x1, y0 - y1
2850-
ff = d/(dx*dx+dy*dy)**.5
2851-
x2, y2 = x0 - ff*dx, y0 - ff*dy
2850+
ff = d / (dx * dx + dy * dy) ** .5
2851+
x2, y2 = x0 - ff * dx, y0 - ff * dy
28522852

28532853
return x2, y2
28542854

@@ -3122,7 +3122,7 @@ class Curve(_Curve):
31223122
"""
31233123

31243124
def __init__(self):
3125-
super(ArrowStyle.Curve, self).__init__( \
3125+
super(ArrowStyle.Curve, self).__init__(
31263126
beginarrow=False, endarrow=False)
31273127

31283128
_style_list["-"] = Curve
@@ -3181,7 +3181,7 @@ def __init__(self, head_length=.4, head_width=.2):
31813181
width of the arrow head
31823182
"""
31833183

3184-
super(ArrowStyle.CurveAB, self).__init__( \
3184+
super(ArrowStyle.CurveAB, self).__init__(
31853185
beginarrow=True, endarrow=True,
31863186
head_length=head_length, head_width=head_width)
31873187

@@ -3201,7 +3201,7 @@ def __init__(self, head_length=.4, head_width=.2):
32013201
width of the arrow head
32023202
"""
32033203

3204-
super(ArrowStyle.CurveFilledA, self).__init__( \
3204+
super(ArrowStyle.CurveFilledA, self).__init__(
32053205
beginarrow=True, endarrow=False,
32063206
fillbegin=True, fillend=False,
32073207
head_length=head_length, head_width=head_width)
@@ -3222,7 +3222,7 @@ def __init__(self, head_length=.4, head_width=.2):
32223222
width of the arrow head
32233223
"""
32243224

3225-
super(ArrowStyle.CurveFilledB, self).__init__( \
3225+
super(ArrowStyle.CurveFilledB, self).__init__(
32263226
beginarrow=False, endarrow=True,
32273227
fillbegin=False, fillend=True,
32283228
head_length=head_length, head_width=head_width)
@@ -3244,7 +3244,7 @@ def __init__(self, head_length=.4, head_width=.2):
32443244
width of the arrow head
32453245
"""
32463246

3247-
super(ArrowStyle.CurveFilledAB, self).__init__( \
3247+
super(ArrowStyle.CurveFilledAB, self).__init__(
32483248
beginarrow=True, endarrow=True,
32493249
fillbegin=True, fillend=True,
32503250
head_length=head_length, head_width=head_width)
@@ -3358,9 +3358,10 @@ def __init__(self,
33583358
angle between the bracket and the line
33593359
"""
33603360

3361-
super(ArrowStyle.BracketAB, self).__init__(True, True, \
3362-
widthA=widthA, lengthA=lengthA, angleA=angleA,
3363-
widthB=widthB, lengthB=lengthB, angleB=angleB)
3361+
super(ArrowStyle.BracketAB, self).__init__(
3362+
True, True, widthA=widthA, lengthA=lengthA,
3363+
angleA=angleA, widthB=widthB, lengthB=lengthB,
3364+
angleB=angleB)
33643365

33653366
_style_list["]-["] = BracketAB
33663367

@@ -3436,8 +3437,8 @@ def __init__(self,
34363437
angle between the bracket and the line
34373438
"""
34383439

3439-
super(ArrowStyle.BarAB, self).__init__(True, True, \
3440-
widthA=widthA, lengthA=0, angleA=angleA,
3440+
super(ArrowStyle.BarAB, self).__init__(
3441+
True, True, widthA=widthA, lengthA=0, angleA=angleA,
34413442
widthB=widthB, lengthB=0, angleB=angleB)
34423443

34433444
_style_list["|-|"] = BarAB
@@ -3481,23 +3482,24 @@ def transmute(self, path, mutation_size, linewidth):
34813482
in_f,
34823483
tolerence=0.01)
34833484
except NonIntersectingPathException:
3484-
# if this happens, make a straight line of the head_length long.
3485+
# if this happens, make a straight line of the head_length
3486+
# long.
34853487
x0, y0 = _point_along_a_line(x2, y2, x1, y1, head_length)
3486-
x1n, y1n = 0.5*(x0+x2), 0.5*(y0+y2)
3488+
x1n, y1n = 0.5 * (x0 + x2), 0.5 * (y0 + y2)
34873489
arrow_in = [(x0, y0), (x1n, y1n), (x2, y2)]
34883490
arrow_out = None
34893491

34903492
# head
34913493
head_width = self.head_width * mutation_size
34923494
head_left, head_right = \
3493-
make_wedged_bezier2(arrow_in, head_width/2.,
3495+
make_wedged_bezier2(arrow_in, head_width / 2.,
34943496
wm=.5)
34953497

3496-
34973498
# tail
34983499
if arrow_out is not None:
34993500
tail_width = self.tail_width * mutation_size
3500-
tail_left, tail_right = get_parallels(arrow_out, tail_width/2.)
3501+
tail_left, tail_right = get_parallels(arrow_out,
3502+
tail_width / 2.)
35013503

35023504
#head_right, head_left = head_r, head_l
35033505
patch_path = [(Path.MOVETO, tail_right[0]),
@@ -3570,9 +3572,10 @@ def transmute(self, path, mutation_size, linewidth):
35703572
in_f,
35713573
tolerence=0.01)
35723574
except NonIntersectingPathException:
3573-
# if this happens, make a straight line of the head_length long.
3575+
# if this happens, make a straight line of the head_length
3576+
# long.
35743577
x0, y0 = _point_along_a_line(x2, y2, x1, y1, head_length)
3575-
x1n, y1n = 0.5*(x0+x2), 0.5*(y0+y2)
3578+
x1n, y1n = 0.5 * (x0 + x2), 0.5 * (y0 + y2)
35763579
arrow_path = [(x0, y0), (x1n, y1n), (x2, y2)]
35773580
path_head = arrow_path
35783581
else:
@@ -3836,7 +3839,7 @@ def set_connectionstyle(self, connectionstyle, **kw):
38363839
available styles as a list of strings.
38373840
"""
38383841

3839-
if connectionstyle == None:
3842+
if connectionstyle is None:
38403843
return ConnectionStyle.pprint_styles()
38413844

38423845
if isinstance(connectionstyle, ConnectionStyle._Base):
@@ -3870,7 +3873,7 @@ def set_arrowstyle(self, arrowstyle=None, **kw):
38703873
available box styles as a list of strings.
38713874
"""
38723875

3873-
if arrowstyle == None:
3876+
if arrowstyle is None:
38743877
return ArrowStyle.pprint_styles()
38753878

38763879
if isinstance(arrowstyle, ConnectionStyle._Base):

0 commit comments

Comments
 (0)