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 = XSDataResultBioSaxsAsciiExportv1_0.parseString(strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()
        EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), "XSDataResult output are the same", _strExcluded="bioSaxs")

################################################################################
# Compare spectrum ascii Files
################################################################################

        outputData = open(xsDataResultObtained.getIntegratedCurve().getPath().value, "rb").read()
        referenceData = open(os.path.join(self.getTestsDataImagesHome(), "bioSaxsAsciiExportv1_1.dat"), "rb").read()

        EDAssert.strAlmostEqual(referenceData, outputData, _strComment="3-column ascii spectra files are the same", _fRelError=0.1, _fAbsError=0.1, _strExcluded="bioSaxs")
    def testExecute(self):
        """
        """
        self.run()

        plugin = self.getPlugin()

        strExpectedOutput = self.readAndParseFile(
            self.getReferenceDataOutputFile())
        #        strObtainedOutput = self.readAndParseFile (self.m_edObtainedOutputDataFile)
        EDVerbose.DEBUG("Checking obtained result...")
        xsDataResultReference = XSDataResultSaxsMacv1_0.parseString(
            strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()
        EDAssert.strAlmostEqual(xsDataResultReference.marshal(),
                                xsDataResultObtained.marshal(),
                                "XSDataResult output are the same")

        outputData = openimage(
            xsDataResultObtained.getOutputImage().getPath().getValue()).data
        referenceData = openimage(
            os.path.join(self.getTestsDataImagesHome(), "moke.edf")).data
        EDAssert.arraySimilar(outputData,
                              referenceData,
                              _fAbsMaxDelta=0.8,
                              _fScaledMaxDelta=0.05,
                              _fRfactor=5,
                              _fRelMaxDelta=1.5,
                              _strComment="Images are the same")
    def testExecute(self):
        """
        """
        self.run()

        plugin = self.getPlugin()

        EDVerbose.DEBUG("Checking obtained result...")
        strExpectedOutput = self.readAndParseFile (self.getReferenceDataOutputFile())
        xsDataResultReference = XSDataResultSPDCake.parseString(strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()
#        EDVerbose.DEBUG("Reference XML:%s" + xsDataResultReference.marshal())
#        EDVerbose.DEBUG("Obtained XML:%s" + xsDataResultObtained.marshal())
        EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), "XSDataResult output are the same")

        # Checking obtained results
        xsDataResultsSPDCake = plugin.getDataOutput()
        strPathToChiOutput = xsDataResultsSPDCake.getCakedFile().getPath().getValue()
        strPathToChiReference = os.path.join(self.getTestsDataImagesHome(), "EDPluginSPDCakev1_0.chi")
        Xref, Yref = readChiPlot(strPathToChiReference)
        Xobt, Yobt = readChiPlot(strPathToChiOutput)
        EDVerbose.DEBUG("Output File: %s, Reference file: %s" % (strPathToChiOutput, strPathToChiReference))
        bigX = Xref + Xobt
        bigX.sort()
        bigYobt = numpy.interp(bigX, Xobt, Yobt)
        bigYref = numpy.interp(bigX, Xref, Yref)
        EDVerbose.DEBUG("ref.shape= %s, obt.shape=%s" % (bigYobt.shape, bigYref.shape))
        EDVerbose.DEBUG("Type of object ref= %s, obt=%s" % (bigYobt.__class__, bigYref.__class__))
        EDAssert.arraySimilar(bigYobt, bigYref, _fAbsMaxDelta=0.1, _fScaledMaxDelta=0.1, _strComment="Comparing ChiPlot files")
示例#4
0
    def testExecute(self):
        """
        """
        self.run()
        plugin = self.getPlugin()

        strExpectedOutput = self.readAndParseFile(
            self.getReferenceDataOutputFile())
        xsDataResultReference = XSDataResultSPDCake.parseString(
            strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()
        #        EDVerbose.DEBUG("Reference XML:%s" + xsDataResultReference.marshal())
        #        EDVerbose.DEBUG("Obtained XML:%s" + xsDataResultObtained.marshal())
        EDAssert.strAlmostEqual(xsDataResultReference.marshal(),
                                xsDataResultObtained.marshal(),
                                "XSDataResult output are the same")

        # Checking obtained results
        xsDataResultsSPDCake = plugin.getDataOutput()
        strPathToChiOutput = xsDataResultsSPDCake.getCakedFile().getPath(
        ).getValue()
        strDataObtained = EDUtilsFile.readFile(strPathToChiOutput)
        strDataReference = EDUtilsFile.readFile(
            os.path.join(self.getTestsDataImagesHome(),
                         "EDPluginSPDCakev1_1.cif"))
        EDAssert.strAlmostEqual(strDataReference,
                                strDataObtained,
                                "Comparing PowderCIF output",
                                _fAbsError=2e-3)
    def testExecute(self):
        """
        """
        self.run()
        plugin = self.getPlugin()

################################################################################
# Compare XSDataResults
################################################################################

        strExpectedOutput = self.readAndParseFile (self.getReferenceDataOutputFile())
        EDVerbose.DEBUG("Checking obtained result...")
        xsDataResultReference = XSDataResultBioSaxsProcessOneFilev1_0.parseString(strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()
        EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), "XSDataResult output are the same", _strExcluded="bioSaxs")


