Skip to content

Commit 21a2ade

Browse files
committed
deprecate bezier functions instead of removing
1 parent 9017f21 commit 21a2ade

File tree

3 files changed

+62
-4
lines changed

3 files changed

+62
-4
lines changed

doc/api/next_api_changes/deprecations.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,3 +370,10 @@ mathtext ``Glue`` helper classes
370370
The ``Fil``, ``Fill``, ``Filll``, ``NegFil``, ``NegFill``, ``NegFilll``, and
371371
``SsGlue`` classes in the :mod:`matplotlib.mathtext` module are deprecated.
372372
As an alternative, directly construct glue instances with ``Glue("fil")``, etc.
373+
374+
Various `matplotlib.bezier` methods that belonged in `.Path` moved there
375+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
376+
- ``bezier.inside_circle()`` (no replacement)
377+
- ``bezier.split_path_inout`` (use ``Path.split_path_inout`` instead)
378+
- ``bezier.make_path_regular`` (use ``Path.make_path_regular`` instead)
379+
- ``bezier.concatenate_paths`` (use ``Path.make_compound_path`` instead)

doc/api/next_api_changes/removals.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,6 @@ Classes and methods
8585
- ``image.BboxImage.interp_at_native`` property (no replacement)
8686
- ``lines.Line2D.verticalOffset`` property (no replacement)
8787
- ``bezier.find_r_to_boundary_of_closedpath()`` (no replacement)
88-
- ``bezier.inside_circle()`` (no replacement)
89-
- ``bezier.split_path_inout`` (use ``Path.split_path_inout`` instead)
90-
- ``bezier.make_path_regular`` (use ``Path.make_path_regular`` instead)
91-
- ``bezier.concatenate_paths`` (use ``Path.make_compound_path`` instead)
9288

9389
- ``quiver.Quiver.color()`` (use ``Quiver.get_facecolor()`` instead)
9490
- ``quiver.Quiver.keyvec`` property (no replacement)

lib/matplotlib/bezier.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,61 @@ def get_normal_points(cx, cy, cos_t, sin_t, length):
6868
return x1, y1, x2, y2
6969

7070

71+
# deprecated routines (moved to `.Path`)
72+
73+
74+
@cbook.deprecated("3.3")
75+
def inside_circle(cx, cy, r):
76+
"""
77+
Return a function that checks whether a point is in a circle with center
78+
(*cx*, *cy*) and radius *r*.
79+
80+
The returned function has the signature::
81+
82+
f(xy: Tuple[float, float]) -> bool
83+
"""
84+
r2 = r ** 2
85+
86+
def _f(xy):
87+
x, y = xy
88+
return (x - cx) ** 2 + (y - cy) ** 2 < r2
89+
return _f
90+
91+
92+
def split_path_inout(path, inside, tolerance=0.01, reorder_inout=False):
93+
"""
94+
Divide a path into two segments at the point where ``inside(x, y)``
95+
becomes False.
96+
"""
97+
cbook.warn_deprecated("3.3",
98+
message="split_path_inout is now a method of "
99+
"`matplotlib.path.Path`")
100+
return path.split_path_inout(inside, tolerance, reorder_inout)
101+
102+
103+
def make_path_regular(path):
104+
"""
105+
If the ``codes`` attribute of `.Path` *p* is None, return a copy of *p*
106+
with ``codes`` set to (MOVETO, LINETO, LINETO, ..., LINETO); otherwise
107+
return *p* itself.
108+
"""
109+
cbook.warn_deprecated("3.3",
110+
message="make_path_regular is now a method of "
111+
"`matplotlib.path.Path`")
112+
return path.make_path_regular()
113+
114+
115+
def concatenate_paths(paths):
116+
"""Concatenate a list of paths into a single path."""
117+
cbook.warn_deprecated("3.3",
118+
message="concatenate_paths is deprecated, please "
119+
"use `matplotlib.path.Path.concatenate_paths` "
120+
"instead, which correctly respects subclasses.")
121+
vertices = np.concatenate([p.vertices for p in paths])
122+
codes = np.concatenate([make_path_regular(p).codes for p in paths])
123+
return Path(vertices, codes)
124+
125+
71126
# BEZIER routines
72127

73128
# subdividing bezier curve

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy