From: Jean-Philippe ARGAUD Date: Tue, 10 Jan 2023 20:49:59 +0000 (+0100) Subject: Minor documentation and code review corrections (38) X-Git-Tag: V9_11_0a1~13 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a6845547d27bcdc0928f898a4c8a2e4fc276c69e;p=modules%2Fadao.git Minor documentation and code review corrections (38) --- diff --git a/doc/en/snippets/ModuleCompatibility.rst b/doc/en/snippets/ModuleCompatibility.rst index 51b980e..a001843 100644 --- a/doc/en/snippets/ModuleCompatibility.rst +++ b/doc/en/snippets/ModuleCompatibility.rst @@ -13,8 +13,8 @@ guarantee). :widths: 20, 10, 10 Python, 3.6.5, 3.10.8 - Numpy, 1.14.3, 1.23.5 - Scipy, 1.1.0, 1.9.3 + Numpy, 1.14.3, 1.24.1 + Scipy, 1.1.0, 1.10.0 MatplotLib, 2.2.2, 3.6.2 - GnuplotPy, 1.8, 1.8 + GnuplotPy, 1.8, 1.8 NLopt, 2.4.2, 2.7.1 diff --git a/doc/fr/snippets/ModuleCompatibility.rst b/doc/fr/snippets/ModuleCompatibility.rst index a53e952..b9eab33 100644 --- a/doc/fr/snippets/ModuleCompatibility.rst +++ b/doc/fr/snippets/ModuleCompatibility.rst @@ -13,8 +13,8 @@ la version atteinte (mais cela reste sans garantie). :widths: 20, 10, 10 Python, 3.6.5, 3.10.8 - Numpy, 1.14.3, 1.23.5 - Scipy, 1.1.0, 1.9.3 + Numpy, 1.14.3, 1.24.1 + Scipy, 1.1.0, 1.10.0 MatplotLib, 2.2.2, 3.6.2 - GnuplotPy, 1.8, 1.8 + GnuplotPy, 1.8, 1.8 NLopt, 2.4.2, 2.7.1 diff --git a/src/daComposant/daAlgorithms/Atoms/ecwnlls.py b/src/daComposant/daAlgorithms/Atoms/ecwnlls.py index 950cd1a..4ddfa11 100644 --- a/src/daComposant/daAlgorithms/Atoms/ecwnlls.py +++ b/src/daComposant/daAlgorithms/Atoms/ecwnlls.py @@ -26,6 +26,7 @@ __doc__ = """ __author__ = "Jean-Philippe ARGAUD" import numpy, scipy, scipy.optimize, scipy.version +from daCore.PlatformInfo import vt # ============================================================================== def ecwnlls(selfA, Xb, Y, U, HO, CM, R, B, __storeState = False): @@ -132,13 +133,13 @@ def ecwnlls(selfA, Xb, Y, U, HO, CM, R, B, __storeState = False): nbPreviousSteps = selfA.StoredVariables["CostFunctionJ"].stepnumber() # if selfA._parameters["Minimizer"] == "LBFGSB": - if "0.19" <= scipy.version.version <= "1.4.99": + if vt("0.19") <= vt(scipy.version.version) <= vt("1.4.99"): import daAlgorithms.Atoms.lbfgsb14hlt as optimiseur - elif "1.5.0" <= scipy.version.version <= "1.7.99": + elif vt("1.5.0") <= vt(scipy.version.version) <= vt("1.7.99"): import daAlgorithms.Atoms.lbfgsb17hlt as optimiseur - elif "1.8.0" <= scipy.version.version <= "1.8.99": + elif vt("1.8.0") <= vt(scipy.version.version) <= vt("1.8.99"): import daAlgorithms.Atoms.lbfgsb18hlt as optimiseur - elif "1.9.0" <= scipy.version.version <= "1.9.99": + elif vt("1.9.0") <= vt(scipy.version.version) <= vt("1.10.99"): import daAlgorithms.Atoms.lbfgsb19hlt as optimiseur else: import scipy.optimize as optimiseur diff --git a/src/daComposant/daAlgorithms/Atoms/incr3dvar.py b/src/daComposant/daAlgorithms/Atoms/incr3dvar.py index 9e217aa..9540603 100644 --- a/src/daComposant/daAlgorithms/Atoms/incr3dvar.py +++ b/src/daComposant/daAlgorithms/Atoms/incr3dvar.py @@ -28,7 +28,7 @@ __author__ = "Jean-Philippe ARGAUD" import numpy, scipy, scipy.optimize, scipy.version from daCore.NumericObjects import HessienneEstimation, QuantilesEstimations from daCore.NumericObjects import RecentredBounds -from daCore.PlatformInfo import PlatformInfo +from daCore.PlatformInfo import PlatformInfo, vt mpr = PlatformInfo().MachinePrecision() # ============================================================================== @@ -134,13 +134,13 @@ def incr3dvar(selfA, Xb, Y, U, HO, CM, R, B, __storeState = False): # if selfA._parameters["Minimizer"] == "LBFGSB": # Minimum, J_optimal, Informations = scipy.optimize.fmin_l_bfgs_b( - if "0.19" <= scipy.version.version <= "1.4.99": + if vt("0.19") <= vt(scipy.version.version) <= vt("1.4.99"): import daAlgorithms.Atoms.lbfgsb14hlt as optimiseur - elif "1.5.0" <= scipy.version.version <= "1.7.99": + elif vt("1.5.0") <= vt(scipy.version.version) <= vt("1.7.99"): import daAlgorithms.Atoms.lbfgsb17hlt as optimiseur - elif "1.8.0" <= scipy.version.version <= "1.8.99": + elif vt("1.8.0") <= vt(scipy.version.version) <= vt("1.8.99"): import daAlgorithms.Atoms.lbfgsb18hlt as optimiseur - elif "1.9.0" <= scipy.version.version <= "1.9.99": + elif vt("1.9.0") <= vt(scipy.version.version) <= vt("1.10.99"): import daAlgorithms.Atoms.lbfgsb19hlt as optimiseur else: import scipy.optimize as optimiseur diff --git a/src/daComposant/daAlgorithms/Atoms/psas3dvar.py b/src/daComposant/daAlgorithms/Atoms/psas3dvar.py index 3921022..a98a604 100644 --- a/src/daComposant/daAlgorithms/Atoms/psas3dvar.py +++ b/src/daComposant/daAlgorithms/Atoms/psas3dvar.py @@ -27,6 +27,7 @@ __author__ = "Jean-Philippe ARGAUD" import numpy, scipy, scipy.optimize, scipy.version from daCore.NumericObjects import HessienneEstimation, QuantilesEstimations +from daCore.PlatformInfo import vt # ============================================================================== def psas3dvar(selfA, Xb, Y, U, HO, CM, R, B, __storeState = False): @@ -114,13 +115,13 @@ def psas3dvar(selfA, Xb, Y, U, HO, CM, R, B, __storeState = False): nbPreviousSteps = selfA.StoredVariables["CostFunctionJ"].stepnumber() # if selfA._parameters["Minimizer"] == "LBFGSB": - if "0.19" <= scipy.version.version <= "1.4.99": + if vt("0.19") <= vt(scipy.version.version) <= vt("1.4.99"): import daAlgorithms.Atoms.lbfgsb14hlt as optimiseur - elif "1.5.0" <= scipy.version.version <= "1.7.99": + elif vt("1.5.0") <= vt(scipy.version.version) <= vt("1.7.99"): import daAlgorithms.Atoms.lbfgsb17hlt as optimiseur - elif "1.8.0" <= scipy.version.version <= "1.8.99": + elif vt("1.8.0") <= vt(scipy.version.version) <= vt("1.8.99"): import daAlgorithms.Atoms.lbfgsb18hlt as optimiseur - elif "1.9.0" <= scipy.version.version <= "1.9.99": + elif vt("1.9.0") <= vt(scipy.version.version) <= vt("1.10.99"): import daAlgorithms.Atoms.lbfgsb19hlt as optimiseur else: import scipy.optimize as optimiseur diff --git a/src/daComposant/daAlgorithms/Atoms/std3dvar.py b/src/daComposant/daAlgorithms/Atoms/std3dvar.py index 8d2b7b2..b67735e 100644 --- a/src/daComposant/daAlgorithms/Atoms/std3dvar.py +++ b/src/daComposant/daAlgorithms/Atoms/std3dvar.py @@ -27,6 +27,7 @@ __author__ = "Jean-Philippe ARGAUD" import numpy, scipy, scipy.optimize, scipy.version from daCore.NumericObjects import HessienneEstimation, QuantilesEstimations +from daCore.PlatformInfo import vt # ============================================================================== def std3dvar(selfA, Xb, Y, U, HO, CM, R, B, __storeState = False): @@ -117,13 +118,13 @@ def std3dvar(selfA, Xb, Y, U, HO, CM, R, B, __storeState = False): nbPreviousSteps = selfA.StoredVariables["CostFunctionJ"].stepnumber() # if selfA._parameters["Minimizer"] == "LBFGSB": - if "0.19" <= scipy.version.version <= "1.4.99": + if vt("0.19") <= vt(scipy.version.version) <= vt("1.4.99"): import daAlgorithms.Atoms.lbfgsb14hlt as optimiseur - elif "1.5.0" <= scipy.version.version <= "1.7.99": + elif vt("1.5.0") <= vt(scipy.version.version) <= vt("1.7.99"): import daAlgorithms.Atoms.lbfgsb17hlt as optimiseur - elif "1.8.0" <= scipy.version.version <= "1.8.99": + elif vt("1.8.0") <= vt(scipy.version.version) <= vt("1.8.99"): import daAlgorithms.Atoms.lbfgsb18hlt as optimiseur - elif "1.9.0" <= scipy.version.version <= "1.9.99": + elif vt("1.9.0") <= vt(scipy.version.version) <= vt("1.10.99"): import daAlgorithms.Atoms.lbfgsb19hlt as optimiseur else: import scipy.optimize as optimiseur diff --git a/src/daComposant/daAlgorithms/Atoms/std4dvar.py b/src/daComposant/daAlgorithms/Atoms/std4dvar.py index 6a6aa47..39ca157 100644 --- a/src/daComposant/daAlgorithms/Atoms/std4dvar.py +++ b/src/daComposant/daAlgorithms/Atoms/std4dvar.py @@ -27,7 +27,7 @@ __author__ = "Jean-Philippe ARGAUD" import numpy, scipy, scipy.optimize, scipy.version from daCore.NumericObjects import ForceNumericBounds, ApplyBounds -from daCore.PlatformInfo import PlatformInfo +from daCore.PlatformInfo import PlatformInfo, vt mpr = PlatformInfo().MachinePrecision() mfp = PlatformInfo().MaximumPrecision() @@ -178,13 +178,13 @@ def std4dvar(selfA, Xb, Y, U, HO, EM, CM, R, B, Q): nbPreviousSteps = selfA.StoredVariables["CostFunctionJ"].stepnumber() # if selfA._parameters["Minimizer"] == "LBFGSB": - if "0.19" <= scipy.version.version <= "1.4.99": + if vt("0.19") <= vt(scipy.version.version) <= vt("1.4.99"): import daAlgorithms.Atoms.lbfgsb14hlt as optimiseur - elif "1.5.0" <= scipy.version.version <= "1.7.99": + elif vt("1.5.0") <= vt(scipy.version.version) <= vt("1.7.99"): import daAlgorithms.Atoms.lbfgsb17hlt as optimiseur - elif "1.8.0" <= scipy.version.version <= "1.8.99": + elif vt("1.8.0") <= vt(scipy.version.version) <= vt("1.8.99"): import daAlgorithms.Atoms.lbfgsb18hlt as optimiseur - elif "1.9.0" <= scipy.version.version <= "1.9.99": + elif vt("1.9.0") <= vt(scipy.version.version) <= vt("1.10.99"): import daAlgorithms.Atoms.lbfgsb19hlt as optimiseur else: import scipy.optimize as optimiseur diff --git a/src/daComposant/daAlgorithms/Atoms/van3dvar.py b/src/daComposant/daAlgorithms/Atoms/van3dvar.py index 95403c0..541a5c1 100644 --- a/src/daComposant/daAlgorithms/Atoms/van3dvar.py +++ b/src/daComposant/daAlgorithms/Atoms/van3dvar.py @@ -28,7 +28,7 @@ __author__ = "Jean-Philippe ARGAUD" import numpy, scipy, scipy.optimize, scipy.version from daCore.NumericObjects import HessienneEstimation, QuantilesEstimations from daCore.NumericObjects import RecentredBounds -from daCore.PlatformInfo import PlatformInfo +from daCore.PlatformInfo import PlatformInfo, vt mpr = PlatformInfo().MachinePrecision() # ============================================================================== @@ -126,13 +126,13 @@ def van3dvar(selfA, Xb, Y, U, HO, CM, R, B, __storeState = False): nbPreviousSteps = selfA.StoredVariables["CostFunctionJ"].stepnumber() # if selfA._parameters["Minimizer"] == "LBFGSB": - if "0.19" <= scipy.version.version <= "1.4.99": + if vt("0.19") <= vt(scipy.version.version) <= vt("1.4.99"): import daAlgorithms.Atoms.lbfgsb14hlt as optimiseur - elif "1.5.0" <= scipy.version.version <= "1.7.99": + elif vt("1.5.0") <= vt(scipy.version.version) <= vt("1.7.99"): import daAlgorithms.Atoms.lbfgsb17hlt as optimiseur - elif "1.8.0" <= scipy.version.version <= "1.8.99": + elif vt("1.8.0") <= vt(scipy.version.version) <= vt("1.8.99"): import daAlgorithms.Atoms.lbfgsb18hlt as optimiseur - elif "1.9.0" <= scipy.version.version <= "1.9.99": + elif vt("1.9.0") <= vt(scipy.version.version) <= vt("1.10.99"): import daAlgorithms.Atoms.lbfgsb19hlt as optimiseur else: import scipy.optimize as optimiseur diff --git a/src/daComposant/daCore/Aidsm.py b/src/daComposant/daCore/Aidsm.py index 0017714..256c38a 100644 --- a/src/daComposant/daCore/Aidsm.py +++ b/src/daComposant/daCore/Aidsm.py @@ -124,7 +124,7 @@ class Aidsm(object): Vector = None, VectorSerie = None, ): - "Interface unique de definition de variables d'entrees par argument" + "Interface unique de définition de variables d'entrées par argument" self.__case.register("set",dir(),locals(),None,True) try: if Concept in ("Background", "CheckingPoint", "ControlInput", "Observation"): @@ -185,7 +185,7 @@ class Aidsm(object): Stored = False, Scheduler = None, Checked = False): - "Definition d'un concept de calcul" + "Définition d'un concept de calcul" Concept = "Background" self.__case.register("set"+Concept, dir(), locals()) self.__adaoObject[Concept] = State( @@ -213,7 +213,7 @@ class Aidsm(object): Stored = False, Scheduler = None, Checked = False): - "Definition d'un concept de calcul" + "Définition d'un concept de calcul" Concept = "CheckingPoint" self.__case.register("set"+Concept, dir(), locals()) self.__adaoObject[Concept] = State( @@ -241,7 +241,7 @@ class Aidsm(object): Stored = False, Scheduler = None, Checked = False): - "Definition d'un concept de calcul" + "Définition d'un concept de calcul" Concept = "ControlInput" self.__case.register("set"+Concept, dir(), locals()) self.__adaoObject[Concept] = State( @@ -269,7 +269,7 @@ class Aidsm(object): Stored = False, Scheduler = None, Checked = False): - "Definition d'un concept de calcul" + "Définition d'un concept de calcul" Concept = "Observation" self.__case.register("set"+Concept, dir(), locals()) self.__adaoObject[Concept] = State( @@ -295,7 +295,7 @@ class Aidsm(object): Stored = False, ObjectMatrix = None, Checked = False): - "Definition d'un concept de calcul" + "Définition d'un concept de calcul" Concept = "BackgroundError" self.__case.register("set"+Concept, dir(), locals()) self.__adaoObject[Concept] = Covariance( @@ -319,7 +319,7 @@ class Aidsm(object): Stored = False, ObjectMatrix = None, Checked = False): - "Definition d'un concept de calcul" + "Définition d'un concept de calcul" Concept = "ObservationError" self.__case.register("set"+Concept, dir(), locals()) self.__adaoObject[Concept] = Covariance( @@ -343,7 +343,7 @@ class Aidsm(object): Stored = False, ObjectMatrix = None, Checked = False): - "Definition d'un concept de calcul" + "Définition d'un concept de calcul" Concept = "EvolutionError" self.__case.register("set"+Concept, dir(), locals()) self.__adaoObject[Concept] = Covariance( @@ -371,7 +371,7 @@ class Aidsm(object): PerformanceProfile = None, InputFunctionAsMulti = False, Checked = False): - "Definition d'un concept de calcul" + "Définition d'un concept de calcul" Concept = "ObservationOperator" self.__case.register("set"+Concept, dir(), locals()) self.__adaoObject[Concept] = FullOperator( @@ -404,7 +404,7 @@ class Aidsm(object): PerformanceProfile = None, InputFunctionAsMulti = False, Checked = False): - "Definition d'un concept de calcul" + "Définition d'un concept de calcul" Concept = "EvolutionModel" self.__case.register("set"+Concept, dir(), locals()) self.__adaoObject[Concept] = FullOperator( @@ -437,7 +437,7 @@ class Aidsm(object): PerformanceProfile = None, InputFunctionAsMulti = False, Checked = False): - "Definition d'un concept de calcul" + "Définition d'un concept de calcul" Concept = "ControlModel" self.__case.register("set"+Concept, dir(), locals()) self.__adaoObject[Concept] = FullOperator( @@ -459,7 +459,7 @@ class Aidsm(object): return 0 def setName(self, String=None): - "Definition d'un concept de calcul" + "Définition d'un concept de calcul" self.__case.register("setName",dir(),locals()) if String is not None: self.__name = str(String) @@ -468,7 +468,7 @@ class Aidsm(object): self.__StoredInputs["Name"] = self.__name def setDirectory(self, String=None): - "Definition d'un concept de calcul" + "Définition d'un concept de calcul" self.__case.register("setDirectory",dir(),locals()) if os.path.isdir(os.path.abspath(str(String))): self.__directory = os.path.abspath(str(String)) @@ -498,7 +498,7 @@ class Aidsm(object): Algorithm = None, Parameters = None, Script = None): - "Definition d'un concept de calcul" + "Définition d'un concept de calcul" Concept = "AlgorithmParameters" self.__case.register("set"+Concept, dir(), locals()) self.__adaoObject[Concept] = AlgorithmAndParameters( @@ -512,7 +512,7 @@ class Aidsm(object): def updateAlgorithmParameters(self, Parameters = None, Script = None): - "Mise a jour d'un concept de calcul" + "Mise à jour d'un concept de calcul" Concept = "AlgorithmParameters" if Concept not in self.__adaoObject or self.__adaoObject[Concept] is None: raise ValueError("\n\nNo algorithm registred, set one before updating parameters or executing\n") @@ -527,7 +527,7 @@ class Aidsm(object): Algorithm = None, Parameters = None, Script = None): - "Definition d'un concept de calcul" + "Définition d'un concept de calcul" Concept = "RegulationParameters" self.__case.register("set"+Concept, dir(), locals()) self.__adaoObject[Concept] = RegulationAndParameters( @@ -541,7 +541,7 @@ class Aidsm(object): def setSupplementaryParameters(self, Parameters = None, Script = None): - "Definition d'un concept de calcul" + "Définition d'un concept de calcul" Concept = "SupplementaryParameters" self.__case.register("set"+Concept, dir(), locals()) self.__adaoObject[Concept] = ExternalParameters( @@ -554,7 +554,7 @@ class Aidsm(object): def updateSupplementaryParameters(self, Parameters = None, Script = None): - "Mise a jour d'un concept de calcul" + "Mise à jour d'un concept de calcul" Concept = "SupplementaryParameters" if Concept not in self.__adaoObject or self.__adaoObject[Concept] is None: self.__adaoObject[Concept] = ExternalParameters(name = Concept) @@ -572,7 +572,7 @@ class Aidsm(object): Info = None, ObjectFunction = None, Scheduler = None): - "Definition d'un concept de calcul" + "Définition d'un concept de calcul" Concept = "Observer" self.__case.register("set"+Concept, dir(), locals()) self.__adaoObject[Concept].append( DataObserver( @@ -592,7 +592,7 @@ class Aidsm(object): Variable = None, ObjectFunction = None, ): - "Permet de retirer un observer à une ou des variable nommée" + "Permet de retirer un observer à une ou des variable nommées" if "AlgorithmParameters" not in self.__adaoObject: raise ValueError("No algorithm registred, ask for one before removing observers") # @@ -617,7 +617,7 @@ class Aidsm(object): Template = None, String = None, Script = None): - "Definition d'un concept de calcul" + "Définition d'un concept de calcul" Concept = "UserPostAnalysis" self.__case.register("set"+Concept, dir(), locals()) self.__adaoObject[Concept].append( repr(UserScript( @@ -631,7 +631,7 @@ class Aidsm(object): # ----------------------------------------------------------- def get(self, Concept=None, noDetails=True ): - "Recuperation d'une sortie du calcul" + "Récupération d'une sortie du calcul" if Concept is not None: try: self.__case.register("get", dir(), locals(), Concept) # Break pickle in Python 2 diff --git a/src/daComposant/daCore/BasicObjects.py b/src/daComposant/daCore/BasicObjects.py index 4ba3b37..eefbea3 100644 --- a/src/daComposant/daCore/BasicObjects.py +++ b/src/daComposant/daCore/BasicObjects.py @@ -792,7 +792,7 @@ class Algorithm(object): logging.debug("%s Taille mémoire utilisée de %.0f Mio"%(self._name, self._m.getUsedMemory("Mio"))) self._getTimeState(reset=True) # - # Mise a jour des paramètres internes avec le contenu de Parameters, en + # Mise à jour des paramètres internes avec le contenu de Parameters, en # reprenant les valeurs par défauts pour toutes celles non définies self.__setParameters(Parameters, reset=True) for k, v in self.__variable_names_not_public.items(): @@ -978,10 +978,9 @@ class Algorithm(object): def run(self, Xb=None, Y=None, H=None, M=None, R=None, B=None, Q=None, Parameters=None): """ - Doit implémenter l'opération élémentaire de calcul d'assimilation sous - sa forme mathématique la plus naturelle possible. + Doit implémenter l'opération élémentaire de calcul algorithmique. """ - raise NotImplementedError("Mathematical assimilation calculation has not been implemented!") + raise NotImplementedError("Mathematical algorithmic calculation has not been implemented!") def defineRequiredParameter(self, name = None, @@ -1246,7 +1245,7 @@ class AlgorithmAndParameters(object): asDict = None, asScript = None, ): - "Mise a jour des parametres" + "Mise à jour des paramètres" if asDict is None and asScript is not None: __Dict = Interfaces.ImportFromScript(asScript).getvalue( self.__name, "Parameters" ) else: @@ -1748,7 +1747,7 @@ class UserScript(object): # ============================================================================== class ExternalParameters(object): """ - Classe générale d'interface de type texte de script utilisateur + Classe générale d'interface pour le stockage des paramètres externes """ def __init__(self, name = "GenericExternalParameters", @@ -1766,7 +1765,7 @@ class ExternalParameters(object): asDict = None, asScript = None, ): - "Mise a jour des parametres" + "Mise à jour des paramètres" if asDict is None and asScript is not None: __Dict = Interfaces.ImportFromScript(asScript).getvalue( self.__name, "ExternalParameters" ) else: diff --git a/src/daComposant/daCore/PlatformInfo.py b/src/daComposant/daCore/PlatformInfo.py index f37c23e..128cebb 100644 --- a/src/daComposant/daCore/PlatformInfo.py +++ b/src/daComposant/daCore/PlatformInfo.py @@ -279,6 +279,13 @@ def uniq( __sequence ): __seen = set() return [x for x in __sequence if x not in __seen and not __seen.add(x)] +def vt( __version ): + "Version transformée pour comparaison robuste, obtenue comme un tuple" + serie = [] + for sv in re.split("[_.+-]", __version): + serie.append(sv.zfill(6)) + return tuple(serie) + def isIterable( __sequence, __check = False, __header = "" ): """ Vérification que l'argument est un itérable interne.