################################################################################
# Compare Ascii HEADER files
################################################################################
        asciiObt = os.linesep.join([i.strip() for i in  open(xsDataResultObtained.integratedCurve.path.value) if i.startswith("#") and "Raster" not in i])
        asciiRef = os.linesep.join([i.strip() for i in  open(os.path.join(self.getTestsDataImagesHome(), "bioSaxsProcessIntegrated1_2.dat")) if i.startswith("#") and "Raster" not in i])

        EDAssert.strAlmostEqual(asciiObt, asciiRef, _strComment="ascii header files are the same", _fRelError=0.1, _strExcluded=os.environ["USER"])

        dataObt = numpy.loadtxt(xsDataResultObtained.integratedCurve.path.value)
        dataRef = numpy.loadtxt(os.path.join(self.getTestsDataImagesHome(), "bioSaxsProcessIntegrated1_2.dat"))
        EDAssert.curveSimilar((dataObt[:, 0], dataObt[:, 1]), (dataRef[:, 0], dataRef[:, 1]), "data are the same", 0.6)
        EDAssert.curveSimilar((dataObt[:, 0], dataObt[:, 2]), (dataRef[:, 0], dataRef[:, 2]), "errors are the same", 0.6)


        EDVerbose.screen("Execution time for %s: %.3fs" % (plugin.getClassName(), plugin.getRunTime()))
    def testExecute(self):
        """
        """
        self.run()
        plugin = self.getPlugin()
        ################################################################################
        # Compare XSDataResults
        ################################################################################
        strExpectedOutput = self.readAndParseFile(
            self.getReferenceDataOutputFile())
        EDVerbose.DEBUG("Checking obtained result...")

        xsDataResultObtained = plugin.getDataOutput()
        EDAssert.strAlmostEqual(self.xsDataResultReference.marshal(),
                                xsDataResultObtained.marshal(),
                                "XSDataResult output are the same")
        ################################################################################
        # Compare image Files
        ################################################################################
        outputData = Image.open(self.outputFile)
        referenceData = Image.open(
            os.path.join(self.getTestsDataImagesHome(),
                         os.path.basename(self.outputFile)))
        delta = ImageChops.difference(outputData, referenceData)
        deltaColor = delta.getextrema()
        i = 0
        for color in deltaColor:
            EDAssert.lowerThan(
                color[1], 12, "Maximum tone variation is %s for channel %s" %
                (color[1], "RGBA"[i]))
            i += 1
    def testExecute(self):
        """
        """
        self.run()

        # Checks that there are no error messages

        plugin = self.getPlugin()

        # Checks the expected result
        strExpectedOutput = self.readAndParseFile (self.getReferenceDataOutputFile())
#        strObtainedOutput = plugin.getDataOutput().marshal() # EDUtilsTest.readAndParseFile ( self.m_edObtainedOutputDataFile )    
        EDVerbose.DEBUG("Checking obtained result...")


        xsDataResultReference = XSDataResultDiffractionCT.parseString(strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()# XSDataResultDiffractionCT.parseString(strObtainedOutput)

        EDAssert.equal(xsDataResultReference.marshal(), xsDataResultObtained.marshal())

        ref = self.readAndParseFile(os.path.join(self.getTestsDataImagesHome(), "DCT2011March.chi"))
        obt = self.readAndParseFile(xsDataResultObtained.getIntegratedIntensities().getPath().getValue())
        EDAssert.strAlmostEqual(ref, obt, "Chi files are the same", 0.001)

# clean up SPD when finished
        EDFactoryPluginStatic.loadPlugin("EDPluginSPDCorrectv10").killAllWorkers()
    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 = XSDataResultBioSaxsAzimutIntv1_0.parseString(strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()
        EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), "XSDataResult output are the same", _strExcluded="bioSaxs")

################################################################################
# Compare spectrum ascii Files
################################################################################

        outputData = open(xsDataResultObtained.getIntegratedCurve().getPath().value, "rb").read().split(os.linesep)
        referenceData = EDUtilsFile.readFileAndParseVariables(os.path.join(self.getTestsDataImagesHome(), "bioSaxsIntegratedv1_3.dat"), EDUtilsPath.getDictOfPaths()).split(os.linesep)
        outputData = os.linesep.join([i for i in outputData if not i.startswith("# History")])
        referenceData = os.linesep.join([i for i in referenceData if not i.startswith("# History")])
        EDAssert.strAlmostEqual(referenceData, outputData, _strComment="3column ascii spectra files are the same", _fRelError=0.1, _fAbsError=0.1, _strExcluded="bioSaxs")
 def testExecute(self):
     """
     """
     plugin = self.getPlugin()
     plugin.__class__.lastBuffer = XSDataFile(
         XSDataString(
             os.path.join(EDUtilsPath.EDNA_TESTIMAGES,
                          "buffer_before.dat")))
     plugin.__class__.lastSample = XSDataFile(
         XSDataString(
             os.path.join(EDUtilsPath.EDNA_TESTIMAGES,
                          "bioSaxsAveraged.dat")))
     self.run()
     plugin = self.getPlugin()
     xsdRef = XSDataResultBioSaxsSmartMergev1_0.parseString(
         self.readAndParseFile(self.getReferenceDataOutputFile()))
     xsdRef.autoRg = None
     xsdObt = plugin.getDataOutput()
     xsdObt.status = None  #Executive summary is too complicated to test
     EDAssert.strAlmostEqual(xsdRef.marshal(),
                             xsdObt.marshal(),
                             "XML output structures are the same",
                             _fAbsError=0.1)
     #        ref = " ".join([" ".join(i.split()) for i in open(self.destFile)])
     #        obt = " ".join([" ".join(i.split()) for i in open(xsdObt.mergedCurve.path.value)])
     #        EDAssert.strAlmostEqual(ref, obt, "Files are the same", _fAbsError=0.1)
     print plugin.__class__.lastBuffer.path.value
     print plugin.__class__.lastSample.path.value
示例#10
0
    def testExecute(self):
        """
        """
        self.run()
        plugin = self.getPlugin()
################################################################################
# Compare XSDataResults
################################################################################
        strExpectedOutput = self.readAndParseFile (self.getReferenceDataOutputFile())
        EDVerbose.DEBUG("Checking obtained result...")
        xsDataResultReference = XSDataResultMatrixInvertFile.parseString(strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()
        EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), _strComment="XSDataResult output are the same")

################################################################################
# Check that  outputData * inputData - Id = 0
################################################################################
        outputData = openimage(self.outputFile).data
        size = outputData.shape[0]
        inputData = openimage(self.inputFile).data
        EDAssert.arraySimilar(numpy.matrix(outputData) * numpy.matrix(inputData), numpy.identity(size), _fAbsMaxDelta=2e-4, _strComment="output x input = Id ")


