Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0b1b23a

Browse files
committed
replace Path.get_extents instead of adding new API
1 parentb8008ac commit0b1b23a

File tree

2 files changed

+13
-25
lines changed

2 files changed

+13
-25
lines changed

‎lib/matplotlib/path.py

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -587,38 +587,26 @@ def contains_path(self, path, transform=None):
587587
transform=transform.frozen()
588588
return_path.path_in_path(self,None,path,transform)
589589

590-
defget_extents(self,transform=None):
591-
"""
592-
Return the extents (*xmin*, *ymin*, *xmax*, *ymax*) of the path.
593-
594-
Unlike computing the extents on the *vertices* alone, this
595-
algorithm will take into account the curves and deal with
596-
control points appropriately.
597-
"""
598-
from .transformsimportBbox
599-
path=self
600-
iftransformisnotNone:
601-
transform=transform.frozen()
602-
ifnottransform.is_affine:
603-
path=self.transformed(transform)
604-
transform=None
605-
returnBbox(_path.get_path_extents(path,transform))
606-
607-
defget_exact_extents(self,**kwargs):
590+
defget_extents(self,transform=None,**kwargs):
608591
"""Get size of Bbox of curve (instead of Bbox of control points).
609592
610593
Parameters
611594
----------
595+
transform : matplotlib.transforms.Transform, optional
596+
Transform to apply to path before computing extents, if any.
612597
kwargs : Dict[str, object]
613598
Forwarded to self.iter_bezier.
614599
615600
Returns
616601
-------
617-
extents :(4,) float, array_like
618-
The extents of the path(xmin, ymin,xmax, ymax).
602+
bbox :matplotlib.transforms.Bbox
603+
The extents of the pathBbox([[xmin, ymin], [xmax, ymax]])
619604
"""
605+
from .transformsimportBbox
606+
iftransformisnotNone:
607+
self=transform.transform_path(self)
620608
maxi=2# [xmin, ymin, *xmax, ymax]
621-
# return value for empty paths to match _path.h
609+
# return value for empty paths to matchwhat used to be done in_path.h
622610
extents=np.array([np.inf,np.inf,-np.inf,-np.inf])
623611
forcurve,codeinself.iter_bezier(**kwargs):
624612
# start and endpoints can be extrema of the curve
@@ -628,10 +616,10 @@ def get_exact_extents(self, **kwargs):
628616
_,dzeros=curve.axis_aligned_extrema
629617
iflen(dzeros)==0:
630618
continue
631-
forzeroindzeros:
632-
potential_extrema=curve.point_at_t(zero)
619+
fortiindzeros:
620+
potential_extrema=curve.point_at_t(ti)
633621
_update_extents(extents,potential_extrema)
634-
returnextents
622+
returnBbox.from_extents(extents)
635623

636624
defintersects_path(self,other,filled=True):
637625
"""

‎lib/matplotlib/tests/test_path.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def test_contains_points_negative_radius():
5252
deftest_exact_extents_cubic():
5353
hard_curve=Path([[0,0], [1,0], [1,1], [0,1]],
5454
[Path.MOVETO,Path.CURVE4,Path.CURVE4,Path.CURVE4])
55-
np.testing.assert_equal(hard_curve.get_exact_extents(), [0.,0.,0.75,1.])
55+
assert(hard_curve.get_extents().bounds== (0.,0.,0.75,1.))
5656

5757

5858
deftest_point_in_path_nan():

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp