Relax image test requirements for Qt5 (there are some single-pixel shifts that
we will nee new test images to cover)
This commit is contained in:
parent
04bbbc453a
commit
c58a177561
@ -59,7 +59,7 @@ if sys.version[0] >= '3':
|
|||||||
else:
|
else:
|
||||||
import httplib
|
import httplib
|
||||||
import urllib
|
import urllib
|
||||||
from ..Qt import QtGui, QtCore, QtTest
|
from ..Qt import QtGui, QtCore, QtTest, QT_LIB
|
||||||
from .. import functions as fn
|
from .. import functions as fn
|
||||||
from .. import GraphicsLayoutWidget
|
from .. import GraphicsLayoutWidget
|
||||||
from .. import ImageItem, TextItem
|
from .. import ImageItem, TextItem
|
||||||
@ -212,7 +212,7 @@ def assertImageApproved(image, standardFile, message=None, **kwargs):
|
|||||||
|
|
||||||
|
|
||||||
def assertImageMatch(im1, im2, minCorr=None, pxThreshold=50.,
|
def assertImageMatch(im1, im2, minCorr=None, pxThreshold=50.,
|
||||||
pxCount=0, maxPxDiff=None, avgPxDiff=None,
|
pxCount=-1, maxPxDiff=None, avgPxDiff=None,
|
||||||
imgDiff=None):
|
imgDiff=None):
|
||||||
"""Check that two images match.
|
"""Check that two images match.
|
||||||
|
|
||||||
@ -234,7 +234,8 @@ def assertImageMatch(im1, im2, minCorr=None, pxThreshold=50.,
|
|||||||
pxThreshold : float
|
pxThreshold : float
|
||||||
Minimum value difference at which two pixels are considered different
|
Minimum value difference at which two pixels are considered different
|
||||||
pxCount : int or None
|
pxCount : int or None
|
||||||
Maximum number of pixels that may differ
|
Maximum number of pixels that may differ. Default is 0 for Qt4 and
|
||||||
|
1% of image size for Qt5.
|
||||||
maxPxDiff : float or None
|
maxPxDiff : float or None
|
||||||
Maximum allowed difference between pixels
|
Maximum allowed difference between pixels
|
||||||
avgPxDiff : float or None
|
avgPxDiff : float or None
|
||||||
@ -247,6 +248,14 @@ def assertImageMatch(im1, im2, minCorr=None, pxThreshold=50.,
|
|||||||
assert im1.shape[2] == 4
|
assert im1.shape[2] == 4
|
||||||
assert im1.dtype == im2.dtype
|
assert im1.dtype == im2.dtype
|
||||||
|
|
||||||
|
if pxCount == -1:
|
||||||
|
if QT_LIB == 'PyQt5':
|
||||||
|
# Qt5 generates slightly different results; relax the tolerance
|
||||||
|
# until test images are updated.
|
||||||
|
pxCount = int(im1.shape[0] * im1.shape[1] * 0.01)
|
||||||
|
else:
|
||||||
|
pxCount = 0
|
||||||
|
|
||||||
diff = im1.astype(float) - im2.astype(float)
|
diff = im1.astype(float) - im2.astype(float)
|
||||||
if imgDiff is not None:
|
if imgDiff is not None:
|
||||||
assert np.abs(diff).sum() <= imgDiff
|
assert np.abs(diff).sum() <= imgDiff
|
||||||
|
Loading…
Reference in New Issue
Block a user