################################################################################
# Compare image Files
################################################################################
        referenceData = openimage(os.path.join(self.getTestsDataImagesHome(), os.path.basename(self.outputFile))).data
        EDAssert.arraySimilar(referenceData, outputData, _fAbsMaxDelta=1e-5, _strComment="images are the same")
    def testExecute(self):
        """
        """
        plugin = self.getPlugin()
        plugin.__class__.dictHPLC = {}
        self.run()

################################################################################
# Compare XSDataResults
################################################################################

        strExpectedOutput = self.readAndParseFile (self.getReferenceDataOutputFile())
        EDVerbose.DEBUG("Checking obtained result...")
        xsDataResultReference = XSDataResultBioSaxsHPLCv1_0.parseString(strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()
        EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), "XSDataResult output are the same", _strExcluded="bioSaxs")


################################################################################
# Compare Ascii files
################################################################################
        asciiObt = os.linesep.join([i.strip() for i in  open(xsDataResultObtained.integratedCurve.path.value) if "Raster" not in i])
        asciiRef = os.linesep.join([i.strip() for i in  open(os.path.join(self.getTestsDataImagesHome(), "bioSaxsProcessIntegrated1_2.dat")) if "Raster" not in i])

        EDAssert.strAlmostEqual(asciiRef, asciiObt, _strComment="3 column ascii files are the same", _fRelError=0.1, _strExcluded=os.environ["USER"])
        EDVerbose.screen("Execution time for %s: %.3fs" % (plugin.getClassName(), plugin.getRunTime()))
示例#12
0
    def testParse_xds_file(self):
        xdsInpPath = os.path.join(self.getPluginTestsDataHome(), "XDS_xdscfgparser.INP")
        parserDict = xdscfgparser.parse_xds_file(xdsInpPath)
#        import pprint
#        pprint.pprint(parserDict)
        EDAssert.equal([1, 4], parserDict["BACKGROUND_RANGE="], "BACKGROUND_RANGE")
        EDAssert.equal(['/data/id29/inhouse/opid291/x_geo_corr.cbf'], parserDict["X-GEO_CORR="], "X-GEO_CORR")
        EDAssert.strAlmostEqual(305.04, parserDict['DETECTOR_DISTANCE='], 'DETECTOR_DISTANCE')
 def testExecute(self):
     self.run()
     # Compare results
     strXMLExpected = self.readAndParseFile(self.getReferenceDataOutputFile())
     xsDataObtained = self.getPlugin().getDataOutput()
     xsDataExpected = XSDataMOSFLMOutputIndexing.parseString(strXMLExpected)
     EDAssert.strAlmostEqual(xsDataExpected.marshal(), xsDataObtained.marshal(), \
                             "(MOSFLM indexing result comparison - expected versus obtained)")
 def testExecute(self):
     """
     """
     self.run()
     xsdOut = self.getPlugin().getDataOutput()
     EDAssert.strAlmostEqual(XSDataResultDatcmp.parseFile(self.getReferenceDataOutputFile()).marshal(),
                             xsdOut.marshal() , "XSData are almost the same", _fAbsError=0.1)
     EDAssert.lowerThan(xsdOut.chi.value, 1.0, "Chi2 is lower than 1")
     EDAssert.equal(xsdOut.fidelity.value, 1.0, "Fidelity is 1")
 def testExecute(self):
     self.run()
     # Compare results
     strXMLExpected = self.readAndParseFile(
         self.getReferenceDataOutputFile())
     xsDataObtained = self.getPlugin().getDataOutput()
     xsDataExpected = XSDataMOSFLMOutputIndexing.parseString(strXMLExpected)
     EDAssert.strAlmostEqual(xsDataExpected.marshal(), xsDataObtained.marshal(), \
                             "(MOSFLM indexing result comparison - expected versus obtained)", _fAbsError=1000.0)
 def testExecute(self):
     """
     """
     self.run()
     xsdOut = self.getPlugin().getDataOutput()
     EDAssert.strAlmostEqual(XSDataResultDatcmp.parseFile(self.getReferenceDataOutputFile()).marshal(),
                             xsdOut.marshal() , "XSData are almost the same", _fAbsError=0.1)
     EDAssert.lowerThan(xsdOut.chi.value, 1.0, "Chi2 is lower than 1")
     EDAssert.equal(xsdOut.fidelity.value, 1.0, "Fidelity is 1")
