Merge pull request #183 from ericdill/zero-div-is-bad
MNT: Don't allow divide by zero
This commit is contained in:
commit
0865a3166b
@ -291,8 +291,8 @@ class ImageItem(GraphicsObject):
|
||||
y = self.mapToDevice(QtCore.QPointF(0,1))
|
||||
w = Point(x-o).length()
|
||||
h = Point(y-o).length()
|
||||
xds = max(1, int(1/w))
|
||||
yds = max(1, int(1/h))
|
||||
xds = int(1/max(1, w))
|
||||
yds = int(1/max(1, h))
|
||||
image = fn.downsample(self.image, xds, axis=0)
|
||||
image = fn.downsample(image, yds, axis=1)
|
||||
else:
|
||||
|
24
pyqtgraph/graphicsItems/tests/test_ImageItem.py
Normal file
24
pyqtgraph/graphicsItems/tests/test_ImageItem.py
Normal file
@ -0,0 +1,24 @@
|
||||
import gc
|
||||
import weakref
|
||||
# try:
|
||||
# import faulthandler
|
||||
# faulthandler.enable()
|
||||
# except ImportError:
|
||||
# pass
|
||||
|
||||
from pyqtgraph.Qt import QtCore, QtGui, QtTest
|
||||
import numpy as np
|
||||
import pyqtgraph as pg
|
||||
app = pg.mkQApp()
|
||||
|
||||
|
||||
def test_dividebyzero():
|
||||
import pyqtgraph as pg
|
||||
im = pg.image(pg.np.random.normal(size=(100,100)))
|
||||
im.imageItem.setAutoDownsample(True)
|
||||
im.view.setRange(xRange=[-5+25, 5e+25],yRange=[-5e+25, 5e+25])
|
||||
app.processEvents()
|
||||
QtTest.QTest.qWait(1000)
|
||||
# must manually call im.imageItem.render here or the exception
|
||||
# will only exist on the Qt event loop
|
||||
im.imageItem.render()
|
Loading…
Reference in New Issue
Block a user