Add short-circuit return to matplotlib.artist.setp if input is length 0 #7801

Merged
merged 2 commits into from Jan 13, 2017
View
@@ -1427,6 +1427,9 @@ def setp(obj, *args, **kwargs):
else:
objs = list(cbook.flatten(obj))
+ if not objs:
+ return
+
insp = ArtistInspector(objs[0])
# file has to be popped before checking if kwargs is empty
@@ -239,6 +239,10 @@ def test_properties():
@cleanup
def test_setp():
+ # Check empty list
+ plt.setp([])
+ plt.setp([[]])
+
# Check arbitrary iterables
fig, axes = plt.subplots()
lines1 = axes.plot(range(3))