示例#17
0
    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 = XSDataResultBioSaxsMetadatav1_0.parseString(
            strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()
        EDAssert.strAlmostEqual(xsDataResultReference.marshal(),
                                xsDataResultObtained.marshal(),
                                "XSDataResult output are the same",
                                _strExcluded="bioSaxs")

        ################################################################################
        # Compare dictionary:
        ################################################################################
        edfRef = EdfFile.EdfFile(
            xsDataResultObtained.getOutputImage().getPath().value)
        edfObt = EdfFile.EdfFile(
            os.path.join(self.getTestsDataImagesHome(), "bioSaxsMetadata.edf"))
        ########################################################################
        # DEPRECATED PLUGIN => DEPREFCATED TESTS
        ########################################################################
        #        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", "Center_1", "Center_2", "Code", "Comments", "Concentration",
        #                    "VersionNumber",'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 dictionary")
        #        for key in keysRef:
        #            EDAssert.strAlmostEqual(headerRef[key], headerObt[key], _strComment="header value %s are the same" % key, _strExcluded="bioSaxs")

        ################################################################################
        # Compare images
        ################################################################################

        outputData = edfObt.GetData(0)
        referenceData = edfRef.GetData(0)
        EDAssert.arraySimilar(outputData,
                              referenceData,
                              _fAbsMaxDelta=0.1,
                              _fScaledMaxDelta=0.05,
                              _strComment="Images-data are the same")
 def testExecute(self):
     self.run()
     # Compare results
     strXMLExpected = self.readAndParseFile(self.__strReferenceDataOutputFile)
     xsDataObtained = self.getPlugin().getDataOutput()
     xsDataExpected = XSDataMOSFLMOutputIntegration.parseString(strXMLExpected)
     # Remove the bestFileHKL part which creates problem...
     xsDataObtained.setBestfileHKL(None)
     xsDataExpected.setBestfileHKL(None)
     EDAssert.strAlmostEqual(xsDataExpected.marshal(), xsDataObtained.marshal(), "(MOSFLM integration result comparison - expected versus obtained)", 0.1, 5000)
    def testExecute(self):
        self.run()

        # Checks the expected result
        strObtainedOutput = self.readAndParseFile(self.m_edObtainedOutputDataFile)
        from XSDataMOSFLMv10 import XSDataMOSFLMOutputGeneratePrediction
        xsDataMOSFLMOutputGeneratePrediction = XSDataMOSFLMOutputGeneratePrediction.parseString(strObtainedOutput)
        strImagePath = xsDataMOSFLMOutputGeneratePrediction.getPredictionImage().getPath().getValue()
        bImageExists = os.path.exists(strImagePath)
        EDAssert.strAlmostEqual(True, bImageExists, "(Test if the image with prediction exists)")
 def testExecute(self):
     """
     """
     self.run()
     plugin = self.getPlugin()
     strExpectedOutput = self.readAndParseFile (self.getReferenceDataOutputFile())
     EDVerbose.DEBUG("Checking obtained result...")
     xsDataResultReference = XSDataResultShiftImage.parseString(strExpectedOutput)
     xsDataResultObtained = plugin.getDataOutput()
     EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), _fRelError=0.0, _fAbsError=0.3, _strComment="XML out are the same")
示例#21
0
    def testExecute(self):
        self.run()

        plugin = self.getPlugin()
        output = plugin.dataOutput
        reference = XSDataResCutoffResult.parseFile(
            self.getReferenceDataOutputFile())

        EDAssert.strAlmostEqual(output.marshal(), reference.marshal(),
                                "output looks good")
示例#22
0
 def testExecute(self):
     """  
     """
     self.run()
     xsdOut = self.getPlugin().getDataOutput()
     EDAssert.strAlmostEqual(XSDataResultDataver.parseString(self.readAndParseFile(self.getReferenceDataOutputFile())).marshal(),
                             xsdOut.marshal() , "XSData are almost the same", _fAbsError=0.1)
     refData = open(os.path.join(self.getTestsDataImagesHome(), "merged.dat")).read().replace("\n", " ")
     obtData = open(self.destFile).read().replace(os.linesep, " ")
     EDAssert.strAlmostEqual(refData, obtData, "Checking obtained file", _fRelError=0.1)
    def testExecute(self):
        self.run()

        plugin = self.getPlugin()
        output = plugin.dataOutput
        reference = XSDataResCutoffResult.parseFile(self.getReferenceDataOutputFile())

        EDAssert.strAlmostEqual(output.marshal(),
                                reference.marshal(),
                                "output looks good")
    def testExecute(self):
        """
        """
        self.run()
        xsdout = self.getPlugin().getDataOutput().marshal()
        print self.getReferenceDataOutputFile()
        xsdRef = XSDataResultStitchOffsetedImage.parseString(self.readAndParseFile(self.getReferenceDataOutputFile())).marshal()
        EDAssert.strAlmostEqual(xsdRef, xsdout, "Xsd are the same")
#        fabio.edfimage.edfimage(data=fabio.open(self.outFile).data - fabio.open(self.refFile).data).write("/tmp/delta.edf")
        EDAssert.arraySimilar(fabio.open(self.outFile).data, fabio.open(self.refFile).data, "Arrays are the same", _fAbsMaxDelta=1)
 def testExecute(self):
     """  
     """
     self.run()
     xsdOut = self.getPlugin().getDataOutput()
     EDAssert.strAlmostEqual(XSDataResultDataver.parseString(self.readAndParseFile(self.getReferenceDataOutputFile())).marshal(),
                             xsdOut.marshal() , "XSData are almost the same", _fAbsError=0.1)
     refData = open(os.path.join(self.getTestsDataImagesHome(), "merged.dat")).read().replace("\n", " ")
     obtData = open(self.destFile).read().replace(os.linesep, " ")
     EDAssert.strAlmostEqual(refData, obtData, "Checking obtained file", _fRelError=0.1)
    def testExecute(self):
        """
        """
        self.run()
        xsdOut = self.getPlugin().getDataOutput()
        EDAssert.strAlmostEqual(XSDataResultDatop.parseString(self.readAndParseFile(self.getReferenceDataOutputFile())).marshal(),
                                xsdOut.marshal() , "XSData are almost the same", _fAbsError=0.1)
        refData = open(os.path.join(self.getTestsDataImagesHome(), "noise1+2.dat")).read()
        obtData = os.linesep.join([i for i in open(self.destFile) if i[0].isspace()])

        EDAssert.strAlmostEqual(refData, obtData, "Checking obtained file")
示例#27
0
 def unitTestArraytoXsdNoNumpy(self):
     """
     test the execution of detectNumberOfCPUs
     """
     EDVerbose.DEBUG("EDTestCaseEDUtilsArray.unitTestArraytoXsdNoNumpy")
     EDAssert.strAlmostEqual(XSDataArray.parseString(self.strXSDataArrayNoNumpy).marshal(),
                             EDUtilsArray.arrayToXSData(self.arrayNumpy, _bForceNoNumpy=True).marshal(),
                             _strComment="XSDataArray from (numpyArray) are the same (forced No Numpy)")
     EDAssert.strAlmostEqual(XSDataArray.parseString(self.strXSDataArrayNoNumpy).marshal(),
                             EDUtilsArray.arrayToXSData(self.arrayNoNumpy, _bForceNoNumpy=True).marshal(),
                             _strComment="XSDataArray from (list of lists) are the same (forced No Numpy)")
