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

Skip to content

Deprecate point_at_t and document that a BezierSegment can be called #30070

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/api/bezier_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
.. automodule:: matplotlib.bezier
:members:
:undoc-members:
:special-members: __call__
:show-inheritance:
4 changes: 4 additions & 0 deletions doc/api/next_api_changes/deprecations/30070-OG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
``BezierSegment.point_at_t``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

... is deprecated. Instead, it is possible to call the BezierSegment with an argument.
8 changes: 6 additions & 2 deletions lib/matplotlib/bezier.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ class BezierSegment:
"""
A d-dimensional Bézier segment.

A BezierSegment can be called with an argument, either a scalar or an array-like
object, to evaluate the curve at that/those location(s).

Parameters
----------
control_points : (N, d) array
Expand Down Expand Up @@ -223,6 +226,8 @@ def __call__(self, t):
return (np.power.outer(1 - t, self._orders[::-1])
* np.power.outer(t, self._orders)) @ self._px

@_api.deprecated(
"3.11", alternative="Call the BezierSegment object with an argument.")
def point_at_t(self, t):
"""
Evaluate the curve at a single point, returning a tuple of *d* floats.
Expand Down Expand Up @@ -336,10 +341,9 @@ def split_bezier_intersecting_with_closedpath(
"""

bz = BezierSegment(bezier)
bezier_point_at_t = bz.point_at_t

t0, t1 = find_bezier_t_intersecting_with_closedpath(
bezier_point_at_t, inside_closedpath, tolerance=tolerance)
lambda t: tuple(bz(t)), inside_closedpath, tolerance=tolerance)

_left, _right = split_de_casteljau(bezier, (t0 + t1) / 2.)
return _left, _right
Expand Down
Loading