From: Jean-Philippe ARGAUD Date: Fri, 17 Mar 2017 22:32:16 +0000 (+0100) Subject: Python 3 compatibility improvement X-Git-Tag: V8_3_0rc1~16 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a375ed08711d1c4338ecb9e0660b13be4c576e9e;p=modules%2Fadao.git Python 3 compatibility improvement --- diff --git a/src/daComposant/daAlgorithms/3DVAR.py b/src/daComposant/daAlgorithms/3DVAR.py index 7ddc1bb..adf9626 100644 --- a/src/daComposant/daAlgorithms/3DVAR.py +++ b/src/daComposant/daAlgorithms/3DVAR.py @@ -110,7 +110,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): self._pre_run(Parameters) # # Correction pour pallier a un bug de TNC sur le retour du Minimum - if self._parameters.has_key("Minimizer") == "TNC": + if "Minimizer" in self._parameters and self._parameters["Minimizer"] == "TNC": self.setParameterValue("StoreInternalVariables",True) # # Opérateurs @@ -118,9 +118,9 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): Hm = HO["Direct"].appliedTo Ha = HO["Adjoint"].appliedInXTo # - # Utilisation éventuelle d'un vecteur H(Xb) précalculé (sans cout) - # ---------------------------------------------------------------- - if HO["AppliedToX"] is not None and HO["AppliedToX"].has_key("HXb"): + # Utilisation éventuelle d'un vecteur H(Xb) précalculé + # ---------------------------------------------------- + if HO["AppliedToX"] is not None and "HXb" in HO["AppliedToX"]: HXb = Hm( Xb, HO["AppliedToX"]["HXb"]) else: HXb = Hm( Xb ) @@ -271,8 +271,8 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): # if "OMA" in self._parameters["StoreSupplementaryCalculations"] or \ "SigmaObs2" in self._parameters["StoreSupplementaryCalculations"] or \ - "SimulatedObservationAtOptimum" in self._parameters["StoreSupplementaryCalculations"] or \ - "SimulationQuantiles" in self._parameters["StoreSupplementaryCalculations"]: + "SimulationQuantiles" in self._parameters["StoreSupplementaryCalculations"] or \ + "SimulatedObservationAtOptimum" in self._parameters["StoreSupplementaryCalculations"]: if "SimulatedObservationAtCurrentState" in self._parameters["StoreSupplementaryCalculations"]: HXa = self.StoredVariables["SimulatedObservationAtCurrentState"][IndexMin] elif "SimulatedObservationAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"]: @@ -312,9 +312,9 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): # Calculs et/ou stockages supplémentaires # --------------------------------------- if "Innovation" in self._parameters["StoreSupplementaryCalculations"] or \ - "OMB" in self._parameters["StoreSupplementaryCalculations"] or \ "SigmaObs2" in self._parameters["StoreSupplementaryCalculations"] or \ - "MahalanobisConsistency" in self._parameters["StoreSupplementaryCalculations"]: + "MahalanobisConsistency" in self._parameters["StoreSupplementaryCalculations"] or \ + "OMB" in self._parameters["StoreSupplementaryCalculations"]: d = Y - HXb if "Innovation" in self._parameters["StoreSupplementaryCalculations"]: self.StoredVariables["Innovation"].store( numpy.ravel(d) ) diff --git a/src/daComposant/daAlgorithms/4DVAR.py b/src/daComposant/daAlgorithms/4DVAR.py index 344ee6c..48a015d 100644 --- a/src/daComposant/daAlgorithms/4DVAR.py +++ b/src/daComposant/daAlgorithms/4DVAR.py @@ -97,7 +97,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): self._pre_run(Parameters) # # Correction pour pallier a un bug de TNC sur le retour du Minimum - if self._parameters.has_key("Minimizer") == "TNC": + if "Minimizer" in self._parameters and self._parameters["Minimizer"] == "TNC": self.setParameterValue("StoreInternalVariables",True) # # Opérateurs @@ -106,7 +106,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): # Mm = EM["Direct"].appliedControledFormTo # - if CM is not None and CM.has_key("Tangent") and U is not None: + if CM is not None and "Tangent" in CM and U is not None: Cm = CM["Tangent"].asMatrix(Xb) else: Cm = None diff --git a/src/daComposant/daAlgorithms/ExtendedBlue.py b/src/daComposant/daAlgorithms/ExtendedBlue.py index 8f77514..4752f14 100644 --- a/src/daComposant/daAlgorithms/ExtendedBlue.py +++ b/src/daComposant/daAlgorithms/ExtendedBlue.py @@ -80,7 +80,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): # # Utilisation éventuelle d'un vecteur H(Xb) précalculé # ---------------------------------------------------- - if HO["AppliedToX"] is not None and HO["AppliedToX"].has_key("HXb"): + if HO["AppliedToX"] is not None and "HXb" in HO["AppliedToX"]: HXb = H( Xb, HO["AppliedToX"]["HXb"]) else: HXb = H( Xb ) diff --git a/src/daComposant/daAlgorithms/ExtendedKalmanFilter.py b/src/daComposant/daAlgorithms/ExtendedKalmanFilter.py index f15f183..0fbd0db 100644 --- a/src/daComposant/daAlgorithms/ExtendedKalmanFilter.py +++ b/src/daComposant/daAlgorithms/ExtendedKalmanFilter.py @@ -78,7 +78,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): if self._parameters["EstimationOf"] == "State": M = EM["Direct"].appliedControledFormTo # - if CM is not None and CM.has_key("Tangent") and U is not None: + if CM is not None and "Tangent" in CM and U is not None: Cm = CM["Tangent"].asMatrix(Xb) else: Cm = None diff --git a/src/daComposant/daAlgorithms/KalmanFilter.py b/src/daComposant/daAlgorithms/KalmanFilter.py index 6684c8b..e613ae2 100644 --- a/src/daComposant/daAlgorithms/KalmanFilter.py +++ b/src/daComposant/daAlgorithms/KalmanFilter.py @@ -69,7 +69,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): Mt = EM["Tangent"].asMatrix(Xb) Ma = EM["Adjoint"].asMatrix(Xb) # - if CM is not None and CM.has_key("Tangent") and U is not None: + if CM is not None and "Tangent" in CM and U is not None: Cm = CM["Tangent"].asMatrix(Xb) else: Cm = None diff --git a/src/daComposant/daAlgorithms/ParticleSwarmOptimization.py b/src/daComposant/daAlgorithms/ParticleSwarmOptimization.py index 7b7edd0..aaa289d 100644 --- a/src/daComposant/daAlgorithms/ParticleSwarmOptimization.py +++ b/src/daComposant/daAlgorithms/ParticleSwarmOptimization.py @@ -101,7 +101,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): def run(self, Xb=None, Y=None, U=None, HO=None, EM=None, CM=None, R=None, B=None, Q=None, Parameters=None): self._pre_run(Parameters) # - if self._parameters.has_key("BoxBounds") and (type(self._parameters["BoxBounds"]) is type([]) or type(self._parameters["BoxBounds"]) is type(())) and (len(self._parameters["BoxBounds"]) > 0): + if "BoxBounds" in self._parameters and (type(self._parameters["BoxBounds"]) is type([]) or type(self._parameters["BoxBounds"]) is type(())) and (len(self._parameters["BoxBounds"]) > 0): BoxBounds = self._parameters["BoxBounds"] logging.debug("%s Prise en compte des bornes d'incréments de paramètres effectuee"%(self._name,)) else: diff --git a/src/daComposant/daAlgorithms/QuantileRegression.py b/src/daComposant/daAlgorithms/QuantileRegression.py index d6c50c1..3d95d36 100644 --- a/src/daComposant/daAlgorithms/QuantileRegression.py +++ b/src/daComposant/daAlgorithms/QuantileRegression.py @@ -81,7 +81,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): # # Utilisation éventuelle d'un vecteur H(Xb) précalculé # ---------------------------------------------------- - if HO["AppliedToX"] is not None and HO["AppliedToX"].has_key("HXb"): + if HO["AppliedToX"] is not None and "HXb" in HO["AppliedToX"]: HXb = Hm( Xb, HO["AppliedToX"]["HXb"]) else: HXb = Hm( Xb ) diff --git a/src/daComposant/daAlgorithms/UnscentedKalmanFilter.py b/src/daComposant/daAlgorithms/UnscentedKalmanFilter.py index fdb6b4f..b084610 100644 --- a/src/daComposant/daAlgorithms/UnscentedKalmanFilter.py +++ b/src/daComposant/daAlgorithms/UnscentedKalmanFilter.py @@ -130,7 +130,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): if self._parameters["EstimationOf"] == "State": M = EM["Direct"].appliedControledFormTo # - if CM is not None and CM.has_key("Tangent") and U is not None: + if CM is not None and "Tangent" in CM and U is not None: Cm = CM["Tangent"].asMatrix(Xb) else: Cm = None diff --git a/src/daComposant/daCore/AssimilationStudy.py b/src/daComposant/daCore/AssimilationStudy.py index ac5abc9..82fca1b 100644 --- a/src/daComposant/daCore/AssimilationStudy.py +++ b/src/daComposant/daCore/AssimilationStudy.py @@ -32,16 +32,16 @@ __all__ = ["AssimilationStudy"] import os, sys import numpy -import ExtendedLogging ; ExtendedLogging.ExtendedLogging() # A importer en premier +from daCore import ExtendedLogging ; ExtendedLogging.ExtendedLogging() # A importer en premier import logging try: import scipy.optimize logging.debug("Succeed initial import of scipy.optimize with Scipy %s", scipy.version.version) except ImportError: logging.debug("Fail initial import of scipy.optimize") -import Persistence -from BasicObjects import Operator, Covariance -import PlatformInfo +from daCore import Persistence +from daCore.BasicObjects import Operator, Covariance +from daCore import PlatformInfo # ============================================================================== class AssimilationStudy: diff --git a/src/daComposant/daCore/BasicObjects.py b/src/daComposant/daCore/BasicObjects.py index f86fc82..6d99271 100644 --- a/src/daComposant/daCore/BasicObjects.py +++ b/src/daComposant/daCore/BasicObjects.py @@ -30,8 +30,8 @@ __all__ = [] import logging, copy import numpy -import Persistence -import PlatformInfo +from daCore import Persistence +from daCore import PlatformInfo # ============================================================================== class CacheManager(object): @@ -59,7 +59,7 @@ class CacheManager(object): "Vérifie l'existence d'un calcul correspondant à la valeur" __alc = False __HxV = None - for i in xrange(min(len(self.__listOPCV),self.__lenghtOR)-1,-1,-1): + for i in range(min(len(self.__listOPCV),self.__lenghtOR)-1,-1,-1): if xValue.size != self.__listOPCV[i][0].size: # logging.debug("CM Différence de la taille %s de X et de celle %s du point %i déjà calculé", xValue.shape,i,self.__listOPCP[i].shape) continue @@ -175,7 +175,7 @@ class Operator(object): # return HxValue - def appliedControledFormTo(self, (xValue, uValue) ): + def appliedControledFormTo(self, paire ): """ Permet de restituer le résultat de l'application de l'opérateur à une paire (xValue, uValue). Cette méthode se contente d'appliquer, son @@ -185,6 +185,8 @@ class Operator(object): - xValue : argument X adapté pour appliquer l'opérateur - uValue : argument U adapté pour appliquer l'opérateur """ + assert len(paire) == 2, "Incorrect number of arguments" + xValue, uValue = paire if self.__Matrix is not None: self.__addOneMatrixCall() return self.__Matrix * xValue @@ -195,7 +197,7 @@ class Operator(object): self.__addOneMethodCall() return self.__Method( xValue ) - def appliedInXTo(self, (xNominal, xValue) ): + def appliedInXTo(self, paire ): """ Permet de restituer le résultat de l'application de l'opérateur à un argument xValue, sachant que l'opérateur est valable en xNominal. @@ -208,6 +210,8 @@ class Operator(object): est construit pour etre ensuite appliqué - xValue : argument adapté pour appliquer l'opérateur """ + assert len(paire) == 2, "Incorrect number of arguments" + xNominal, xValue = paire if self.__Matrix is not None: self.__addOneMatrixCall() return self.__Matrix * xValue @@ -365,7 +369,7 @@ class Algorithm(object): self.__setParameters(Parameters) # # Corrections et complements - if self._parameters.has_key("Bounds") and (type(self._parameters["Bounds"]) is type([]) or type(self._parameters["Bounds"]) is type(())) and (len(self._parameters["Bounds"]) > 0): + if "Bounds" in self._parameters and (type(self._parameters["Bounds"]) is type([]) or type(self._parameters["Bounds"]) is type(())) and (len(self._parameters["Bounds"]) > 0): logging.debug("%s Prise en compte des bornes effectuee"%(self._name,)) else: self._parameters["Bounds"] = None diff --git a/src/daComposant/daCore/ExtendedLogging.py b/src/daComposant/daCore/ExtendedLogging.py index e9daddc..a3bbf22 100644 --- a/src/daComposant/daCore/ExtendedLogging.py +++ b/src/daComposant/daCore/ExtendedLogging.py @@ -76,7 +76,7 @@ __all__ = [] import os import sys import logging -import PlatformInfo +from daCore import PlatformInfo LOGFILE = os.path.join(os.path.abspath(os.curdir),"AssimilationStudy.log") diff --git a/src/daComposant/daCore/Persistence.py b/src/daComposant/daCore/Persistence.py index e095a38..b9c6577 100644 --- a/src/daComposant/daCore/Persistence.py +++ b/src/daComposant/daCore/Persistence.py @@ -29,7 +29,7 @@ __all__ = [] import numpy, copy -from PlatformInfo import PathManagement ; PathManagement() +from daCore.PlatformInfo import PathManagement ; PathManagement() # ============================================================================== class Persistence(object): diff --git a/src/daComposant/daCore/PlatformInfo.py b/src/daComposant/daCore/PlatformInfo.py index 78d621b..1ab3a7e 100644 --- a/src/daComposant/daCore/PlatformInfo.py +++ b/src/daComposant/daCore/PlatformInfo.py @@ -52,17 +52,17 @@ class PlatformInfo(object): def getName(self): "Retourne le nom de l'application" - import version as dav + import daCore.version as dav return dav.name def getVersion(self): "Retourne le numéro de la version" - import version as dav + import daCore.version as dav return dav.version def getDate(self): "Retourne la date de création de la version" - import version as dav + import daCore.version as dav return dav.date def getPythonVersion(self): @@ -138,7 +138,7 @@ class PlatformInfo(object): return sys.float_info.epsilon def __str__(self): - import version as dav + import daCore.version as dav return "%s %s (%s)"%(dav.name,dav.version,dav.date) # ============================================================================== diff --git a/src/daComposant/daCore/Templates.py b/src/daComposant/daCore/Templates.py index 60b4672..c7ab6b1 100644 --- a/src/daComposant/daCore/Templates.py +++ b/src/daComposant/daCore/Templates.py @@ -60,9 +60,9 @@ class TemplateStorage(object): __keys.sort() return __keys - def has_key(self, name): - "D.has_key(k) -> True if D has a key k, else False" - return name in self.__values + # def has_key(self, name): + # "D.has_key(k) -> True if D has a key k, else False" + # return name in self.__values def __contains__(self, name): "D.__contains__(k) -> True if D has a key k, else False" diff --git a/src/daComposant/daDiagnostics/PlotVector.py b/src/daComposant/daDiagnostics/PlotVector.py index 69179d3..97751e4 100644 --- a/src/daComposant/daDiagnostics/PlotVector.py +++ b/src/daComposant/daDiagnostics/PlotVector.py @@ -124,7 +124,7 @@ class ElementaryDiagnostic(BasicObjects.Diagnostic): # ============================================================================== if __name__ == "__main__": - print '\n AUTODIAGNOSTIC \n' + print('\n AUTODIAGNOSTIC \n') D = ElementaryDiagnostic("Mon Plot") @@ -146,4 +146,4 @@ if __name__ == "__main__": D.calculate(vect, title = "Vecteur 8", ltitle = "Vecteur 8") temps = [0.1,0.2,0.3,0.4,0.5] D.calculate(vect, temps, title = "Vecteur 8 avec axe du temps modifie") - print + print("") diff --git a/src/daComposant/daDiagnostics/PlotVectors.py b/src/daComposant/daDiagnostics/PlotVectors.py index c1058a8..e3d58c9 100644 --- a/src/daComposant/daDiagnostics/PlotVectors.py +++ b/src/daComposant/daDiagnostics/PlotVectors.py @@ -58,9 +58,9 @@ class ElementaryDiagnostic(BasicObjects.Diagnostic): self.__g('set style data lines') self.__g('set grid') self.__g('set autoscale') - self.__g('set title "'+title +'"') - self.__g('set xlabel "'+xlabel+'"') - self.__g('set ylabel "'+ylabel+'"') + self.__g('set title "'+str(title) +'"') + self.__g('set xlabel "'+str(xlabel)+'"') + self.__g('set ylabel "'+str(ylabel)+'"') self.__g.plot( self.__gnuplot.Data( Steps, Vector.pop(0), title=ltitle.pop(0) ) ) for vector in Vector: self.__g.replot( self.__gnuplot.Data( Steps, vector, title=ltitle.pop(0) ) ) @@ -135,7 +135,7 @@ class ElementaryDiagnostic(BasicObjects.Diagnostic): # ============================================================================== if __name__ == "__main__": - print '\n AUTODIAGNOSTIC \n' + print('\n AUTODIAGNOSTIC \n') D = ElementaryDiagnostic("Mon Plot") @@ -152,4 +152,4 @@ if __name__ == "__main__": [0.1,0.2,0.3,0.4,0.5], title = "Vecteurs 1 a 3, temps modifie", ltitle = ["Vecteur 1","Vecteur 2","Vecteur 3"]) - print + print("") diff --git a/src/daComposant/daDiagnostics/RMS.py b/src/daComposant/daDiagnostics/RMS.py index 6fe3272..509c15b 100644 --- a/src/daComposant/daDiagnostics/RMS.py +++ b/src/daComposant/daDiagnostics/RMS.py @@ -59,7 +59,7 @@ class ElementaryDiagnostic(BasicObjects.Diagnostic,Persistence.OneScalar): # ============================================================================== if __name__ == "__main__": - print '\n AUTODIAGNOSTIC \n' + print('\n AUTODIAGNOSTIC \n') D = ElementaryDiagnostic("Ma RMS") @@ -81,8 +81,8 @@ if __name__ == "__main__": vect1 = [-0.23262176, 1.36065207, 0.32988102, 0.24400551, -0.66765848, -0.19088483, -0.31082575, 0.56849814, 1.21453443, 0.99657516] vect2 = [0,0,0,0,0,0,0,0,0,0] D.calculate(vect1,vect2) - print " Les valeurs de RMS attendues sont les suivantes : [1.0, 1.0, 1.0, 3.0, 0.53162016515553656, 0.73784217096601323]" - print " Les RMS obtenues................................:", D[:] - print " La moyenne......................................:", D.mean() - print + print(" Les valeurs de RMS attendues sont les suivantes : [1.0, 1.0, 1.0, 3.0, 0.53162016515553656, 0.73784217096601323]") + print(" Les RMS obtenues................................: %s"%(D[:],)) + print(" La moyenne......................................: %s"%(D.mean(),)) + print("") diff --git a/src/daComposant/daDiagnostics/ReduceVariance.py b/src/daComposant/daDiagnostics/ReduceVariance.py index b78edb6..23225cc 100644 --- a/src/daComposant/daDiagnostics/ReduceVariance.py +++ b/src/daComposant/daDiagnostics/ReduceVariance.py @@ -68,7 +68,7 @@ class ElementaryDiagnostic(BasicObjects.Diagnostic,Persistence.OneScalar): #=============================================================================== if __name__ == "__main__": - print '\n AUTODIAGNOSTIC \n' + print('\n AUTODIAGNOSTIC \n') # # Instanciation de l'objet diagnostic # ----------------------------------- @@ -78,34 +78,34 @@ if __name__ == "__main__": # ---------------------- x1 = numpy.matrix(([3. , 4., 5. ])) x2 = numpy.matrix(([1.5, 2., 2.5])) - print " L'écart entre les observations et l'ébauche est OMB :", x1 - print " La moyenne de OMB (i.e. le biais) est de............:", x1.mean() - print " La variance de OMB est de...........................:", x1.var() - print " L'écart entre les observations et l'analyse est OMA :", x2 - print " La moyenne de OMA (i.e. le biais) est de............:", x2.mean() - print " La variance de OMA est de...........................:", x2.var() + print(" L'écart entre les observations et l'ébauche est OMB :", x1) + print(" La moyenne de OMB (i.e. le biais) est de............:", x1.mean()) + print(" La variance de OMB est de...........................:", x1.var()) + print(" L'écart entre les observations et l'analyse est OMA :", x2) + print(" La moyenne de OMA (i.e. le biais) est de............:", x2.mean()) + print(" La variance de OMA est de...........................:", x2.var()) # D.calculate( vectorOMB = x1, vectorOMA = x2) if not D[0] : - print " Résultat : l'analyse NE RÉDUIT PAS la variance" + print(" Résultat : l'analyse NE RÉDUIT PAS la variance") else : - print " Résultat : l'analyse RÉDUIT la variance" - print + print(" Résultat : l'analyse RÉDUIT la variance") + print("") # # Vecteur de type array # --------------------- x1 = numpy.array(range(11)) x2 = numpy.matrix(range(-10,12,2)) - print " L'écart entre les observations et l'ébauche est OMB :", x1 - print " La moyenne de OMB (i.e. le biais) est de............:", x1.mean() - print " La variance de OMB est de...........................:", x1.var() - print " L'écart entre les observations et l'analyse est OMA :", x2 - print " La moyenne de OMA (i.e. le biais) est de............:", x2.mean() - print " La variance de OMA est de...........................:", x2.var() + print(" L'écart entre les observations et l'ébauche est OMB :", x1) + print(" La moyenne de OMB (i.e. le biais) est de............:", x1.mean()) + print(" La variance de OMB est de...........................:", x1.var()) + print(" L'écart entre les observations et l'analyse est OMA :", x2) + print(" La moyenne de OMA (i.e. le biais) est de............:", x2.mean()) + print(" La variance de OMA est de...........................:", x2.var()) # D.calculate( vectorOMB = x1, vectorOMA = x2) if not D[1] : - print " Résultat : l'analyse NE RÉDUIT PAS la variance" + print(" Résultat : l'analyse NE RÉDUIT PAS la variance") else : - print " Résultat : l'analyse RÉDUIT la variance" - print + print(" Résultat : l'analyse RÉDUIT la variance") + print("") diff --git a/src/daComposant/daNumerics/ApproximatedDerivatives.py b/src/daComposant/daNumerics/ApproximatedDerivatives.py index ec60fc4..4cc812d 100644 --- a/src/daComposant/daNumerics/ApproximatedDerivatives.py +++ b/src/daComposant/daNumerics/ApproximatedDerivatives.py @@ -31,7 +31,9 @@ from daCore.BasicObjects import Operator # logging.getLogger().setLevel(logging.DEBUG) # ============================================================================== -def ExecuteFunction( (X, funcrepr) ): +def ExecuteFunction( paire ): + assert len(paire) == 2, "Incorrect number of arguments" + X, funcrepr = paire __X = numpy.asmatrix(numpy.ravel( X )).T __sys_path_tmp = sys.path ; sys.path.insert(0,funcrepr["__userFunction__path"]) __module = __import__(funcrepr["__userFunction__modl"], globals(), locals(), []) @@ -122,7 +124,7 @@ class FDApproximation(object): self.__listJPIN = [] # Jacobian Previous Calculated Increment Norms else: self.__avoidRC = False - if float(increment) <> 0.: + if abs(float(increment)) > 1.e-15: self.__increment = float(increment) else: self.__increment = 0.01 @@ -318,10 +320,12 @@ class FDApproximation(object): return _Jacobienne # --------------------------------------------------------- - def TangentOperator(self, (X, dX) ): + def TangentOperator(self, paire ): """ Calcul du tangent à l'aide de la Jacobienne. """ + assert len(paire) == 2, "Incorrect number of arguments" + X, dX = paire _Jacobienne = self.TangentMatrix( X ) if dX is None or len(dX) == 0: # @@ -337,10 +341,12 @@ class FDApproximation(object): return _HtX.A1 # --------------------------------------------------------- - def AdjointOperator(self, (X, Y) ): + def AdjointOperator(self, paire ): """ Calcul de l'adjoint à l'aide de la Jacobienne. """ + assert len(paire) == 2, "Incorrect number of arguments" + X, Y = paire _JacobienneT = self.TangentMatrix( X ).T if Y is None or len(Y) == 0: # @@ -357,4 +363,4 @@ class FDApproximation(object): # ============================================================================== if __name__ == "__main__": - print '\n AUTODIAGNOSTIC \n' + print('\n AUTODIAGNOSTIC \n') diff --git a/src/daComposant/daNumerics/mmqr.py b/src/daComposant/daNumerics/mmqr.py index de88e1c..698398d 100644 --- a/src/daComposant/daNumerics/mmqr.py +++ b/src/daComposant/daNumerics/mmqr.py @@ -105,4 +105,4 @@ def mmqr( # ============================================================================== if __name__ == "__main__": - print '\n AUTODIAGNOSTIC \n' + print('\n AUTODIAGNOSTIC \n')