示例#28
0
 def testExecute(self):
     """
     """
     self.run()
     plugin = self.getPlugin()
     xsdRef = XSDataResultBioSaxsSmartMergev1_0.parseString(self.readAndParseFile(self.getReferenceDataOutputFile()))
     xsdObt = plugin.getDataOutput()
     xsdObt.status = None #Executive summary is too complicated to test
     EDAssert.strAlmostEqual(xsdRef.marshal(), xsdObt.marshal(), "XML output structures are the same", _fAbsError=0.1)
     ref = " ".join([" ".join(i.split()) for i in open(self.destFile)])
     obt = " ".join([" ".join(i.split()) for i in open(xsdObt.mergedCurve.path.value)])
     EDAssert.strAlmostEqual(ref, obt, "Files are the same", _fAbsError=0.1)
示例#29
0
    def testExecute(self):
        """
        """
        self.run()

        plugin = self.getPlugin()

        strExpectedOutput = self.readAndParseFile (self.getReferenceDataOutputFile())
        EDVerbose.DEBUG("Checking obtained result...")
        xsDataResultReference = XSDataResultMeasureOffset.parseString(strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()
        EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), _fRelError=0.0, _fAbsError=5, _strComment="XML out are the same")
    def testExecute(self):
        self.run()
        plugin = self.getPlugin()
        plugin.synchronize()
        xmlobtain = plugin.getDataOutput().marshal()
        xmlexpected = XSDataResultID11.parseString(self.readAndParseFile(self.getReferenceDataOutputFile())).marshal()
        EDAssert.strAlmostEqual(xmlexpected, xmlobtain, "XSData comparaison")
        #EDPluginSPDCakev1_5.killAllWorkers()
        outputData = open(plugin.getDataOutput().getOutputFile()[0].getPath().getValue(), "rb").read()
        referenceData = open(os.path.join(self.getTestsDataImagesHome(), "moke.spr"), "rb").read()

        EDAssert.strAlmostEqual(referenceData, outputData, " file are the same")
 def testExecute(self):
     """
     """
     self.run()
     plugin = self.getPlugin()
     xsdRef = XSDataResultBioSaxsSmartMergev1_0.parseString(self.readAndParseFile(self.getReferenceDataOutputFile()))
     xsdObt = plugin.getDataOutput()
     xsdObt.status = None #Executive summary is too complicated to test
     EDAssert.strAlmostEqual(xsdRef.marshal(), xsdObt.marshal(), "XML output structures are the same", _fAbsError=0.1)
     ref = " ".join([" ".join(i.split()) for i in open(self.destFile)])
     obt = " ".join([" ".join(i.split()) for i in open(xsdObt.mergedCurve.path.value)])
     EDAssert.strAlmostEqual(ref, obt, "Files are the same", _fAbsError=0.1)
    def testExecute(self):
        """
        """
        self.run()
        plugin = self.getPlugin()
################################################################################
# Compare XSDataResults
################################################################################
        strExpectedOutput = self.readAndParseFile (self.getReferenceDataOutputFile())
        EDVerbose.DEBUG("Checking obtained result...")
        xsDataResultReference = XSDataResultWriteMatrix.parseString(strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()
        EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), "XSDataResult output are the same")
示例#33
0
 def unitTestArraytoXsd(self):
     """
     test the execution of xsDataToArray static method
     """
     EDVerbose.DEBUG("EDTestCaseEDUtilsArray.unitTestArraytoXsd")
     if numpy is not None:
         EDAssert.strAlmostEqual(XSDataArray.parseString(self.strXSDataArrayNumpy).marshal(),
                                 EDUtilsArray.arrayToXSData(self.arrayNumpy).marshal(),
                                 _strComment="XSDataArray from (numpyArray) are the same")
     else:
         EDAssert.strAlmostEqual(XSDataArray.parseString(self.strXSDataArrayNoNumpy).marshal(),
                                 EDUtilsArray.arrayToXSData(self.arrayNumpy).marshal(),
                                 _strComment="XSDataArray from (Non numpy Array) are the same")
    def testExecute(self):
        """
        """
        self.run()

        # Checks that there are no error messages

        plugin = self.getPlugin()

        edStringExpectedOutput = self.readAndParseFile (self.getReferenceDataOutputFile())
        edStringObtainedOutput = self.readAndParseFile (self.m_edObtainedOutputDataFile)
        EDVerbose.DEBUG("Checking obtained result...")
        xsDataResultReference = XSDataResultExecVideo.parseString(edStringExpectedOutput)
        xsDataResultObtained = XSDataResultExecVideo.parseString(edStringObtainedOutput)

        EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), "XSDataResult output are the same")

################################################################################
# Identification of the video by its size
################################################################################

        edStringExpectedOutput = self.readAndParseFile (self.getReferenceDataOutputFile())
        xsDataResultReference = XSDataResultExecVideo.parseString(edStringExpectedOutput)
        outputFileName = xsDataResultReference.getVideoPath().getPath().getValue()
        outputVideoSize = os.stat(outputFileName)[6]


        referenceFileName = os.path.join(self.getPluginTestsDataHome(), os.path.basename(outputFileName))
        referenceVideoSize = os.stat(referenceFileName)[6]

        EDAssert.equal(outputVideoSize, referenceVideoSize, "Identification of the video file by its size")
