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

Skip to content

Commit 6fc5d56

Browse files
committed
Deprecate Path helpers in bezier.py
... in favor of the corresponding ones in path.py. (Strictly speaking, `make_path_regular` is closed to `cleaned(remove_nans=False)` but in practice `cleaned()` works equally well.)
1 parent a4d82fe commit 6fc5d56

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Deprecations
2+
````````````
3+
4+
``bezier.make_path_regular`` is deprecated. Use ``Path.cleaned()`` (or
5+
``Path.cleaned(curves=True)``, etc.) instead (but note that these methods add a
6+
``STOP`` code at the end of the path).
7+
8+
``bezier.concatenate_paths`` is deprecated. Use ``Path.make_compound_path()``
9+
instead.

lib/matplotlib/bezier.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ def make_wedged_bezier2(bezier2, width, w1=1., wm=0.5, w2=0.):
457457
return path_left, path_right
458458

459459

460+
@cbook.deprecated("3.2", alternative="Path.cleaned()")
460461
def make_path_regular(p):
461462
"""
462463
If the :attr:`codes` attribute of `Path` *p* is None, return a copy of *p*
@@ -472,6 +473,7 @@ def make_path_regular(p):
472473
return p
473474

474475

476+
@cbook.deprecated("3.2", alternative="Path.make_compound_path()")
475477
def concatenate_paths(paths):
476478
"""Concatenate a list of paths into a single path."""
477479
vertices = np.concatenate([p.vertices for p in paths])

lib/matplotlib/patches.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3223,26 +3223,20 @@ def __call__(self, path, mutation_size, linewidth,
32233223
and takes care of the aspect ratio.
32243224
"""
32253225

3226-
path = make_path_regular(path)
3227-
32283226
if aspect_ratio is not None:
32293227
# Squeeze the given height by the aspect_ratio
3230-
3231-
vertices, codes = path.vertices[:], path.codes[:]
3232-
# Squeeze the height
3233-
vertices[:, 1] = vertices[:, 1] / aspect_ratio
3234-
path_shrunk = Path(vertices, codes)
3228+
path_shrunk = Path(path.vertices / [1, aspect_ratio],
3229+
path.codes)
32353230
# call transmute method with squeezed height.
32363231
path_mutated, fillable = self.transmute(path_shrunk,
32373232
linewidth,
32383233
mutation_size)
32393234
if np.iterable(fillable):
32403235
path_list = []
32413236
for p in zip(path_mutated):
3242-
v, c = p.vertices, p.codes
32433237
# Restore the height
3244-
v[:, 1] = v[:, 1] * aspect_ratio
3245-
path_list.append(Path(v, c))
3238+
path_list.append(
3239+
Path(p.vertices * [1, aspect_ratio], p.codes))
32463240
return path_list, fillable
32473241
else:
32483242
return path_mutated, fillable
@@ -4253,10 +4247,8 @@ def get_path(self):
42534247
in display coordinates.
42544248
"""
42554249
_path, fillable = self.get_path_in_displaycoord()
4256-
42574250
if np.iterable(fillable):
4258-
_path = concatenate_paths(_path)
4259-
4251+
_path = Path.make_compound_path(*_path)
42604252
return self.get_transform().inverted().transform_path(_path)
42614253

42624254
def get_path_in_displaycoord(self):

lib/matplotlib/tests/test_artist.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,7 @@ def test_clipping():
101101
exterior.vertices -= 2
102102
interior = mpath.Path.unit_circle().deepcopy()
103103
interior.vertices = interior.vertices[::-1]
104-
clip_path = mpath.Path(vertices=np.concatenate([exterior.vertices,
105-
interior.vertices]),
106-
codes=np.concatenate([exterior.codes,
107-
interior.codes]))
104+
clip_path = mpath.Path.make_compound_path(exterior, interior)
108105

109106
star = mpath.Path.unit_regular_star(6).deepcopy()
110107
star.vertices *= 2.6

0 commit comments

Comments
 (0)