glue-viz / glue-vispy-viewers

3-d data viewers for glue based on VisPy
http://glueviz.org/en/stable/whatsnew/experimental_3d.html#experimental-3d
BSD 2-Clause "Simplified" License
25 stars 21 forks source link

Avoid division by zero errors #244

Closed astrofrog closed 7 years ago

astrofrog commented 7 years ago

A number of bug reports (reported via glue itself) show that under certain circumstances, there can be division by zero here:

Traceback (most recent call last):

File "/Users/max/anaconda3/lib/python3.5/site-packages/glue_vispy_viewers/common/viewer_options.py", line 264, in _update_limits
  self._update_aspect()
File "/Users/max/anaconda3/lib/python3.5/site-packages/glue_vispy_viewers/common/viewer_options.py", line 115, in _update_aspect
  self._vispy_widget._update_limits()
File "/Users/max/anaconda3/lib/python3.5/site-packages/glue_vispy_viewers/common/vispy_widget.py", line 122, in _update_limits
  scale = [2 / (self.options.x_max - self.options.x_min) * self.options.x_stretch * self.options.aspect[0],
ZeroDivisionError: float division by zero Traceback (most recent call last):

for instance if the limits are equal. We need to catch and avoid these cases.