################################################################################
# Identification of the video by mplayer
################################################################################
        outputVideoLog = subprocess.Popen("mplayer  -identify -vo null -ao null -frames 0 2>/dev/null " + outputFileName, stdout=subprocess.PIPE, shell=True).stdout.readlines()
        outputVideoSummary = ""

        for oneLine in outputVideoLog:
            if oneLine.strip() != "":
                if not oneLine.split()[0].split("=")[0] in self.EXCLUDED:
                    outputVideoSummary += oneLine

        referenceVideoLog = subprocess.Popen("mplayer  -identify -vo null -ao null -frames 0 2>/dev/null " + referenceFileName, stdout=subprocess.PIPE, shell=True).stdout.readlines()
        referenceVideoSummary = ""
        for oneLine in referenceVideoLog:
            if oneLine.strip() != "":
                if not oneLine.split()[0].split("=")[0] in self.EXCLUDED:
                    referenceVideoSummary += oneLine

        EDAssert.strAlmostEqual(outputVideoSummary, referenceVideoSummary, "Identification of the video by mplayer", _lstExcluded="edna")
示例#35
0
    def testExecute(self):
        self.run()

        # Checks the expected result
        strObtainedOutput = self.readAndParseFile(
            self.m_edObtainedOutputDataFile)
        from XSDataMOSFLMv10 import XSDataMOSFLMOutputGeneratePrediction
        xsDataMOSFLMOutputGeneratePrediction = XSDataMOSFLMOutputGeneratePrediction.parseString(
            strObtainedOutput)
        strImagePath = xsDataMOSFLMOutputGeneratePrediction.getPredictionImage(
        ).getPath().getValue()
        bImageExists = os.path.exists(strImagePath)
        EDAssert.strAlmostEqual(True, bImageExists,
                                "(Test if the image with prediction exists)")
    def testExecute(self):
        """
        """
        self.run()
        plugin = self.getPlugin()

        # Checking obtained results
        xsDataResult = plugin.getDataOutput()
        EDAssert.strAlmostEqual(XSDataResult1DPowderEDF.parseString(self.readAndParseFile(self.getReferenceDataOutputFile())).marshal(), xsDataResult.marshal(), _strComment="XML structures are the same")

        outputData = open(xsDataResult.getOutputFile().getPath().getValue(), "rb").read()
        referenceData = open(os.path.join(self.getTestsDataImagesHome(), self.refOutput), "rb").read()

        EDAssert.strAlmostEqual(referenceData, outputData, "ChiPlot files are the same")
示例#37
0
    def testExecute(self):
        """
        """
        self.run()
        plugin = self.getPlugin()

################################################################################
# Compare XSDataResults
################################################################################

        strExpectedOutput = self.readAndParseFile(self.getReferenceDataOutputFile())
        EDVerbose.DEBUG("Checking obtained result...")
        xsDataResultReference = XSDataResult.parseString(strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()
        EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), "XSDataResult output are the same", _strExcluded="bioSaxs")
 def testExecute(self):
     self.run()
     # Compare results
     strXMLExpected = self.readAndParseFile(
         self.__strReferenceDataOutputFile)
     xsDataObtained = self.getPlugin().getDataOutput()
     xsDataExpected = XSDataMOSFLMOutputIntegration.parseString(
         strXMLExpected)
     # Remove the bestFileHKL part which creates problem...
     xsDataObtained.setBestfileHKL(None)
     xsDataExpected.setBestfileHKL(None)
     EDAssert.strAlmostEqual(
         xsDataExpected.marshal(), xsDataObtained.marshal(),
         "(MOSFLM integration result comparison - expected versus obtained)",
         0.1, 5000)
 def testExecute(self):
     """
     """
     self.run()
     xsdout = self.getPlugin().getDataOutput().marshal()
     print self.getReferenceDataOutputFile()
     xsdRef = XSDataResultStitchOffsetedImage.parseString(
         self.readAndParseFile(
             self.getReferenceDataOutputFile())).marshal()
     EDAssert.strAlmostEqual(xsdRef, xsdout, "Xsd are the same")
     #        fabio.edfimage.edfimage(data=fabio.open(self.outFile).data - fabio.open(self.refFile).data).write("/tmp/delta.edf")
     EDAssert.arraySimilar(fabio.open(self.outFile).data,
                           fabio.open(self.refFile).data,
                           "Arrays are the same",
                           _fAbsMaxDelta=1)
    def testExecute(self):
        """
        """
        self.run()
        plugin = self.getPlugin()
        strExpectedOutput = self.readAndParseFile (self.getReferenceDataOutputFile())

        EDVerbose.DEBUG("Checking obtained result...")
        xsDataResultReference = XSDataResultSaxsAddMetadatav1_0.parseString(strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()
        EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), "XSDataResult output are the same")


        outputData = str(open(self.testOutput, "rb").read()[:8196])
        referenceData = str(open(self.refOutput, "rb").read()[:8196])
        EDAssert.strAlmostEqual(outputData, referenceData, "Same headers")
    def testExecute(self):
        self.run()

        plugin = self.getPlugin()

        strExpectedOutput = self.readAndParseFile (self.getReferenceDataOutputFile())
#        strObtainedOutput = self.readAndParseFile (self.m_edObtainedOutputDataFile)
        EDVerbose.DEBUG("Checking obtained result...")
        xsDataResultReference = XSDataResultSaxsAddv1_0.parseString(strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()
        EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), "XSDataResult output are the same")


        outputData = openimage(xsDataResultObtained.getOutputImage().getPath().getValue()).data
        referenceData = openimage(os.path.join(self.getTestsDataImagesHome(), "bsa_014_07.msk")).data
        EDAssert.arraySimilar(outputData, referenceData , _fAbsMaxDelta=0.8, _fScaledMaxDelta=0.05, _fRfactor=5, _fRelMaxDelta=1.5 , _strComment="Images are the same")
    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()

        strExpectedOutput = self.readAndParseFile(
            self.getReferenceDataOutputFile())
        #        strObtainedOutput = self.readAndParseFile (self.m_edObtainedOutputDataFile)
        EDVerbose.DEBUG("Checking obtained result...")
        xsDataResultReference = XSDataResultPyFAI.parseString(
            strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()
        EDAssert.strAlmostEqual(xsDataResultReference.marshal(),
                                xsDataResultObtained.marshal(),
                                "XSDataResult output are the same")
    def testExecute(self):
        """
        """
        self.run()
        plugin = self.getPlugin()

################################################################################
# Compare XSDataResults
################################################################################

        strExpectedOutput = self.readAndParseFile (self.getReferenceDataOutputFile())
        EDVerbose.DEBUG("Checking obtained result...")
        xsDataResultReference = XSDataResult.parseString(strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()
        EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), "XSDataResult output are the same", _strExcluded="bioSaxs")

        EDAssert.isFile(xsDataResultObtained.gnom.gnomFile.path.value, "Gnom file exists")
    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 = XSDataResultBioSaxsMetadatav1_0.parseString(strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()
        EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), "XSDataResult output are the same", _strExcluded="bioSaxs")

