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

Commitdf9fa06

Browse files
authored
Merge pull request#20483 from meeseeksmachine/auto-backport-of-pr-20480-on-v3.4.x
Backport PR#20480 on branch v3.4.x (Fix str of empty polygon.)
2 parents0580c0d +c7f2f42 commitdf9fa06

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

‎lib/matplotlib/patches.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,8 +1048,11 @@ class Polygon(Patch):
10481048
"""A general polygon patch."""
10491049

10501050
def__str__(self):
1051-
s="Polygon%d((%g, %g) ...)"
1052-
returns% (len(self._path.vertices),*tuple(self._path.vertices[0]))
1051+
iflen(self._path.vertices):
1052+
s="Polygon%d((%g, %g) ...)"
1053+
returns% (len(self._path.vertices),*self._path.vertices[0])
1054+
else:
1055+
return"Polygon0()"
10531056

10541057
@docstring.dedent_interpd
10551058
def__init__(self,xy,closed=True,**kwargs):

‎lib/matplotlib/tests/test_patches.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,9 @@ def test_patch_str():
347347
p=mpatches.PathPatch(path)
348348
assertstr(p)=="PathPatch3((1, 2) ...)"
349349

350+
p=mpatches.Polygon(np.empty((0,2)))
351+
assertstr(p)=="Polygon0()"
352+
350353
data= [[1,2], [2,2], [1,2]]
351354
p=mpatches.Polygon(data)
352355
assertstr(p)=="Polygon3((1, 2) ...)"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp