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

Skip to content

Commit acf2b61

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 47c0764 commit acf2b61

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
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
@@ -520,6 +520,7 @@ def make_wedged_bezier2(bezier2, width, w1=1., wm=0.5, w2=0.):
520520
return path_left, path_right
521521

522522

523+
@cbook.deprecated("3.2", alternative="Path.cleaned()")
523524
def make_path_regular(p):
524525
"""
525526
If the :attr:`codes` attribute of `Path` *p* is None, return a copy of *p*
@@ -535,6 +536,7 @@ def make_path_regular(p):
535536
return p
536537

537538

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

lib/matplotlib/patches.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3123,26 +3123,20 @@ def __call__(self, path, mutation_size, linewidth,
31233123
and takes care of the aspect ratio.
31243124
"""
31253125

3126-
path = make_path_regular(path)
3127-
31283126
if aspect_ratio is not None:
31293127
# Squeeze the given height by the aspect_ratio
3130-
3131-
vertices, codes = path.vertices[:], path.codes[:]
3132-
# Squeeze the height
3133-
vertices[:, 1] = vertices[:, 1] / aspect_ratio
3134-
path_shrunk = Path(vertices, codes)
3128+
path_shrunk = Path(path.vertices / [1, aspect_ratio],
3129+
path.codes)
31353130
# call transmute method with squeezed height.
31363131
path_mutated, fillable = self.transmute(path_shrunk,
31373132
linewidth,
31383133
mutation_size)
31393134
if np.iterable(fillable):
31403135
path_list = []
31413136
for p in zip(path_mutated):
3142-
v, c = p.vertices, p.codes
31433137
# Restore the height
3144-
v[:, 1] = v[:, 1] * aspect_ratio
3145-
path_list.append(Path(v, c))
3138+
path_list.append(
3139+
Path(p.vertices * [1, aspect_ratio], p.codes))
31463140
return path_list, fillable
31473141
else:
31483142
return path_mutated, fillable
@@ -4152,7 +4146,7 @@ def get_path(self):
41524146
"""
41534147
_path, fillable = self.get_path_in_displaycoord()
41544148
if np.iterable(fillable):
4155-
_path = concatenate_paths(_path)
4149+
_path = Path.make_compound_path(*_path)
41564150
return self.get_transform().inverted().transform_path(_path)
41574151

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