def _checkOutputs(self, outputs, random=False, errorthreshold=0.001): """ Check that all output files are produced and are equivalent to the ones in goldStandard folder. """ for out in outputs: outFile = os.path.join(self._testDir, self.outputDir, out) fileGoldStd = os.path.join(self.goldDir, out) # Check the expect output file was produced msg = "Missing expected output file:\n output: %s" % outFile self.assertTrue(os.path.exists(outFile), msg) if random: print "WARNING: %s was created using a random seed, check skipped\n " % outFile else: fnGoldStd = xmipp.FileName(fileGoldStd) if fnGoldStd.isImage(): im1 = xmipp.Image(fileGoldStd) im2 = xmipp.Image(outFile) msg = "Images are not equal (+-%f):\n output: %s\n gold: %s" % \ (errorthreshold, outFile, fileGoldStd) self.assertTrue(im1.equal(im2, errorthreshold), msg) elif fnGoldStd.isMetaData(): msg = "MetaDatas are not equal:\n output: %s\n gold: %s" % ( outFile, fileGoldStd) self.assertTrue( xmipp.compareTwoMetadataFiles(outFile, fileGoldStd), msg) else: msg = "Files are not equal:\n output: %s\n gold: %s" % ( outFile, fileGoldStd) self.assertTrue( xmipp.compareTwoFiles(outFile, fileGoldStd, 0), msg)
def checkResult(self, testfiles, outDir, random): error = "" try: from xmipp import FileName, Image, compareTwoFiles, compareTwoMetadataFiles for file in testfiles: file = join(outDir, file) fileGoldStd = file.replace(self.fnDir, 'goldStandard') result = True if not exists(file): error += file + " was NOT produced\n" else: if (random): self.warning += file + " was created using a random seed, check skipped\n" self.warningFlag = True else: fnGoldStd = FileName(fileGoldStd) if fnGoldStd.isImage(): im1 = Image(fileGoldStd) im2 = Image(file) result = im1.equal(im2, 0.001) elif fnGoldStd.isMetaData(): result = compareTwoMetadataFiles(file, fileGoldStd) else: result = compareTwoFiles(file, fileGoldStd, 0) if not result: error += " file '%s' and '%s' are NOT identical\n" % (file, fileGoldStd) except KeyboardInterrupt: raise except Exception, ex: error += " Error checking results: '%s'\n" % str(ex)
def checkResult(self, testfiles, outDir, random): error = "" try: from xmipp import FileName, Image, compareTwoFiles, compareTwoMetadataFiles for file in testfiles: file = join(outDir, file) fileGoldStd = file.replace(self.fnDir, 'goldStandard') result = True if not exists(file): error += file + " was NOT produced\n" else: if (random): self.warning += file + " was created using a random seed, check skipped\n" self.warningFlag = True else: fnGoldStd = FileName(fileGoldStd) if fnGoldStd.isImage(): im1 = Image(fileGoldStd) im2 = Image(file) result = im1.equal(im2, 0.001) elif fnGoldStd.isMetaData(): result = compareTwoMetadataFiles(file, fileGoldStd) else: result = compareTwoFiles(file, fileGoldStd, 0) if not result: error += " file '%s' and '%s' are NOT identical\n" % ( file, fileGoldStd) except KeyboardInterrupt: raise except Exception, ex: error += " Error checking results: '%s'\n" % str(ex)
def _checkOutputs(self, outputs, random=False): """ Check that all output files are produced and are equivalent to the ones in goldStandard folder. """ for out in outputs: outFile = os.path.join(self._testDir, self.outputDir, out) fileGoldStd = os.path.join(self.goldDir, out) # Check the expect output file was produced msg = "Missing expected output file:\n output: %s" % outFile self.assertTrue(os.path.exists(outFile), msg) if random: print "WARNING: %s was created using a random seed, check skipped\n " % outFile else: fnGoldStd = xmipp.FileName(fileGoldStd) if fnGoldStd.isImage(): im1 = xmipp.Image(fileGoldStd) im2 = xmipp.Image(outFile) msg = "Images are not equal:\n output: %s\n gold: %s" % (outFile, fileGoldStd) self.assertTrue(im1.equal(im2, 0.001), msg) elif fnGoldStd.isMetaData(): msg = "MetaDatas are not equal:\n output: %s\n gold: %s" % (outFile, fileGoldStd) self.assertTrue(xmipp.compareTwoMetadataFiles(outFile, fileGoldStd), msg) else: msg = "Files are not equal:\n output: %s\n gold: %s" % (outFile, fileGoldStd) self.assertTrue(xmipp.compareTwoFiles(outFile, fileGoldStd, 0), msg)