8000 BUG: Fix UnboundLocalError in contour labelling · matplotlib/matplotlib@ca9502e · GitHub
[go: up one dir, main page]

Skip to content

Commit ca9502e

Browse files
committed
BUG: Fix UnboundLocalError in contour labelling
The code was trying to protect the access of xy1 and xy2 to valid cases, but unfortunately, for a list, l != -1 doesn't do element-by-element or return an error--it just always returns True. Therefore it wasn't actually guarding.
1 parent d2f7bb1 commit ca9502e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/matplotlib/contour.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ def calc_label_rot_and_inline(self, slc, ind, lw, lc=None, spacing=5):
440440
# Actually break contours
441441
if closed:
442442
# This will remove contour if shorter than label
443-
if np.all(I != -1):
443+
if all(i != -1 for i in I):
444444
nlc.append(np.row_stack([xy2, lc[I[1]:I[0]+1], xy1]))
445445
else:
446446
# These will remove pieces of contour if they have length zero

0 commit comments

Comments
 (0)
0