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

Skip to content

Commit d6a70a7

Browse files
author
Brian Mattern
committed
pep-8 compliance for commit 283f358
1 parent 283f358 commit d6a70a7

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

lib/matplotlib/contour.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -577,12 +577,12 @@ def add_label_near(self, x, y, inline=True, inline_spacing=5,
577577
paths = self.collections[conmin].get_paths()
578578
lc = paths[segmin].vertices
579579
if transform:
580-
xcmin = transform.inverted().transform([xmin,ymin])
580+
xcmin = transform.inverted().transform([xmin, ymin])
581581
else:
582-
xcmin = np.array([xmin,ymin])
582+
xcmin = np.array([xmin, ymin])
583583
if not np.allclose(xcmin, lc[imin]):
584-
lc = np.r_[lc[:imin], np.array(xcmin)[None,:], lc[imin:]]
585-
paths[segmin] = mpath.Path(lc)
584+
lc = np.r_[lc[:imin], np.array(xcmin)[None, :], lc[imin:]]
585+
paths[segmin] = mpath.Path(lc)
586586

587587
# Get index of nearest level in subset of levels used for labeling
588588
lmin = self.labelIndiceList.index(conmin)
@@ -685,6 +685,7 @@ def labels(self, inline, inline_spacing):
685685
del paths[:]
686686
paths.extend(additions)
687687

688+
688689
def _find_closest_point_on_leg(p1, p2, p0):
689690
'''find closest point to p0 on line segment connecting p1 and p2'''
690691

@@ -698,37 +699,40 @@ def _find_closest_point_on_leg(p1, p2, p0):
698699

699700
# project on to line segment to find closest point
700701
proj = np.dot(d01, d21) / np.dot(d21, d21)
701-
if proj < 0: proj = 0
702-
if proj > 1: proj = 1
702+
if proj < 0:
703+
proj = 0
704+
if proj > 1:
705+
proj = 1
703706
pc = p1 + proj * d21
704707

705708
# find squared distance
706709
d = np.sum((pc-p0)**2)
707710

708711
return d, pc
709712

713+
710714
def _find_closest_point_on_path(lc, point):
711715
'''
712716
lc: coordinates of vertices
713717
point: coordinates of test point
714718
'''
715719

716720
# find index of closest vertex for this segment
717-
ds = np.sum((lc - point[None,:])**2, 1)
721+
ds = np.sum((lc - point[None, :])**2, 1)
718722
imin = np.argmin(ds)
719723

720724
dmin = 1e10
721725
xcmin = None
722-
legmin = (None,None)
726+
legmin = (None, None)
723727

724728
closed = mlab.is_closed_polygon(lc)
725729

726730
# build list of legs before and after this vertex
727731
legs = []
728732
if imin > 0 or closed:
729-
legs.append(((imin-1)%len(lc),imin))
733+
legs.append(((imin-1) % len(lc), imin))
730734
if imin < len(lc) - 1 or closed:
731-
legs.append((imin,(imin+1)%len(lc)))
735+
legs.append((imin, (imin+1) % len(lc)))
732736

733737
for leg in legs:
734738
d, xc = _find_closest_point_on_leg(lc[leg[0]], lc[leg[1]], point)
@@ -739,6 +743,7 @@ def _find_closest_point_on_path(lc, point):
739743

740744
return (dmin, xcmin, legmin)
741745

746+
742747
class ContourSet(cm.ScalarMappable, ContourLabeler):
743748
"""
744749
Store a set of contour lines or filled regions.
@@ -1327,7 +1332,7 @@ def find_nearest_contour(self, x, y, indices=None, pixel=True):
13271332
xmin = None
13281333
ymin = None
13291334

1330-
point = np.array([x,y])
1335+
point = np.array([x, y])
13311336

13321337
for icon in indices:
13331338
con = self.collections[icon]

0 commit comments

Comments
 (0)