From 46a3baf87fca696fb0adc5a5945c3c759d83fe26 Mon Sep 17 00:00:00 2001 From: Jean-Philippe ARGAUD Date: Thu, 9 Jul 2020 13:59:45 +0200 Subject: [PATCH] Documentation, comments and potential minor bug correction --- doc/fr/tui.rst | 2 +- .../Physical_simulation_functions.py | 12 +++---- src/daComposant/daCore/Aidsm.py | 13 +++++--- src/daComposant/daCore/BasicObjects.py | 2 +- src/daComposant/daCore/Interfaces.py | 31 ++++++++++++------- 5 files changed, 36 insertions(+), 24 deletions(-) diff --git a/doc/fr/tui.rst b/doc/fr/tui.rst index 592f398..33d4c34 100644 --- a/doc/fr/tui.rst +++ b/doc/fr/tui.rst @@ -304,7 +304,7 @@ fait soit lors de leur définition, soit lors de l'exécution. .. index:: single: Stored Dans chaque commande, le mot-clé booléen "*Stored*" permet d'indiquer si l'on -veut éventuellement la stocker la grandeur définie, pour en disposer en cours de +veut éventuellement stocker la grandeur définie, pour en disposer en cours de calcul ou en sortie. Le choix par défaut est de ne pas stocker, et il est recommandé de conserver cette valeur par défaut. En effet, pour un cas de calcul TUI, on dispose déjà souvent des grandeurs données en entrées qui sont présentes diff --git a/examples/daSkeletons/External_data_definition_by_scripts/Physical_simulation_functions.py b/examples/daSkeletons/External_data_definition_by_scripts/Physical_simulation_functions.py index a4b9516..f65ecab 100644 --- a/examples/daSkeletons/External_data_definition_by_scripts/Physical_simulation_functions.py +++ b/examples/daSkeletons/External_data_definition_by_scripts/Physical_simulation_functions.py @@ -37,14 +37,14 @@ import os, numpy, time def DirectOperator( XX ): """ Direct non-linear simulation operator """ # - # --------------------------------------> EXAMPLE TO BE REMOVED + # ------------------------------------------> EXAMPLE TO BE REMOVED if isinstance(XX, type(numpy.matrix([]))): # EXAMPLE TO BE REMOVED - HX = XX.A1.tolist() # EXAMPLE TO BE REMOVED + HX = XX.A1.tolist() # EXAMPLE TO BE REMOVED elif isinstance(XX, type(numpy.array([]))): # EXAMPLE TO BE REMOVED - HX = numpy.matrix(XX).A1.tolist() # EXAMPLE TO BE REMOVED - else: # EXAMPLE TO BE REMOVED - HX = XX # EXAMPLE TO BE REMOVED - # --------------------------------------> EXAMPLE TO BE REMOVED + HX = numpy.matrix(XX).A1.tolist() # EXAMPLE TO BE REMOVED + else: # EXAMPLE TO BE REMOVED + HX = numpy.ravel(XX) # EXAMPLE TO BE REMOVED + # ------------------------------------------> EXAMPLE TO BE REMOVED # return numpy.array( HX ) diff --git a/src/daComposant/daCore/Aidsm.py b/src/daComposant/daCore/Aidsm.py index 3a56565..ce8912d 100644 --- a/src/daComposant/daCore/Aidsm.py +++ b/src/daComposant/daCore/Aidsm.py @@ -50,6 +50,7 @@ class Aidsm(object): self.__PostAnalysis = [] # self.__Concepts = [ + self.__Concepts = [ # Liste exhaustive "AlgorithmParameters", "Background", "CheckingPoint", @@ -75,7 +76,7 @@ class Aidsm(object): self.__adaoObject[ename] = {} for ename in ("Observer",): self.__adaoObject[ename] = [] - self.__StoredInputs[ename] = [] + self.__StoredInputs[ename] = [] # Vide par defaut self.__StoredInputs["Name"] = self.__name self.__StoredInputs["Directory"] = self.__directory # @@ -516,10 +517,12 @@ class Aidsm(object): Concept = "RegulationParameters" self.__case.register("set"+Concept, dir(), locals()) self.__adaoObject[Concept] = RegulationAndParameters( - name = Concept, - asAlgorithm = Algorithm, - asDict = Parameters, - asScript = self.__with_directory(Script), + name = Concept, + asAlgorithm = Algorithm, + asDict = Parameters, + asScript = self.__with_directory(Script), + ) + return 0 ) return 0 diff --git a/src/daComposant/daCore/BasicObjects.py b/src/daComposant/daCore/BasicObjects.py index dee9c53..71d3549 100644 --- a/src/daComposant/daCore/BasicObjects.py +++ b/src/daComposant/daCore/BasicObjects.py @@ -1333,7 +1333,7 @@ class RegulationAndParameters(object): self.__P.update( dict(__Dict) ) # if __Algo is not None: - self.__P.update( {"Algorithm":__Algo} ) + self.__P.update( {"Algorithm":str(__Algo)} ) def get(self, key = None): "Vérifie l'existence d'une clé de variable ou de paramètres" diff --git a/src/daComposant/daCore/Interfaces.py b/src/daComposant/daCore/Interfaces.py index 47164d8..4b31c32 100644 --- a/src/daComposant/daCore/Interfaces.py +++ b/src/daComposant/daCore/Interfaces.py @@ -39,7 +39,7 @@ from daCore import Templates # ============================================================================== class GenericCaseViewer(object): """ - Gestion des commandes de creation d'une vue de cas + Gestion des commandes de création d'une vue de cas """ def __init__(self, __name="", __objname="case", __content=None, __object=None): "Initialisation et enregistrement de l'entete" @@ -52,10 +52,10 @@ class GenericCaseViewer(object): self._object = __object self._missing = """raise ValueError("This case requires beforehand to import or define the variable named <%s>. When corrected, remove this command, correct and uncomment the following one.")\n# """ def _append(self, *args): - "Transformation de commande individuelle en enregistrement" + "Transformation d'une commande individuelle en un enregistrement" raise NotImplementedError() def _extract(self, *args): - "Transformation d'enregistrement en commande individuelle" + "Transformation d'enregistrement(s) en commande(s) individuelle(s)" raise NotImplementedError() def _finalize(self, __upa=None): "Enregistrement du final" @@ -93,7 +93,7 @@ class GenericCaseViewer(object): class _TUIViewer(GenericCaseViewer): """ - Etablissement des commandes d'un cas ADAO TUI (Cas<->TUI) + Établissement des commandes d'un cas ADAO TUI (Cas<->TUI) """ def __init__(self, __name="", __objname="case", __content=None, __object=None): "Initialisation et enregistrement de l'entete" @@ -137,7 +137,7 @@ class _TUIViewer(GenericCaseViewer): __text += ")" self._addLine(__text) def _extract(self, __multilines="", __object=None): - "Transformation un enregistrement en une commande individuelle" + "Transformation d'enregistrement(s) en commande(s) individuelle(s)" __is_case = False __commands = [] __multilines = __multilines.replace("\r\n","\n") @@ -156,7 +156,7 @@ class _TUIViewer(GenericCaseViewer): class _COMViewer(GenericCaseViewer): """ - Etablissement des commandes d'un cas COMM (Eficas Native Format/Cas<-COM) + Établissement des commandes d'un cas COMM (Eficas Native Format/Cas<-COM) """ def __init__(self, __name="", __objname="case", __content=None, __object=None): "Initialisation et enregistrement de l'entete" @@ -171,10 +171,12 @@ class _COMViewer(GenericCaseViewer): for command in self._content: self._append(*command) def _extract(self, __multilines=None, __object=None): - "Transformation un enregistrement en une commande individuelle" + "Transformation d'enregistrement(s) en commande(s) individuelle(s)" if __multilines is not None: - __multilines = __multilines.replace("ASSIMILATION_STUDY","dict") - __multilines = __multilines.replace("CHECKING_STUDY", "dict") + if "ASSIMILATION_STUDY" in __multilines: + __multilines = __multilines.replace("ASSIMILATION_STUDY","dict") + if "CHECKING_STUDY" in __multilines: + __multilines = __multilines.replace("CHECKING_STUDY", "dict") __multilines = __multilines.replace("_F(", "dict(") __multilines = __multilines.replace(",),);", ",),)") __fulllines = "" @@ -199,6 +201,10 @@ class _COMViewer(GenericCaseViewer): __commands.append( "set( Concept='Name', String='%s')"%(str(r),) ) elif __command == "StudyRepertory": __commands.append( "set( Concept='Directory', String='%s')"%(str(r),) ) + elif __command == "Debug" and str(r) == "0": + __commands.append( "set( Concept='NoDebug' )" ) + elif __command == "Debug" and str(r) == "1": + __commands.append( "set( Concept='Debug' )" ) # elif __command == "UserPostAnalysis" and type(r) is dict: if 'STRING' in r: @@ -291,10 +297,12 @@ class _COMViewer(GenericCaseViewer): class _SCDViewer(GenericCaseViewer): """ - Etablissement des commandes d'un cas SCD (Study Config Dictionary/Cas->SCD) + Établissement des commandes d'un cas SCD (Study Config Dictionary/Cas->SCD) + + Remarque : le fichier généré est différent de celui obtenu par EFICAS """ def __init__(self, __name="", __objname="case", __content=None, __object=None): - "Initialisation et enregistrement de l'entete" + "Initialisation et enregistrement de l'entête" GenericCaseViewer.__init__(self, __name, __objname, __content, __object) self._addLine("# -*- coding: utf-8 -*-") self._addLine("#\n# Input for ADAO converter to YACS\n#") @@ -363,6 +371,7 @@ class _SCDViewer(GenericCaseViewer): if __k == "Concept": continue if __k in ['ScalarSparseMatrix','DiagonalSparseMatrix','Matrix','OneFunction','ThreeFunctions'] and 'Script' in __local and __local['Script'] is not None: continue if __k in ['Vector','VectorSerie'] and 'DataFile' in __local and __local['DataFile'] is not None: continue + if __k == 'Parameters' and not (__command in ['AlgorithmParameters','SupplementaryParameters']): continue if __k == 'Algorithm': __text += "study_config['Algorithm'] = %s\n"%(repr(__v)) elif __k == 'DataFile': -- 2.39.2