def __init__(self):
        """
        """
        EDPluginControl.__init__(self)
        self.setXSDataInputClass(XSDataInputMatrixInvertFile)
        self.__strControlledPluginReader = "EDPluginExecMatrixReadv1_0"
        self.__strControlledPluginInverter = "EDPluginExecMatrixInvertv1_0"
        self.__strControlledPluginWriter = "EDPluginExecMatrixWritev1_0"
        self.__edPluginExecRead = None
        self.__edPluginExecInvert = None
        self.__edPluginExecWrite = None

        self.xsDataResult = XSDataResultMatrixInvertFile()
Exemple #2
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 __init__(self):
        """
        """
        EDPluginControl.__init__(self)
        self.setXSDataInputClass(XSDataInputMatrixInvertFile)
        self.__strControlledPluginReader = "EDPluginExecMatrixReadv1_0"
        self.__strControlledPluginInverter = "EDPluginExecMatrixInvertv1_0"
        self.__strControlledPluginWriter = "EDPluginExecMatrixWritev1_0"
        self.__edPluginExecRead = None
        self.__edPluginExecInvert = None
        self.__edPluginExecWrite = None

        self.xsDataResult = XSDataResultMatrixInvertFile()
Exemple #4
0
    def preProcess(self):
        """
        PreProcess of the execution test: download a set of images  from http://www.edna-site.org
        and delete any output file
        """
        EDTestCasePluginExecute.preProcess(self)

        xsDataInput = XSDataInputMatrixInvertFile.parseString(self.readAndParseFile(self.getDataInputFile()))
        self.inputFile = xsDataInput.getInputMatrixFile().getPath().getValue()

        self.xsDataResultReference = XSDataResultMatrixInvertFile.parseString(self.readAndParseFile(self.getReferenceDataOutputFile()))
        self.outputFile = self.xsDataResultReference.getOutputMatrixFile().getPath().getValue()

        self.loadTestImage([os.path.basename(self.inputFile), os.path.basename(self.outputFile) ])

        if not os.path.isdir(os.path.dirname(self.outputFile)):
            os.makedirs(os.path.dirname(self.outputFile))
        if os.path.isfile(self.outputFile):
            EDVerbose.DEBUG(" Output file exists %s, I will remove it" % self.outputFile)
            os.remove(self.outputFile)
    def preProcess(self):
        """
        PreProcess of the execution test: download a set of images  from http://www.edna-site.org
        and delete any output file
        """
        EDTestCasePluginExecute.preProcess(self)

        xsDataInput = XSDataInputMatrixInvertFile.parseString(self.readAndParseFile(self.getDataInputFile()))
        self.inputFile = xsDataInput.getInputMatrixFile().getPath().getValue()

        self.xsDataResultReference = XSDataResultMatrixInvertFile.parseString(
            self.readAndParseFile(self.getReferenceDataOutputFile())
        )
        self.outputFile = self.xsDataResultReference.getOutputMatrixFile().getPath().getValue()

        self.loadTestImage([os.path.basename(self.inputFile), os.path.basename(self.outputFile)])

        if not os.path.isdir(os.path.dirname(self.outputFile)):
            os.makedirs(os.path.dirname(self.outputFile))
        if os.path.isfile(self.outputFile):
            EDVerbose.DEBUG(" Output file exists %s, I will remove it" % self.outputFile)
            os.remove(self.outputFile)
    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")