################################################################################
# Compare dictionary: 
################################################################################
        edfRef = EdfFile.EdfFile(xsDataResultObtained.getOutputImage().getPath().value)
        edfObt = EdfFile.EdfFile(os.path.join(self.getTestsDataImagesHome(), "bioSaxsMetadata.edf"))
        ########################################################################
        # DEPRECATED PLUGIN => DEPREFCATED TESTS
        ########################################################################
#        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", "Center_1", "Center_2", "Code", "Comments", "Concentration",
#                    "VersionNumber",'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 dictionary")
#        for key in keysRef:
#            EDAssert.strAlmostEqual(headerRef[key], headerObt[key], _strComment="header value %s are the same" % key, _strExcluded="bioSaxs")


################################################################################
# Compare images 
################################################################################

        outputData = edfObt.GetData(0)
        referenceData = edfRef.GetData(0)
        EDAssert.arraySimilar(outputData, referenceData , _fAbsMaxDelta=0.1, _fScaledMaxDelta=0.05, _strComment="Images-data are the same")
    def testExecute(self):
        """
        """
        self.run()
        plugin = self.getPlugin()

        #        # Checking obtained results
        xsDataResultsSPDCake = plugin.getDataOutput()
        pathToOutput = xsDataResultsSPDCake.getCakedFile().getPath().getValue()
        #        edStringDataObtained = EDUtilsFile.readFile(pathToOutput)
        #        edStringDataReference = EDUtilsFile.readFile(os.path.join(self.getPluginTestsDataHome(), \
        #                                                                             "EDPluginSPDCakev1_1.chi"))
        #        EDAssert.strAlmostEqual(edStringDataReference, edStringDataObtained, "Comparing ChiPlot files")
        EDVerbose.DEBUG("Checking obtained result...")
        strExpectedOutput = self.readAndParseFile(
            self.getReferenceDataOutputFile())
        xsDataResultReference = XSDataResultSPDCake.parseString(
            strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()
        EDAssert.strAlmostEqual(xsDataResultReference.marshal(),
                                xsDataResultObtained.marshal(),
                                "XSDataResult output are the same")

        # Checking obtained results
        xsDataResultsSPDCake = plugin.getDataOutput()
        strPathToChiOutput = xsDataResultsSPDCake.getCakedFile().getPath(
        ).getValue()
        strPathToChiReference = os.path.join(self.getTestsDataImagesHome(),
                                             "EDPluginSPDCakev1_1.chi")
        Xref, Yref = readChiPlot(strPathToChiReference)
        Xobt, Yobt = readChiPlot(strPathToChiOutput)
        EDVerbose.DEBUG("Output File: %s, Reference file: %s" %
                        (strPathToChiOutput, strPathToChiReference))
        bigX = Xref + Xobt
        bigX.sort()
        bigYobt = numpy.interp(bigX, Xobt, Yobt)
        bigYref = numpy.interp(bigX, Xref, Yref)
        EDVerbose.DEBUG("ref.shape= %s, obt.shape=%s" %
                        (bigYobt.shape, bigYref.shape))
        EDVerbose.DEBUG("Type of object ref= %s, obt=%s" %
                        (bigYobt.__class__, bigYref.__class__))
        EDAssert.arraySimilar(bigYobt,
                              bigYref,
                              _fAbsMaxDelta=0.1,
                              _fScaledMaxDelta=0.1,
                              _strComment="Comparing ChiPlot files")
    def testExecute(self):
        """
        """
        plugin = self.getPlugin()
        plugin.__class__.lastBuffer = XSDataFile(XSDataString(os.path.join(EDUtilsPath.EDNA_TESTIMAGES, "buffer_before.dat")))
        plugin.__class__.lastSample = XSDataFile(XSDataString(os.path.join(EDUtilsPath.EDNA_TESTIMAGES, "bioSaxsAveraged.dat")))
        self.run()
        plugin = self.getPlugin()
        xsdRef = XSDataResultBioSaxsSmartMergev1_0.parseString(self.readAndParseFile(self.getReferenceDataOutputFile()))
        xsdRef.autoRg = None
        xsdObt = plugin.getDataOutput()
        xsdObt.status = None #Executive summary is too complicated to test
        EDAssert.strAlmostEqual(xsdRef.marshal(), xsdObt.marshal(), "XML output structures are the same", _fAbsError=0.1)
#        ref = " ".join([" ".join(i.split()) for i in open(self.destFile)])
#        obt = " ".join([" ".join(i.split()) for i in open(xsdObt.mergedCurve.path.value)])
#        EDAssert.strAlmostEqual(ref, obt, "Files are the same", _fAbsError=0.1)
        print plugin.__class__.lastBuffer.path.value
        print plugin.__class__.lastSample.path.value
示例#48
0
    def testExecute(self):
        """
        """
        self.run()
        xsdOut = self.getPlugin().getDataOutput()
        EDAssert.strAlmostEqual(XSDataResultDatop.parseString(
            self.readAndParseFile(
                self.getReferenceDataOutputFile())).marshal(),
                                xsdOut.marshal(),
                                "XSData are almost the same",
                                _fAbsError=0.1)
        refData = open(
            os.path.join(self.getTestsDataImagesHome(),
                         "noise1+2.dat")).read()
        obtData = os.linesep.join(
            [i for i in open(self.destFile) if i[0].isspace()])

        EDAssert.strAlmostEqual(refData, obtData, "Checking obtained file")
    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 = XSDataResultBioSaxsAzimutIntv1_0.parseString(
            strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()
        EDAssert.strAlmostEqual(xsDataResultReference.marshal(),
                                xsDataResultObtained.marshal(),
                                "XSDataResult output are the same",
                                _strExcluded="bioSaxs")

        ################################################################################
        # Compare spectrum ascii Files
        ################################################################################

        outputData = open(
            xsDataResultObtained.getIntegratedCurve().getPath().value,
            "rb").read().split(os.linesep)
        referenceData = EDUtilsFile.readFileAndParseVariables(
            os.path.join(self.getTestsDataImagesHome(),
                         "bioSaxsIntegratedv1_3.dat"),
            EDUtilsPath.getDictOfPaths()).split(os.linesep)
        outputData = os.linesep.join(
            [i for i in outputData if not i.startswith("# History")])
        referenceData = os.linesep.join(
            [i for i in referenceData if not i.startswith("# History")])
        EDAssert.strAlmostEqual(
            referenceData,
            outputData,
            _strComment="3column ascii spectra files are the same",
            _fRelError=0.1,
            _fAbsError=0.1,
            _strExcluded="bioSaxs")
示例#50
0
    def testExecute(self):
        """
        """
        self.run()

        plugin = self.getPlugin()
        ################################################################################
        # Compare XSDataResults
        ################################################################################
        strExpectedOutput = self.readAndParseFile(
            self.getReferenceDataOutputFile())
        EDVerbose.DEBUG("Checking obtained result...")
        xsDataResultReference = XSDataResultMatrixInvertv2.parseString(
            strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()
        EDAssert.strAlmostEqual(xsDataResultReference.marshal(),
                                xsDataResultObtained.marshal(),
                                _fStrSimilar=0.99,
                                _strComment="XSDataResult output are the same")
示例#51
0
    def testExecute(self):
        """
        """
        self.run()
        plugin = self.getPlugin()
        strExpectedOutput = self.readAndParseFile(
            self.getReferenceDataOutputFile())

        EDVerbose.DEBUG("Checking obtained result...")
        xsDataResultReference = XSDataResultSaxsAddMetadatav1_0.parseString(
            strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()
        EDAssert.strAlmostEqual(xsDataResultReference.marshal(),
                                xsDataResultObtained.marshal(),
                                "XSDataResult output are the same")

        outputData = str(open(self.testOutput, "rb").read()[:8196])
        referenceData = str(open(self.refOutput, "rb").read()[:8196])
        EDAssert.strAlmostEqual(outputData, referenceData, "Same headers")
    def testExecute(self):
        self.run()
        plugin = self.getPlugin()
        plugin.synchronize()
        xmlobtain = plugin.getDataOutput().marshal()
        xmlexpected = XSDataResultID11.parseString(
            self.readAndParseFile(
                self.getReferenceDataOutputFile())).marshal()
        EDAssert.strAlmostEqual(xmlexpected, xmlobtain, "XSData comparaison")
        #EDPluginSPDCakev1_5.killAllWorkers()
        outputData = open(
            plugin.getDataOutput().getOutputFile()[0].getPath().getValue(),
            "rb").read()
        referenceData = open(
            os.path.join(self.getTestsDataImagesHome(), "moke.spr"),
            "rb").read()

        EDAssert.strAlmostEqual(referenceData, outputData,
                                " file are the same")
    def testExecute(self):
        """
        """
        self.run()


        plugin = self.getPlugin()

        strExpectedOutput = self.readAndParseFile (self.getReferenceDataOutputFile())
#        strObtainedOutput = self.readAndParseFile (self.m_edObtainedOutputDataFile)
        EDVerbose.DEBUG("Checking obtained result...")
        xsDataResultReference = XSDataResultSaxsAnglev1_0.parseString(strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()
        EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), "XSDataResult output are the same")


        outputData = openimage(xsDataResultObtained.getRegroupedDataFile().getPath().getValue()).data
        referenceData = openimage(os.path.join(self.getTestsDataImagesHome(), "Moke-2th10-tilt0-rot0.azim")).data
        EDAssert.arraySimilar(outputData, referenceData , _fAbsMaxDelta=0.4, _fScaledMaxDelta=0.5, _strComment="Images 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 = XSDataResultBioSaxsMetadatav1_0.parseString(strExpectedOutput)
        xsDataResultObtained = plugin.getDataOutput()
        EDAssert.strAlmostEqual(xsDataResultReference.marshal(), xsDataResultObtained.marshal(), "XSDataResult output are the same", _strExcluded="bioSaxs")

################################################################################
# Compare dictionary
################################################################################
        edfRef = fabio.open(xsDataResultObtained.getOutputImage().getPath().value)
        edfObt = fabio.open(os.path.join(self.getTestsDataImagesHome(), "bioSaxsMetadata.edf"))
        keysRef = edfRef.header_keys
        keysObt = edfObt.header_keys
        keysRef.sort()
        keysObt.sort()

        for key in ["HeaderID", "Image", 'EDF_BinarySize', "EDF_DataBlockID", "EDF_HeaderSize", "filename", "RasterOrientation" ]:
            if key in keysObt: keysObt.remove(key)
            if key in keysRef: keysRef.remove(key)
#        print edfObt.header
        EDAssert.equal(keysRef, keysObt, _strComment="Same keys in the header dictionary")
        for key in keysRef:
            EDAssert.strAlmostEqual(edfRef.header[key], edfObt.header[key], _strComment="header value %s are the same" % key, _strExcluded="bioSaxs")


################################################################################
# Compare images 
################################################################################

        outputData = edfObt.data
        referenceData = edfRef.data
        EDAssert.arraySimilar(outputData, referenceData , _fAbsMaxDelta=0.1, _fScaledMaxDelta=0.05, _strComment="Images-data are the same")