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

Skip to content

Commit 16b56dd

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 16b56dd

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
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: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3223,12 +3223,10 @@ 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
32303228

3231-
vertices, codes = path.vertices[:], path.codes[:]
3229+
vertices, codes = path.vertices[:], path.codes
32323230
# Squeeze the height
32333231
vertices[:, 1] = vertices[:, 1] / aspect_ratio
32343232
path_shrunk = Path(vertices, codes)
@@ -4253,10 +4251,8 @@ def get_path(self):
42534251
in display coordinates.
42544252
"""
42554253
_path, fillable = self.get_path_in_displaycoord()
4256-
42574254
if np.iterable(fillable):
4258-
_path = concatenate_paths(_path)
4259-
4255+
_path = Path.make_compound_path(*_path)
42604256
return self.get_transform().inverted().transform_path(_path)
42614257

42624258
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)