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

Skip to content

Commit 800fedc

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 25b80c3 commit 800fedc

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

doc/api/next_api_changes/deprecations.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,3 +242,13 @@ The following related APIs are also deprecated:
242242
``matplotlib.test(recursionlimit=...)``
243243
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
244244
The *recursionlimit* parameter of ``matplotlib.test`` is deprecated.
245+
246+
Path helpers in :mod:`.bezier`
247+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
248+
249+
``bezier.make_path_regular`` is deprecated. Use ``Path.cleaned()`` (or
250+
``Path.cleaned(curves=True)``, etc.) instead (but note that these methods add a
251+
``STOP`` code at the end of the path).
252+
253+
``bezier.concatenate_paths`` is deprecated. Use ``Path.make_compound_path()``
254+
instead.

lib/matplotlib/bezier.py

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

482482

483+
@cbook.deprecated("3.2", alternative="Path.cleaned()")
483484
def make_path_regular(p):
484485
"""
485486
If the ``codes`` attribute of `.Path` *p* is None, return a copy of *p*
@@ -495,6 +496,7 @@ def make_path_regular(p):
495496
return p
496497

497498

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

lib/matplotlib/patches.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@
1010
import matplotlib as mpl
1111
from . import artist, cbook, colors, docstring, lines as mlines, transforms
1212
from .bezier import (
13-
NonIntersectingPathException, concatenate_paths, get_cos_sin,
14-
get_intersection, get_parallels, inside_circle, make_path_regular,
15-
make_wedged_bezier2, split_bezier_intersecting_with_closedpath,
16-
split_path_inout)
13+
NonIntersectingPathException, get_cos_sin, get_intersection,
14+
get_parallels, inside_circle, make_wedged_bezier2,
15+
split_bezier_intersecting_with_closedpath, split_path_inout)
1716
from .path import Path
1817

1918

@@ -3187,8 +3186,6 @@ def __call__(self, path, mutation_size, linewidth,
31873186
and takes care of the aspect ratio.
31883187
"""
31893188

3190-
path = make_path_regular(path)
3191-
31923189
if aspect_ratio is not None:
31933190
# Squeeze the given height by the aspect_ratio
31943191
vertices = path.vertices / [1, aspect_ratio]
@@ -3200,10 +3197,9 @@ def __call__(self, path, mutation_size, linewidth,
32003197
if np.iterable(fillable):
32013198
path_list = []
32023199
for p in zip(path_mutated):
3203-
v, c = p.vertices, p.codes
32043200
# Restore the height
3205-
v[:, 1] = v[:, 1] * aspect_ratio
3206-
path_list.append(Path(v, c))
3201+
path_list.append(
3202+
Path(p.vertices * [1, aspect_ratio], p.codes))
32073203
return path_list, fillable
32083204
else:
32093205
return path_mutated, fillable
@@ -4174,7 +4170,7 @@ def get_path(self):
41744170
"""
41754171
_path, fillable = self.get_path_in_displaycoord()
41764172
if np.iterable(fillable):
4177-
_path = concatenate_paths(_path)
4173+
_path = Path.make_compound_path(*_path)
41784174
return self.get_transform().inverted().transform_path(_path)
41794175

41804176
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
@@ -100,10 +100,7 @@ def test_clipping():
100100
exterior.vertices -= 2
101101
interior = mpath.Path.unit_circle().deepcopy()
102102
interior.vertices = interior.vertices[::-1]
103-
clip_path = mpath.Path(vertices=np.concatenate([exterior.vertices,
104-
interior.vertices]),
105-
codes=np.concatenate([exterior.codes,
106-
interior.codes]))
103+
clip_path = mpath.Path.make_compound_path(exterior, interior)
107104

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

0 commit comments

Comments
 (0)
0