8000 Deprecate Path helpers in bezier.py · matplotlib/matplotlib@b78a7ae · GitHub
[go: up one dir, main page]

Skip to content

Commit b78a7ae

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 b78a7ae

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Deprecations
2+
````````````
3+
4+
``bezier.make_path_regular`` is deprecated. Use ``Path.cleaned()`` instead.
5+
6+
``bezier.concatenate_paths`` is deprecated. Use ``Path.make_compound_path``
7+
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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3223,7 +3223,7 @@ def __call__(self, path, mutation_size, linewidth,
32233223
and takes care of the aspect ratio.
32243224
"""
32253225

3226-
path = make_path_regular(path)
3226+
path = path.cleaned()
32273227

32283228
if aspect_ratio is not None:
32293229
# Squeeze the given height by the aspect_ratio
@@ -4255,7 +4255,8 @@ def get_path(self):
42554255
_path, fillable = self.get_path_in_displaycoord()
42564256

42574257
if np.iterable(fillable):
4258-
_path = concatenate_paths(_path)
4258+
cleaned = [p.cleaned() for p in _path]
4259+
_path = Path.make_compound_path(*cleaned)
42594260

42604261
return self.get_transform().inverted().transform_path(_path)
42614262

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