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

Skip to content

Commit 090cc96

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 bb7f9b9 commit 090cc96

File tree

4 files changed

+20
-14
lines changed

4 files changed

+20
-14
lines changed

doc/api/next_api_changes/deprecations.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,3 +376,13 @@ NavigationToolbar2QT.parent
376376
This attribute is deprecated. In order to access the parent window, use
377377
``toolbar.canvas.parent()``. Once the deprecation period is elapsed, it will
378378
also be accessible as ``toolbar.parent()``.
379+
380+
Path helpers in :mod:`.bezier`
381+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
382+
383+
``bezier.make_path_regular`` is deprecated. Use ``Path.cleaned()`` (or
384+
``Path.cleaned(curves=True)``, etc.) instead (but note that these methods add a
385+
``STOP`` code at the end of the path).
386+
387+
``bezier.concatenate_paths`` is deprecated. Use ``Path.make_compound_path()``
388+
instead.

lib/matplotlib/bezier.py

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

482482

483+
@cbook.deprecated(
484+
"3.2", alternative="Path.cleaned() and remove the final STOP if needed")
483485
def make_path_regular(p):
484486
"""
485487
If the ``codes`` attribute of `.Path` *p* is None, return a copy of *p*
@@ -495,6 +497,7 @@ def make_path_regular(p):
495497
return p
496498

497499

500+
@cbook.deprecated("3.2", alternative="Path.make_compound_path()")
498501
def concatenate_paths(paths):
499502
"""Concatenate a list of paths into a single path."""
500503
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

@@ -2873,8 +2872,6 @@ def __call__(self, path, mutation_size, linewidth,
28732872
and takes care of the aspect ratio.
28742873
"""
28752874

2876-
path = make_path_regular(path)
2877-
28782875
if aspect_ratio is not None:
28792876
# Squeeze the given height by the aspect_ratio
28802877
vertices = path.vertices / [1, aspect_ratio]
@@ -2886,10 +2883,9 @@ def __call__(self, path, mutation_size, linewidth,
28862883
if np.iterable(fillable):
28872884
path_list = []
28882885
for p in zip(path_mutated):
2889-
v, c = p.vertices, p.codes
28902886
# Restore the height
2891-
v[:, 1] = v[:, 1] * aspect_ratio
2892-
path_list.append(Path(v, c))
2887+
path_list.append(
2888+
Path(p.vertices * [1, aspect_ratio], p.codes))
28932889
return path_list, fillable
28942890
else:
28952891
return path_mutated, fillable
@@ -4125,7 +4121,7 @@ def get_path(self):
41254121
"""
41264122
_path, fillable = self.get_path_in_displaycoord()
41274123
if np.iterable(fillable):
4128-
_path = concatenate_paths(_path)
4124+
_path = Path.make_compound_path(*_path)
41294125
return self.get_transform().inverted().transform_path(_path)
41304126

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