class EDPluginControlMatrixInvertFilev1_0(EDPluginControl):
    """
    [To be replaced with a description of EDPluginControlTemplatev10]
    """

    def __init__(self):
        """
        """
        EDPluginControl.__init__(self)
        self.setXSDataInputClass(XSDataInputMatrixInvertFile)
        self.__strControlledPluginReader = "EDPluginExecMatrixReadv1_0"
        self.__strControlledPluginInverter = "EDPluginExecMatrixInvertv1_0"
        self.__strControlledPluginWriter = "EDPluginExecMatrixWritev1_0"
        self.__edPluginExecRead = None
        self.__edPluginExecInvert = None
        self.__edPluginExecWrite = None

        self.xsDataResult = XSDataResultMatrixInvertFile()

    def checkParameters(self):
        """
        Checks the mandatory parameters.
        """
        EDVerbose.DEBUG("EDPluginControlMatrixInvertFilev1_0.checkParameters")
        self.checkMandatoryParameters(self.getDataInput(), "Data Input is None")
        self.checkMandatoryParameters(self.getDataInput().getInputMatrixFile(), "No Input File")
        self.checkMandatoryParameters(self.getDataInput().getOutputMatrixFile(), "No Output file")

    def preProcess(self, _edObject=None):
        EDPluginControl.preProcess(self)
        EDVerbose.DEBUG("EDPluginControlMatrixInvertFilev1_0.preProcess")
        # Load the execution plugin
        self.__edPluginExecRead = self.loadPlugin(self.__strControlledPluginReader)
        self.__edPluginExecInvert = self.loadPlugin(self.__strControlledPluginInverter)
        self.__edPluginExecWrite = self.loadPlugin(self.__strControlledPluginWriter)

    def process(self, _edObject=None):
        EDPluginControl.process(self)
        EDVerbose.DEBUG("EDPluginControlMatrixInvertFilev1_0.process")
        xsdin = XSDataInputReadMatrix()
        xsdin.setInputMatrixFile(self.getDataInput().getInputMatrixFile())
        self.__edPluginExecRead.setDataInput(xsdin)
        self.__edPluginExecRead.connectSUCCESS(self.doSuccessExecRead)
        self.__edPluginExecRead.connectFAILURE(self.doFailureExecRead)
        self.__edPluginExecRead.executeSynchronous()

    def postProcess(self, _edObject=None):
        EDPluginControl.postProcess(self)
        EDVerbose.DEBUG("EDPluginControlMatrixInvertFilev1_0.postProcess")
        # Create some output data
        self.setDataOutput(self.xsDataResult)

    def doSuccessExecRead(self, _edPlugin=None):
        EDVerbose.DEBUG("EDPluginControlMatrixInvertFilev1_0.doSuccessExecRead")
        self.retrieveSuccessMessages(_edPlugin, "EDPluginControlMatrixInvertFilev1_0.doSuccessExecRead")
        xsdmat = _edPlugin.getDataOutput().getOutputMatrix()
        xsdin = XSDataInputMatrixInvert()
        xsdin.setInputMatrix(xsdmat)
        self.__edPluginExecInvert.setDataInput(xsdin)
        self.__edPluginExecInvert.connectSUCCESS(self.doSuccessExecInvert)
        self.__edPluginExecInvert.connectFAILURE(self.doFailureExecInvert)
        self.__edPluginExecInvert.executeSynchronous()

    def doFailureExecRead(self, _edPlugin=None):
        EDVerbose.DEBUG("EDPluginControlMatrixInvertFilev1_0.doFailureExecRead")
        self.retrieveFailureMessages(_edPlugin, "EDPluginControlMatrixInvertFilev1_0.doFailureExecRead")

    def doSuccessExecInvert(self, _edPlugin=None):
        EDVerbose.DEBUG("EDPluginControlMatrixInvertFilev1_0.doSuccessExecInvert")
        self.retrieveSuccessMessages(_edPlugin, "EDPluginControlMatrixInvertFilev1_0.doSuccessExecInvert")
        xsdmat = _edPlugin.getDataOutput().getOutputMatrix()
        xsdin = XSDataInputWriteMatrix()
        xsdin.setInputMatrix(xsdmat)
        xsdin.setOutputMatrixFile(self.getDataInput().getOutputMatrixFile())
        self.__edPluginExecWrite.setDataInput(xsdin)
        self.__edPluginExecWrite.connectSUCCESS(self.doSuccessExecWrite)
        self.__edPluginExecWrite.connectFAILURE(self.doFailureExecWrite)
        self.__edPluginExecWrite.executeSynchronous()

    def doFailureExecInvert(self, _edPlugin=None):
        EDVerbose.DEBUG("EDPluginControlMatrixInvertFilev1_0.doFailureExecInvert")
        self.retrieveFailureMessages(_edPlugin, "EDPluginControlMatrixInvertFilev1_0.doFailureExecInvert")

    def doSuccessExecWrite(self, _edPlugin=None):
        EDVerbose.DEBUG("EDPluginControlMatrixInvertFilev1_0.doSuccessExecWrite")
        self.retrieveSuccessMessages(_edPlugin, "EDPluginControlMatrixInvertFilev1_0.doSuccessExecWrite")
        xsdout = _edPlugin.getDataOutput().getOutputMatrixFile()
        self.xsDataResult.setOutputMatrixFile(xsdout)

    def doFailureExecWrite(self, _edPlugin=None):
        EDVerbose.DEBUG("EDPluginControlMatrixInvertFilev1_0.doFailureExecWrite")
        self.retrieveFailureMessages(_edPlugin, "EDPluginControlMatrixInvertFilev1_0.doFailureExecWrite")
