Skip to content

Commit

Permalink
Merge pull request #1143 from psavery/catch-mouse-move-index-error
Browse files Browse the repository at this point in the history
Catch IndexError on mouse move
  • Loading branch information
psavery authored Jan 28, 2022
2 parents ea1f1f0 + 2441f8d commit aea3f2b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion hexrd/ui/image_tab_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,17 @@ def on_motion_notify_event(self, event):
if event.inaxes.get_images():
# Image was created with imshow()
artist = event.inaxes.get_images()[0]

i, j = utils.coords2index(artist, info['x_data'], info['y_data'])
intensity = artist.get_array().data[i, j]
try:
intensity = artist.get_array().data[i, j]
except IndexError:
# Most likely, this means we are slightly out of bounds,
# and the index is too big. Just clear the status bar in
# this case.
# FIXME: can we avoid this somehow?
self.clear_mouse_position.emit()
return
else:
# This is probably just a plot. Do not calculate intensity.
intensity = None
Expand Down

0 comments on commit aea3f2b

Please sign in to comment.