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

Skip to content

Commit f4dafd9

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 f4dafd9

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
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: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3187,8 +3187,6 @@ def __call__(self, path, mutation_size, linewidth,
31873187
and takes care of the aspect ratio.
31883188
"""
31893189

3190-
path = make_path_regular(path)
3191-
31923190
if aspect_ratio is not None:
31933191
# Squeeze the given height by the aspect_ratio
31943192
vertices = path.vertices / [1, aspect_ratio]
@@ -3200,10 +3198,9 @@ def __call__(self, path, mutation_size, linewidth,
32003198
if np.iterable(fillable):
32013199
path_list = []
32023200
for p in zip(path_mutated):
3203-
v, c = p.vertices, p.codes
32043201
# Restore the height
3205-
v[:, 1] = v[:, 1] * aspect_ratio
3206-
path_list.append(Path(v, c))
3202+
path_list.append(
3203+
Path(p.vertices * [1, aspect_ratio], p.codes))
32073204
return path_list, fillable
32083205
else:
32093206
return path_mutated, fillable
@@ -4174,7 +4171,7 @@ def get_path(self):
41744171
"""
41754172
_path, fillable = self.get_path_in_displaycoord()
41764173
if np.iterable(fillable):
4177-
_path = concatenate_paths(_path)
4174+
_path = Path.make_compound_path(*_path)
41784175
return self.get_transform().inverted().transform_path(_path)
41794176

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