class EDPluginControlMatrixInvertFilev1_0(EDPluginControl):
    """
    [To be replaced with a description of EDPluginControlTemplatev10]
    """
    def __init__(self):
        """
        """
        EDPluginControl.__init__(self)
        self.setXSDataInputClass(XSDataInputMatrixInvertFile)
        self.__strControlledPluginReader = "EDPluginExecMatrixReadv1_0"
        self.__strControlledPluginInverter = "EDPluginExecMatrixInvertv1_0"
        self.__strControlledPluginWriter = "EDPluginExecMatrixWritev1_0"
        self.__edPluginExecRead = None
        self.__edPluginExecInvert = None
        self.__edPluginExecWrite = None

        self.xsDataResult = XSDataResultMatrixInvertFile()

    def checkParameters(self):
        """
        Checks the mandatory parameters.
        """
        EDVerbose.DEBUG("EDPluginControlMatrixInvertFilev1_0.checkParameters")
        self.checkMandatoryParameters(self.getDataInput(),
                                      "Data Input is None")
        self.checkMandatoryParameters(self.getDataInput().getInputMatrixFile(),
                                      "No Input File")
        self.checkMandatoryParameters(
            self.getDataInput().getOutputMatrixFile(), "No Output file")

    def preProcess(self, _edObject=None):
        EDPluginControl.preProcess(self)
        EDVerbose.DEBUG("EDPluginControlMatrixInvertFilev1_0.preProcess")
        # Load the execution plugin
        self.__edPluginExecRead = self.loadPlugin(
            self.__strControlledPluginReader)
        self.__edPluginExecInvert = self.loadPlugin(
            self.__strControlledPluginInverter)
        self.__edPluginExecWrite = self.loadPlugin(
            self.__strControlledPluginWriter)

    def process(self, _edObject=None):
        EDPluginControl.process(self)
        EDVerbose.DEBUG("EDPluginControlMatrixInvertFilev1_0.process")
        xsdin = XSDataInputReadMatrix()
        xsdin.setInputMatrixFile(self.getDataInput().getInputMatrixFile())
        self.__edPluginExecRead.setDataInput(xsdin)
        self.__edPluginExecRead.connectSUCCESS(self.doSuccessExecRead)
        self.__edPluginExecRead.connectFAILURE(self.doFailureExecRead)
        self.__edPluginExecRead.executeSynchronous()

    def postProcess(self, _edObject=None):
        EDPluginControl.postProcess(self)
        EDVerbose.DEBUG("EDPluginControlMatrixInvertFilev1_0.postProcess")
        # Create some output data
        self.setDataOutput(self.xsDataResult)

    def doSuccessExecRead(self, _edPlugin=None):
        EDVerbose.DEBUG(
            "EDPluginControlMatrixInvertFilev1_0.doSuccessExecRead")
        self.retrieveSuccessMessages(
            _edPlugin, "EDPluginControlMatrixInvertFilev1_0.doSuccessExecRead")
        xsdmat = _edPlugin.getDataOutput().getOutputMatrix()
        xsdin = XSDataInputMatrixInvert()
        xsdin.setInputMatrix(xsdmat)
        self.__edPluginExecInvert.setDataInput(xsdin)
        self.__edPluginExecInvert.connectSUCCESS(self.doSuccessExecInvert)
        self.__edPluginExecInvert.connectFAILURE(self.doFailureExecInvert)
        self.__edPluginExecInvert.executeSynchronous()

    def doFailureExecRead(self, _edPlugin=None):
        EDVerbose.DEBUG(
            "EDPluginControlMatrixInvertFilev1_0.doFailureExecRead")
        self.retrieveFailureMessages(
            _edPlugin, "EDPluginControlMatrixInvertFilev1_0.doFailureExecRead")

    def doSuccessExecInvert(self, _edPlugin=None):
        EDVerbose.DEBUG(
            "EDPluginControlMatrixInvertFilev1_0.doSuccessExecInvert")
        self.retrieveSuccessMessages(
            _edPlugin,
            "EDPluginControlMatrixInvertFilev1_0.doSuccessExecInvert")
        xsdmat = _edPlugin.getDataOutput().getOutputMatrix()
        xsdin = XSDataInputWriteMatrix()
        xsdin.setInputMatrix(xsdmat)
        xsdin.setOutputMatrixFile(self.getDataInput().getOutputMatrixFile())
        self.__edPluginExecWrite.setDataInput(xsdin)
        self.__edPluginExecWrite.connectSUCCESS(self.doSuccessExecWrite)
        self.__edPluginExecWrite.connectFAILURE(self.doFailureExecWrite)
        self.__edPluginExecWrite.executeSynchronous()

    def doFailureExecInvert(self, _edPlugin=None):
        EDVerbose.DEBUG(
            "EDPluginControlMatrixInvertFilev1_0.doFailureExecInvert")
        self.retrieveFailureMessages(
            _edPlugin,
            "EDPluginControlMatrixInvertFilev1_0.doFailureExecInvert")

    def doSuccessExecWrite(self, _edPlugin=None):
        EDVerbose.DEBUG(
            "EDPluginControlMatrixInvertFilev1_0.doSuccessExecWrite")
        self.retrieveSuccessMessages(
            _edPlugin,
            "EDPluginControlMatrixInvertFilev1_0.doSuccessExecWrite")
        xsdout = _edPlugin.getDataOutput().getOutputMatrixFile()
        self.xsDataResult.setOutputMatrixFile(xsdout)

    def doFailureExecWrite(self, _edPlugin=None):
        EDVerbose.DEBUG(
            "EDPluginControlMatrixInvertFilev1_0.doFailureExecWrite")
        self.retrieveFailureMessages(
            _edPlugin,
            "EDPluginControlMatrixInvertFilev1_0.doFailureExecWrite")