def preProcess(self): """ PreProcess of the execution test: download a set of images from http://www.edna-site.org and remove any existing output file """ EDTestCasePluginExecute.preProcess(self) self.loadTestImage(["bioSaxsRaw.edf", "bioSaxsMask.edf", "bioSaxsNormalized.edf", "bioSaxsNormalized.log"]) strExpectedOutput = self.readAndParseFile (self.getReferenceDataOutputFile()) EDVerbose.DEBUG("strExpectedOutput:" + strExpectedOutput) xsDataResultReference = XSDataResultBioSaxsNormalizev1_0.parseString(strExpectedOutput) self.refOutput = xsDataResultReference.normalizedImage.getPath().value EDVerbose.DEBUG("Output file is %s" % self.refOutput) if not os.path.isdir(os.path.dirname(self.refOutput)): os.makedirs(os.path.dirname(self.refOutput)) if os.path.isfile(self.refOutput): EDVerbose.DEBUG(" Output file exists %s, I will remove it" % self.refOutput) os.remove(self.refOutput)
def testExecute(self): """ """ self.run() plugin = self.getPlugin() ################################################################################ # Compare XSDataResults ################################################################################ strExpectedOutput = self.readAndParseFile (self.getReferenceDataOutputFile()) EDVerbose.DEBUG("Checking obtained result...") xsDataResultReference = XSDataResultBioSaxsNormalizev1_0.parseString(strExpectedOutput) xsDataResultObtained = plugin.getDataOutput() EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), "XSDataResult output are the same", _strExcluded="bioSaxs") ################################################################################ # Compare dictionary ################################################################################ edfRef = openimage(xsDataResultObtained.normalizedImage.getPath().value) edfObt = openimage(os.path.join(self.getTestsDataImagesHome(), "bioSaxsCorrected.edf")) headerRef = edfRef.header headerObt = edfObt.header keysRef = headerRef.keys() keysObt = headerObt.keys() keysRef.sort() keysObt.sort() # EDAssert.equal(keysRef, keysObt, _strComment="Same keys in the header dict") for key in keysRef: if not (key.startswith("History") or key in [ "Compression", "DDummy", "Dummy", "EDF_HeaderSize", "HeaderID", "Image", "filename", "RasterOrientation", "time_of_day"]): EDAssert.strAlmostEqual(headerRef[key], headerObt[key], _strComment="header value %s are the same" % key, _strExcluded="bioSaxs") ################################################################################ # Compare images ################################################################################ outputData = edfRef.data referenceData = edfObt.data EDAssert.arraySimilar(numpy.maximum(outputData, 0), numpy.maximum(referenceData, 0) , _fAbsMaxDelta=0.1, _fScaledMaxDelta=0.05, _strComment="Images-data are the same") outputData = edfRef.next().data referenceData = edfObt.next().data EDAssert.arraySimilar(numpy.maximum(outputData, 0), numpy.maximum(referenceData, 0) , _fAbsMaxDelta=0.1, _fScaledMaxDelta=0.05, _strComment="Images-ESD are the same")
def preProcess(self): """ PreProcess of the execution test: download a set of images from http://www.edna-site.org and remove any existing output file """ EDTestCasePluginExecute.preProcess(self) self.loadTestImage( ["bioSaxsRaw.edf", "bioSaxsMask.edf", "bioSaxsCorrected.edf"]) strExpectedOutput = self.readAndParseFile( self.getReferenceDataOutputFile()) EDVerbose.DEBUG("strExpectedOutput:" + strExpectedOutput) xsDataResultReference = XSDataResultBioSaxsNormalizev1_0.parseString( strExpectedOutput) self.refOutput = xsDataResultReference.normalizedImage.getPath().value EDVerbose.DEBUG("Output file is %s" % self.refOutput) if not os.path.isdir(os.path.dirname(self.refOutput)): os.makedirs(os.path.dirname(self.refOutput)) if os.path.isfile(self.refOutput): EDVerbose.DEBUG(" Output file exists %s, I will remove it" % self.refOutput) os.remove(self.refOutput)
def testExecute(self): """ """ self.run() plugin = self.getPlugin() ################################################################################ # Compare XSDataResults ################################################################################ strExpectedOutput = self.readAndParseFile( self.getReferenceDataOutputFile()) EDVerbose.DEBUG("Checking obtained result...") xsDataResultReference = XSDataResultBioSaxsNormalizev1_0.parseString( strExpectedOutput) xsDataResultObtained = plugin.getDataOutput() EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), "XSDataResult output are the same", _strExcluded="bioSaxs") ################################################################################ # Compare dictionary ################################################################################ edfRef = openimage( xsDataResultObtained.normalizedImage.getPath().value) edfObt = openimage( os.path.join(self.getTestsDataImagesHome(), "bioSaxsCorrected.edf")) headerRef = edfRef.header headerObt = edfObt.header keysRef = headerRef.keys() keysObt = headerObt.keys() keysRef.sort() keysObt.sort() # EDAssert.equal(keysRef, keysObt, _strComment="Same keys in the header dict") for key in keysRef: if not (key.startswith("History") or key in [ "Compression", "DDummy", "Dummy", "EDF_HeaderSize", "HeaderID", "Image", "filename", "RasterOrientation", "time_of_day" ]): EDAssert.strAlmostEqual( headerRef[key], headerObt[key], _strComment="header value %s are the same" % key, _strExcluded="bioSaxs") ################################################################################ # Compare images ################################################################################ outputData = edfRef.data referenceData = edfObt.data EDAssert.arraySimilar(numpy.maximum(outputData, 0), numpy.maximum(referenceData, 0), _fAbsMaxDelta=0.1, _fScaledMaxDelta=0.05, _strComment="Images-data are the same") outputData = edfRef.next().data referenceData = edfObt.next().data EDAssert.arraySimilar(numpy.maximum(outputData, 0), numpy.maximum(referenceData, 0), _fAbsMaxDelta=0.1, _fScaledMaxDelta=0.05, _strComment="Images-ESD are the same")
def testExecute(self): """ """ self.run() plugin = self.getPlugin() ################################################################################ # Compare XSDataResults ################################################################################ strExpectedOutput = self.readAndParseFile( self.getReferenceDataOutputFile()) # strObtainedOutput = self.readAndParseFile (self.m_edObtainedOutputDataFile) EDVerbose.DEBUG("Checking obtained result...") xsDataResultReference = XSDataResultBioSaxsNormalizev1_0.parseString( strExpectedOutput) xsDataResultObtained = plugin.getDataOutput() EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), "XSDataResult output are the same", _strExcluded="bioSaxs") ################################################################################ # Compare Log Files ################################################################################ outputData = "" for oneLine in open(xsDataResultObtained.getLogFile().getPath().value, "rb").readlines(): oneline = oneLine.lower() if oneline.startswith("first"): outputData += oneLine if oneline.startswith("last"): outputData += oneLine if oneline.startswith("increment"): outputData += oneLine if oneline.startswith("factor"): outputData += oneLine if oneline.startswith("constant"): outputData += oneLine referenceData = "" for oneLine in open( os.path.join(self.getTestsDataImagesHome(), "bioSaxsNormalized.log"), "rb").readlines(): oneline = oneLine.lower() if oneline.startswith("first"): referenceData += oneLine elif oneline.startswith("last"): referenceData += oneLine elif oneline.startswith("increment"): referenceData += oneLine elif oneline.startswith("factor"): referenceData += oneLine elif oneline.startswith("constant"): referenceData += oneLine EDAssert.strAlmostEqual(referenceData, outputData, _strComment="LogFiles are the same", _fAbsError=0.1) ################################################################################ # Compare dictionary ################################################################################ edfRef = EdfFile.EdfFile( xsDataResultObtained.normalizedImage.getPath().value) edfObt = EdfFile.EdfFile( os.path.join(self.getTestsDataImagesHome(), "bioSaxsNormalized.edf")) ######################################################################## # Deprected plugin => deprected test ######################################################################## # headerRef = edfRef.GetHeader(0) # headerObt = edfObt.GetHeader(0) # keysRef = headerRef.keys() # keysObt = headerObt.keys() # keysRef.sort() # keysObt.sort() # for key in ["HeaderID", "Image", 'EDF_BinarySize', "EDF_DataBlockID", "EDF_HeaderSize", "filename", "RasterOrientation", "time_of_day" ]: # if key in keysObt: keysObt.remove(key) # if key in keysRef: keysRef.remove(key) # EDAssert.equal(keysRef, keysObt, _strComment="Same keys in the header dict") # for key in keysRef: # if not key.startswith("History"): # EDAssert.strAlmostEqual(headerRef[key], headerObt[key], _strComment="header value %s are the same" % key, _strExcluded="bioSaxs") ################################################################################ # Compare images ################################################################################ outputData = edfRef.GetData(0) referenceData = edfObt.GetData(0) EDAssert.arraySimilar(outputData, referenceData, _fAbsMaxDelta=0.1, _fScaledMaxDelta=0.05, _strComment="Images-data are the same") outputData = edfRef.GetData(1) referenceData = edfObt.GetData(1) EDAssert.arraySimilar(outputData, referenceData, _fAbsMaxDelta=0.1, _fScaledMaxDelta=0.05, _strComment="Images-ESD are the same")
def testExecute(self): """ """ self.run() plugin = self.getPlugin() ################################################################################ # Compare XSDataResults ################################################################################ strExpectedOutput = self.readAndParseFile (self.getReferenceDataOutputFile()) # strObtainedOutput = self.readAndParseFile (self.m_edObtainedOutputDataFile) EDVerbose.DEBUG("Checking obtained result...") xsDataResultReference = XSDataResultBioSaxsNormalizev1_0.parseString(strExpectedOutput) xsDataResultObtained = plugin.getDataOutput() EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), "XSDataResult output are the same", _strExcluded="bioSaxs") ################################################################################ # Compare Log Files ################################################################################ outputData = "" for oneLine in open(xsDataResultObtained.getLogFile().getPath().value, "rb").readlines(): oneline = oneLine.lower() if oneline.startswith("first"):outputData += oneLine if oneline.startswith("last"):outputData += oneLine if oneline.startswith("increment"):outputData += oneLine if oneline.startswith("factor"):outputData += oneLine if oneline.startswith("constant"):outputData += oneLine referenceData = "" for oneLine in open(os.path.join(self.getTestsDataImagesHome(), "bioSaxsNormalized.log"), "rb").readlines(): oneline = oneLine.lower() if oneline.startswith("first"):referenceData += oneLine elif oneline.startswith("last"):referenceData += oneLine elif oneline.startswith("increment"):referenceData += oneLine elif oneline.startswith("factor"):referenceData += oneLine elif oneline.startswith("constant"):referenceData += oneLine EDAssert.strAlmostEqual(referenceData, outputData, _strComment="LogFiles are the same", _fAbsError=0.1) ################################################################################ # Compare dictionary ################################################################################ edfRef = EdfFile.EdfFile(xsDataResultObtained.normalizedImage.getPath().value) edfObt = EdfFile.EdfFile(os.path.join(self.getTestsDataImagesHome(), "bioSaxsNormalized.edf")) ######################################################################## # Deprected plugin => deprected test ######################################################################## # headerRef = edfRef.GetHeader(0) # headerObt = edfObt.GetHeader(0) # keysRef = headerRef.keys() # keysObt = headerObt.keys() # keysRef.sort() # keysObt.sort() # for key in ["HeaderID", "Image", 'EDF_BinarySize', "EDF_DataBlockID", "EDF_HeaderSize", "filename", "RasterOrientation", "time_of_day" ]: # if key in keysObt: keysObt.remove(key) # if key in keysRef: keysRef.remove(key) # EDAssert.equal(keysRef, keysObt, _strComment="Same keys in the header dict") # for key in keysRef: # if not key.startswith("History"): # EDAssert.strAlmostEqual(headerRef[key], headerObt[key], _strComment="header value %s are the same" % key, _strExcluded="bioSaxs") ################################################################################ # Compare images ################################################################################ outputData = edfRef.GetData(0) referenceData = edfObt.GetData(0) EDAssert.arraySimilar(outputData, referenceData , _fAbsMaxDelta=0.1, _fScaledMaxDelta=0.05, _strComment="Images-data are the same") outputData = edfRef.GetData(1) referenceData = edfObt.GetData(1) EDAssert.arraySimilar(outputData, referenceData , _fAbsMaxDelta=0.1, _fScaledMaxDelta=0.05, _strComment="Images-ESD are the same")