Salome HOME
Code improvements, review and simplifications (2)
[modules/adao.git] / src / daComposant / daCore / Aidsm.py
index 79ddef25c1c5e5507d76078c734340055ada8027..3aa0c20e835bb64958b4f7425609d10f8971fa9b 100644 (file)
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2008-2021 EDF R&D
+# Copyright (C) 2008-2022 EDF R&D
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -78,6 +78,10 @@ class Aidsm(object):
             self.__adaoObject[ename] = None
         for ename in ("ObservationOperator", "EvolutionModel", "ControlModel"):
             self.__adaoObject[ename] = {}
+        for ename in ("BackgroundError", "ObservationError"):
+            self.__adaoObject[ename] = Covariance(ename, asEyeByScalar = 1.)
+        for ename in ("EvolutionError",):
+            self.__adaoObject[ename] = Covariance(ename, asEyeByScalar = 1.e-16)
         for ename in ("Observer", "UserPostAnalysis"):
             self.__adaoObject[ename]   = []
             self.__StoredInputs[ename] = [] # Vide par defaut
@@ -95,7 +99,6 @@ class Aidsm(object):
             Concept              = None, # Premier argument
             Algorithm            = None,
             AppliedInXb          = None,
-            AvoidRC              = True,
             Checked              = False,
             ColMajor             = False,
             ColNames             = None,
@@ -109,6 +112,7 @@ class Aidsm(object):
             ObjectMatrix         = None,
             OneFunction          = None,
             Parameters           = None,
+            PerformanceProfile   = None,
             ScalarSparseMatrix   = None,
             Scheduler            = None,
             Script               = None,
@@ -152,20 +156,20 @@ class Aidsm(object):
                 self.setObservationOperator(
                     Matrix, OneFunction, ThreeFunctions, AppliedInXb,
                     Parameters, Script, ExtraArguments,
-                    Stored, AvoidRC, InputFunctionAsMulti, Checked )
+                    Stored, PerformanceProfile, InputFunctionAsMulti, Checked )
             elif Concept in ("EvolutionModel", "ControlModel"):
                 commande = getattr(self,"set"+Concept)
                 commande(
                     Matrix, OneFunction, ThreeFunctions,
                     Parameters, Script, Scheduler, ExtraArguments,
-                    Stored, AvoidRC, InputFunctionAsMulti, Checked )
+                    Stored, PerformanceProfile, InputFunctionAsMulti, Checked )
             else:
                 raise ValueError("the variable named '%s' is not allowed."%str(Concept))
         except Exception as e:
-            if isinstance(e, SyntaxError): msg = "at %s: %s"%(e.offset, e.text)
+            if isinstance(e, SyntaxError): msg = " at %s: %s"%(e.offset, e.text)
             else: msg = ""
             raise ValueError(("during settings, the following error occurs:\n"+\
-                              "\n%s %s\n\nSee also the potential messages, "+\
+                              "\n%s%s\n\nSee also the potential messages, "+\
                               "which can show the origin of the above error, "+\
                               "in the launching terminal.")%(str(e),msg))
 
@@ -364,7 +368,7 @@ class Aidsm(object):
             Script               = None,
             ExtraArguments       = None,
             Stored               = False,
-            AvoidRC              = True,
+            PerformanceProfile   = None,
             InputFunctionAsMulti = False,
             Checked              = False):
         "Definition d'un concept de calcul"
@@ -379,7 +383,7 @@ class Aidsm(object):
             asDict           = Parameters,
             appliedInX       = AppliedInXb,
             extraArguments   = ExtraArguments,
-            avoidRC          = AvoidRC,
+            performancePrf   = PerformanceProfile,
             inputAsMF        = InputFunctionAsMulti,
             scheduledBy      = None,
             toBeChecked      = Checked,
@@ -397,7 +401,7 @@ class Aidsm(object):
             Scheduler            = None,
             ExtraArguments       = None,
             Stored               = False,
-            AvoidRC              = True,
+            PerformanceProfile   = None,
             InputFunctionAsMulti = False,
             Checked              = False):
         "Definition d'un concept de calcul"
@@ -412,7 +416,7 @@ class Aidsm(object):
             asDict           = Parameters,
             appliedInX       = None,
             extraArguments   = ExtraArguments,
-            avoidRC          = AvoidRC,
+            performancePrf   = PerformanceProfile,
             inputAsMF        = InputFunctionAsMulti,
             scheduledBy      = Scheduler,
             toBeChecked      = Checked,
@@ -430,7 +434,7 @@ class Aidsm(object):
             Scheduler            = None,
             ExtraArguments       = None,
             Stored               = False,
-            AvoidRC              = True,
+            PerformanceProfile   = None,
             InputFunctionAsMulti = False,
             Checked              = False):
         "Definition d'un concept de calcul"
@@ -445,7 +449,7 @@ class Aidsm(object):
             asDict           = Parameters,
             appliedInX       = None,
             extraArguments   = ExtraArguments,
-            avoidRC          = AvoidRC,
+            performancePrf   = PerformanceProfile,
             inputAsMF        = InputFunctionAsMulti,
             scheduledBy      = Scheduler,
             toBeChecked      = Checked,
@@ -622,6 +626,7 @@ class Aidsm(object):
             asString    = String,
             asScript    = self.__with_directory(Script),
             )))
+        return 0
 
     # -----------------------------------------------------------
 
@@ -763,9 +768,9 @@ class Aidsm(object):
         self.__adaoObject["AlgorithmParameters"].executePythonScheme( self.__adaoObject )
         if "UserPostAnalysis" in self.__adaoObject and len(self.__adaoObject["UserPostAnalysis"])>0:
             self.__objname = self.__retrieve_objname()
-            __Upa = map(str, self.__adaoObject["UserPostAnalysis"])
-            __Upa = eval("\n".join(__Upa))
-            exec(__Upa, {}, {'self':self, 'ADD':self, 'case':self, 'adaopy':self, self.__objname:self})
+            for __UpaOne in self.__adaoObject["UserPostAnalysis"]:
+                __UpaOne = eval(str(__UpaOne))
+                exec(__UpaOne, {}, {'self':self, 'ADD':self, 'case':self, 'adaopy':self, self.__objname:self})
         return 0
 
     def __executeYACSScheme(self, FileName=None):
@@ -825,9 +830,8 @@ class Aidsm(object):
         for level in reversed(inspect.stack()):
             __names += [name for name, value in level.frame.f_locals.items() if value is self]
         __names += [name for name, value in globals().items() if value is self]
-        __names.remove('self') # Devrait toujours être trouvé, donc pas d'erreur
+        while 'self' in __names: __names.remove('self') # Devrait toujours être trouvé, donc pas d'erreur
         if len(__names) > 0:
-            logging.debug("Cet objet est appelé par au moins une variable :",__names)
             self.__objname = __names[0]
         else:
             self.__objname = "ADD"