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

Skip to content

Commit 5a53f5e

Browse files
authored
Merge pull request #13300 from anntzer/bezier
Trivial bezier cleanups.
2 parents b91f4a6 + 16e3df8 commit 5a53f5e

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

lib/matplotlib/bezier.py

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ def find_control_points(c1x, c1y, mmx, mmy, c2x, c2y):
409409

410410
def make_wedged_bezier2(bezier2, width, w1=1., wm=0.5, w2=0.):
411411
"""
412-
Being similar to get_parallels, returns control points of two quadrativ
412+
Being similar to get_parallels, returns control points of two quadratic
413413
bezier lines having a width roughly parallel to given one separated by
414414
*width*.
415415
"""
@@ -460,31 +460,21 @@ def make_wedged_bezier2(bezier2, width, w1=1., wm=0.5, w2=0.):
460460

461461
def make_path_regular(p):
462462
"""
463-
fill in the codes if None.
463+
If the :attr:`codes` attribute of `Path` *p* is None, return a copy of *p*
464+
with the :attr:`codes` set to (MOVETO, LINETO, LINETO, ..., LINETO);
465+
otherwise return *p* itself.
464466
"""
465467
c = p.codes
466468
if c is None:
467-
c = np.empty(p.vertices.shape[:1], "i")
468-
c.fill(Path.LINETO)
469+
c = np.full(len(p.vertices), Path.LINETO, dtype=Path.code_type)
469470
c[0] = Path.MOVETO
470-
471471
return Path(p.vertices, c)
472472
else:
473473
return p
474474

475475

476476
def concatenate_paths(paths):
477-
"""
478-
concatenate list of paths into a single path.
479-
"""
480-
481-
vertices = []
482-
codes = []
483-
for p in paths:
484-
p = make_path_regular(p)
485-
vertices.append(p.vertices)
486-
codes.append(p.codes)
487-
488-
_path = Path(np.concatenate(vertices),
489-
np.concatenate(codes))
490-
return _path
477+
"""Concatenate a list of paths into a single path."""
478+
vertices = np.concatenate([p.vertices for p in paths])
479+
codes = np.concatenate([make_path_regular(p).codes for p in paths])
480+
return Path(vertices, codes)

0 commit comments

Comments
 (0)