8000 Fix failing tests · matplotlib/matplotlib@cf58c0a · GitHub
[go: up one dir, main page]

Skip to content

Commit cf58c0a

Browse files
committed
Fix failing tests
1 parent babc377 commit cf58c0a

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

lib/matplotlib/tests/test_widgets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def onselect(epress, erelease):
7575
assert erelease.xdata == 150
7676
assert erelease.ydata == 150
7777

78+
7879
tool = widgets.RectangleSelector(ax, onselect, **kwargs)
7980
event = get_event(ax, xdata=100, ydata=100, button=1)
8081
tool.press(event)
@@ -144,7 +145,6 @@ def check_lasso_selector(**kwargs):
144145

145146
def onselect(verts):
146147
ax._got_onselect = True
147-
print(verts)
148148
assert verts == [(100, 100), (125, 125), (150, 150)]
149149

150150
tool = widgets.LassoSelector(ax, onselect, **kwargs)

lib/matplotlib/widgets.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,10 +1108,10 @@ def __init__(self, ax, onselect, useblit=False, button=None):
11081108
self.artists = []
11091109
self.useblit = useblit and self.canvas.supports_blit
11101110

1111-
if button is None or isinstance(button, list):
1112-
self.validButtons = button
1113-
elif isinstance(button, int):
1111+
if isinstance(button, int):
11141112
self.validButtons = [button]
1113+
else:
1114+
self.validButtons = button
11151115

11161116
# will save the data (position at mouseclick)
11171117
self.eventpress = None
@@ -1192,8 +1192,16 @@ def update(self):
11921192
if self.background is not None:
11931193
self.canvas.restore_region(self.background)
11941194
for artist in self.artists:
1195-
self.ax.draw_artist(artist)
1196-
self.canvas.blit(self.ax.bbox)
1195+
try:
1196+
self.ax.draw_artist(artist)
1197+
except AssertionError:
1198+
self.canvas.draw_idle()
1199+
return False
1200+
try:
1201+
self.canvas.blit(self.ax.bbox)
1202+
except AttributeError:
1203+
self.canvas.draw_idle()
1204+
return False
11971205
else:
11981206
self.canvas.draw_idle()
11991207
return False
@@ -1425,7 +1433,6 @@ def onmove(self, event):
14251433
self.onmove_callback(vmin, vmax)
14261434

14271435
self.update()
1428-
self.eventpress = None
14291436
return False
14301437

14311438

0 commit comments

Comments
 (0)
0