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

Appearance settings

Commit 9edcb03

Browse filesBrowse files
authored
Merge pull request #7801 from samsontmr/fix-#7784
FIX: Add short-circuit return to matplotlib.artist.setp if input is length 0
2 parents a02e303 + 193da2e commit 9edcb03
Copy full SHA for 9edcb03

File tree

Expand file treeCollapse file tree

2 files changed

+7
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+7
-0
lines changed

‎lib/matplotlib/artist.py

Copy file name to clipboardExpand all lines: lib/matplotlib/artist.py
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,6 +1427,9 @@ def setp(obj, *args, **kwargs):
14271427
else:
14281428
objs = list(cbook.flatten(obj))
14291429

1430+
if not objs:
1431+
return
1432+
14301433
insp = ArtistInspector(objs[0])
14311434

14321435
# file has to be popped before checking if kwargs is empty

‎lib/matplotlib/tests/test_artist.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_artist.py
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,10 @@ def test_properties():
239239

240240
@cleanup
241241
def test_setp():
242+
# Check empty list
243+
plt.setp([])
244+
plt.setp([[]])
245+
242246
# Check arbitrary iterables
243247
fig, axes = plt.subplots()
244248
lines1 = axes.plot(range(3))

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.