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

Ignore non-draw codes when calculating path extent#19216

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
brunobeltran merged 1 commit intomatplotlib:masterfromdstansby:path-extent
Jan 6, 2021
Merged
Show file tree
Hide file tree
Changes fromall 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
7 changes: 6 additions & 1 deletionlib/matplotlib/path.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -621,7 +621,12 @@ def get_extents(self, transform=None, **kwargs):
if self.codes is None:
xys = self.vertices
elif len(np.intersect1d(self.codes, [Path.CURVE3, Path.CURVE4])) == 0:
xys = self.vertices[self.codes != Path.CLOSEPOLY]
# Optimization for the straight line case.
# Instead of iterating through each curve, consider
# each line segment's end-points
# (recall that STOP and CLOSEPOLY vertices are ignored)
xys = self.vertices[np.isin(self.codes,
[Path.MOVETO, Path.LINETO])]
else:
xys = []
for curve, code in self.iter_bezier(**kwargs):
Expand Down
10 changes: 10 additions & 0 deletionslib/matplotlib/tests/test_path.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -102,6 +102,16 @@ def test_exact_extents(path, extents):
assert np.all(path.get_extents().extents == extents)


@pytest.mark.parametrize('ignored_code', [Path.CLOSEPOLY, Path.STOP])
def test_extents_with_ignored_codes(ignored_code):
# Check that STOP and CLOSEPOLY points are ignored when calculating extents
# of a path with only straight lines
path = Path([[0, 0],
[1, 1],
[2, 2]], [Path.MOVETO, Path.MOVETO, ignored_code])
assert np.all(path.get_extents().extents == (0., 0., 1., 1.))


def test_point_in_path_nan():
box = np.array([[0, 0], [1, 0], [1, 1], [0, 1], [0, 0]])
p = Path(box)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp