From 38495c3345e3032c0ad0539dd749bc686ef8da24 Mon Sep 17 00:00:00 2001 From: Jean-Philippe ARGAUD Date: Wed, 23 Nov 2022 20:06:51 +0100 Subject: [PATCH] Minor documentation and code review corrections (34) --- doc/en/advanced.rst | 23 +++++++++++++++++-- ...thm_MeasurementsOptimalPositioningTask.rst | 3 +++ doc/en/snippets/ModuleCompatibility.rst | 20 ++++++++++++++++ doc/en/snippets/ModuleValidation.rst | 19 +++++++++++++++ doc/fr/advanced.rst | 22 ++++++++++++++++-- ...thm_MeasurementsOptimalPositioningTask.rst | 3 +++ doc/fr/snippets/ModuleCompatibility.rst | 20 ++++++++++++++++ doc/fr/snippets/ModuleValidation.rst | 20 ++++++++++++++++ src/daComposant/daAlgorithms/Atoms/ecweim.py | 2 +- .../MeasurementsOptimalPositioningTask.py | 5 ++++ src/daComposant/daCore/BasicObjects.py | 2 ++ src/daComposant/daCore/Interfaces.py | 5 +++- src/daComposant/daCore/Persistence.py | 21 +++++++++++++++++ 13 files changed, 159 insertions(+), 6 deletions(-) create mode 100644 doc/en/snippets/ModuleCompatibility.rst create mode 100644 doc/en/snippets/ModuleValidation.rst create mode 100644 doc/fr/snippets/ModuleCompatibility.rst create mode 100644 doc/fr/snippets/ModuleValidation.rst diff --git a/doc/en/advanced.rst b/doc/en/advanced.rst index 993cfc4..4716c30 100644 --- a/doc/en/advanced.rst +++ b/doc/en/advanced.rst @@ -582,13 +582,32 @@ convergence, even if they exist. These parameter adjustments are simple to implement, and it is favorable to try them (in twin experiments or not) because they solve many problems encountered in practice. + +.. _subsection_version_compatibility: +.. index:: + pair: Version ; SALOME + pair: Version ; EFICAS + pair: Version ; Python + pair: Version ; Numpy + pair: Version ; Scipy + pair: Version ; MatplotLib + pair: Version ; Gnuplot + pair: Version ; NLopt + +Versions of ADAO compatibility with support tools +------------------------------------------------- + +.. include:: snippets/ModuleValidation.rst + +.. include:: snippets/ModuleCompatibility.rst + .. _subsection_new_adao_version: +.. index:: + pair: Version of ADAO ; Switching Switching from a version of ADAO to a newer one ----------------------------------------------- -.. index:: single: Version - The ADAO module and its ".comm" case files are identified by versions, with "Major", "Minor", "Revision" and optionally "Installation" characteristics. A particular version is numbered as "Major.Minor.Revision", with strong link with diff --git a/doc/en/ref_algorithm_MeasurementsOptimalPositioningTask.rst b/doc/en/ref_algorithm_MeasurementsOptimalPositioningTask.rst index 80f25eb..3d025f4 100644 --- a/doc/en/ref_algorithm_MeasurementsOptimalPositioningTask.rst +++ b/doc/en/ref_algorithm_MeasurementsOptimalPositioningTask.rst @@ -85,6 +85,7 @@ StoreSupplementaryCalculations the following part of this specific algorithmic documentation, in the sub-section "*Information and variables available at the end of the algorithm*"): [ + "EnsembleOfSnapshots", "OptimalPoints", "ReducedBasis", "Residus", @@ -103,6 +104,8 @@ StoreSupplementaryCalculations .. ------------------------------------ .. .. include:: snippets/Header2Algo05.rst +.. include:: snippets/EnsembleOfSnapshots.rst + .. include:: snippets/OptimalPoints.rst .. include:: snippets/ReducedBasis.rst diff --git a/doc/en/snippets/ModuleCompatibility.rst b/doc/en/snippets/ModuleCompatibility.rst new file mode 100644 index 0000000..51b980e --- /dev/null +++ b/doc/en/snippets/ModuleCompatibility.rst @@ -0,0 +1,20 @@ +The compatibility of the module is furthermore checked against various versions +of Python and support modules like Numpy and Scipy. The range of versions +reached in the tests depends on their availability, and the tests are not +systematically performed on all intermediate versions. For all tested versions, +the ADAO module behaves identically (to the extent of modifications depending +on the support tools). It is strongly discouraged (or impossible) to use ADAO +with a version lower than the minimum version, and there is no limitation to +the use of the ADAO module beyond the reached version (but this remains without +guarantee). + +.. csv-table:: Support tool verification intervals for ADAO + :header: "Tool", "Minimal version", "Reached version" + :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 + MatplotLib, 2.2.2, 3.6.2 + GnuplotPy, 1.8, 1.8 + NLopt, 2.4.2, 2.7.1 diff --git a/doc/en/snippets/ModuleValidation.rst b/doc/en/snippets/ModuleValidation.rst new file mode 100644 index 0000000..67d02e1 --- /dev/null +++ b/doc/en/snippets/ModuleValidation.rst @@ -0,0 +1,19 @@ +Each version of the ADAO module is validated within the framework of SALOME, +and is therefore compatible with the environment implicitly defined by the +|release| version of SALOME identical to that of ADAO. The validation versions +are indicated here for information purposes only, knowing that, in case of +doubt, the SALOME version sheet [Salome]_ is the official validation version. + +.. csv-table:: Validation versions of support tools for ADAO + :header: "Tool", "Version" + :widths: 20, 10 + + ADAO, |release| + EFICAS, |release| + SALOME, |release| + Python, 3.6.5 + Numpy, 1.16.4 + Scipy, 1.4.1 + MatplotLib, 3.3.4 + Gnuplot, 1.8 + NLopt, 2.5.0 diff --git a/doc/fr/advanced.rst b/doc/fr/advanced.rst index 767dfab..e1068f5 100644 --- a/doc/fr/advanced.rst +++ b/doc/fr/advanced.rst @@ -634,13 +634,31 @@ sont simples à mettre en œuvre, et il est favorable de les essayer (en expériences jumelles ou pas) car ils résolvent de nombreux problèmes rencontrés en pratique. +.. _subsection_version_compatibility: +.. index:: + pair: Version ; SALOME + pair: Version ; EFICAS + pair: Version ; Python + pair: Version ; Numpy + pair: Version ; Scipy + pair: Version ; MatplotLib + pair: Version ; Gnuplot + pair: Version ; NLopt + +Versions de compatibilité d'ADAO avec les outils support +-------------------------------------------------------- + +.. include:: snippets/ModuleValidation.rst + +.. include:: snippets/ModuleCompatibility.rst + .. _subsection_new_adao_version: +.. index:: + pair: Version d'ADAO ; Changement de Passer d'une version d'ADAO à une nouvelle ------------------------------------------ -.. index:: single: Version - Le module ADAO et ses fichiers de cas ".comm" sont identifiés par des versions, avec des caractéristiques "Major", "Minor", "Revision" et optionnellement "Installation". Une version particulière est numérotée "Major.Minor.Revision", diff --git a/doc/fr/ref_algorithm_MeasurementsOptimalPositioningTask.rst b/doc/fr/ref_algorithm_MeasurementsOptimalPositioningTask.rst index c795791..71e3615 100644 --- a/doc/fr/ref_algorithm_MeasurementsOptimalPositioningTask.rst +++ b/doc/fr/ref_algorithm_MeasurementsOptimalPositioningTask.rst @@ -87,6 +87,7 @@ StoreSupplementaryCalculations (la description détaillée de chaque variable nommée est donnée dans la suite de cette documentation par algorithme spécifique, dans la sous-partie "*Informations et variables disponibles à la fin de l'algorithme*") : [ + "EnsembleOfSnapshots", "OptimalPoints", "ReducedBasis", "Residus", @@ -105,6 +106,8 @@ StoreSupplementaryCalculations .. ------------------------------------ .. .. include:: snippets/Header2Algo05.rst +.. include:: snippets/EnsembleOfSnapshots.rst + .. include:: snippets/OptimalPoints.rst .. include:: snippets/ReducedBasis.rst diff --git a/doc/fr/snippets/ModuleCompatibility.rst b/doc/fr/snippets/ModuleCompatibility.rst new file mode 100644 index 0000000..a53e952 --- /dev/null +++ b/doc/fr/snippets/ModuleCompatibility.rst @@ -0,0 +1,20 @@ +La compatibilité du module est de plus vérifiée par rapport à diverses versions +de Python et des modules support comme Numpy et Scipy. L'étendue des versions +atteintes lors des tests dépend de leur disponibilité, et les tests ne sont pas +systématiques sur toutes les versions intermédiaires. Pour toutes les versions +testées, le module ADAO se comporte de manière identique (dans la mesure de +modifications dépendant des outils support). Il est fortement déconseillé (ou +impossible) d'utiliser ADAO avec une version inférieure à la version minimale, +et il n'y a pas de limitation à l'utilisation du module ADAO au-delà au-delà de +la version atteinte (mais cela reste sans garantie). + +.. csv-table:: Intervalles de vérification des outils support pour ADAO + :header: "Outil", "Version minimale", "Version atteinte" + :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 + MatplotLib, 2.2.2, 3.6.2 + GnuplotPy, 1.8, 1.8 + NLopt, 2.4.2, 2.7.1 diff --git a/doc/fr/snippets/ModuleValidation.rst b/doc/fr/snippets/ModuleValidation.rst new file mode 100644 index 0000000..1fffbc3 --- /dev/null +++ b/doc/fr/snippets/ModuleValidation.rst @@ -0,0 +1,20 @@ +Chaque version du module ADAO est validée dans le cadre de SALOME, et elle est +donc compatible avec l'environnement implicitement défini par la version +|release| de SALOME identique à celle d'ADAO. Les versions de validation sont +indiquées ici pour information uniquement sachant que, en cas de doute, c'est +la fiche de version de SALOME [Salome]_ qui fait foi pour les versions +officielles de validation. + +.. csv-table:: Versions de validation des outils support pour ADAO + :header: "Outil", "Version" + :widths: 20, 10 + + ADAO, |release| + EFICAS, |release| + SALOME, |release| + Python, 3.6.5 + Numpy, 1.16.4 + Scipy, 1.4.1 + MatplotLib, 3.3.4 + Gnuplot, 1.8 + NLopt, 2.5.0 diff --git a/src/daComposant/daAlgorithms/Atoms/ecweim.py b/src/daComposant/daAlgorithms/Atoms/ecweim.py index 39e9f70..0c0a0df 100644 --- a/src/daComposant/daAlgorithms/Atoms/ecweim.py +++ b/src/daComposant/daAlgorithms/Atoms/ecweim.py @@ -40,7 +40,7 @@ def EIM_offline(selfA, Verbose = False): elif isinstance(selfA._parameters["EnsembleOfSnapshots"], (list,tuple)): __EOS = numpy.asarray(selfA._parameters["EnsembleOfSnapshots"]).T else: - raise ValueError("EnsembleOfSnapshots has to be an array/matrix (each column is a snapshot vector) or a list/tuple (each element is a snapshot vector).") + raise ValueError("EnsembleOfSnapshots has to be an array/matrix (each column being a vector) or a list/tuple (each element being a vector).") # if selfA._parameters["ErrorNorm"] == "L2": MaxNormByColumn = MaxL2NormByColumn diff --git a/src/daComposant/daAlgorithms/MeasurementsOptimalPositioningTask.py b/src/daComposant/daAlgorithms/MeasurementsOptimalPositioningTask.py index 346c12e..dd11eae 100644 --- a/src/daComposant/daAlgorithms/MeasurementsOptimalPositioningTask.py +++ b/src/daComposant/daAlgorithms/MeasurementsOptimalPositioningTask.py @@ -78,6 +78,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): typecast = tuple, message = "Liste de calculs supplémentaires à stocker et/ou effectuer", listval = [ + "EnsembleOfSnapshots", "OptimalPoints", "ReducedBasis", "Residus", @@ -97,12 +98,16 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): #-------------------------- if self._parameters["Variant"] == "PositioningBylcEIM": if len(self._parameters["EnsembleOfSnapshots"]) > 0: + if self._toStore("EnsembleOfSnapshots"): + self.StoredVariables["EnsembleOfSnapshots"].store( self._parameters["EnsembleOfSnapshots"] ) ecweim.EIM_offline(self) else: raise ValueError("Snapshots have to be given in order to launch the positionning analysis") # elif self._parameters["Variant"] == "PositioningByEIM": if len(self._parameters["EnsembleOfSnapshots"]) > 0: + if self._toStore("EnsembleOfSnapshots"): + self.StoredVariables["EnsembleOfSnapshots"].store( self._parameters["EnsembleOfSnapshots"] ) ecweim.EIM_offline(self) else: raise ValueError("Snapshots have to be given in order to launch the positionning analysis") diff --git a/src/daComposant/daCore/BasicObjects.py b/src/daComposant/daCore/BasicObjects.py index a82bb1a..50fd4b0 100644 --- a/src/daComposant/daCore/BasicObjects.py +++ b/src/daComposant/daCore/BasicObjects.py @@ -681,6 +681,7 @@ class Algorithm(object): - CurrentOptimum : état optimal courant lors d'itérations - CurrentState : état courant lors d'itérations - CurrentStepNumber : pas courant d'avancement dans les algorithmes en évolution, à partir de 0 + - EnsembleOfSnapshots : ensemble d'états rangés par colonne dans une matrice - ForecastCovariance : covariance de l'état prédit courant lors d'itérations - ForecastState : état prédit courant lors d'itérations - GradientOfCostFunctionJ : gradient de la fonction-coût globale @@ -742,6 +743,7 @@ class Algorithm(object): self.StoredVariables["CurrentOptimum"] = Persistence.OneVector(name = "CurrentOptimum") self.StoredVariables["CurrentState"] = Persistence.OneVector(name = "CurrentState") self.StoredVariables["CurrentStepNumber"] = Persistence.OneIndex(name = "CurrentStepNumber") + self.StoredVariables["EnsembleOfSnapshots"] = Persistence.OneMatrix(name = "EnsembleOfSnapshots") self.StoredVariables["ForecastCovariance"] = Persistence.OneMatrix(name = "ForecastCovariance") self.StoredVariables["ForecastState"] = Persistence.OneVector(name = "ForecastState") self.StoredVariables["GradientOfCostFunctionJ"] = Persistence.OneVector(name = "GradientOfCostFunctionJ") diff --git a/src/daComposant/daCore/Interfaces.py b/src/daComposant/daCore/Interfaces.py index 189508d..01cd5ce 100644 --- a/src/daComposant/daCore/Interfaces.py +++ b/src/daComposant/daCore/Interfaces.py @@ -405,6 +405,7 @@ class _SCDViewer(GenericCaseViewer): if __content is not None: for command in __content: self._append(*command) + # def _append(self, __command=None, __keys=None, __local=None, __pre=None, __switchoff=False): "Transformation d'une commande individuelle en un enregistrement" if __command == "set": __command = __local["Concept"] @@ -550,6 +551,7 @@ class _SCDViewer(GenericCaseViewer): if __text is not None: self._addLine(__text) if not __switchoff: self._switchoff = False + # def _finalize(self, *__args): self.__loadVariablesByScript() if self.__DebugCommandNotSet: @@ -562,6 +564,7 @@ class _SCDViewer(GenericCaseViewer): self._addLine("xa=ADD.get('Analysis')[-1]") self._addLine("print('Analysis:',xa)\"\"\"") self._addLine("study_config['UserPostAnalysis'] = Analysis_config") + # def __loadVariablesByScript(self): __ExecVariables = {} # Necessaire pour recuperer la variable exec("\n".join(self._lineSerie), __ExecVariables) @@ -611,7 +614,7 @@ class _YACSViewer(GenericCaseViewer): """ Etablissement des commandes d'un cas YACS (Cas->SCD->YACS) """ - __slots__ = ("__internalSCD") + __slots__ = ("__internalSCD", "_append") # def __init__(self, __name="", __objname="case", __content=None, __object=None): "Initialisation et enregistrement de l'entete" diff --git a/src/daComposant/daCore/Persistence.py b/src/daComposant/daCore/Persistence.py index 815b9b1..4e8950b 100644 --- a/src/daComposant/daCore/Persistence.py +++ b/src/daComposant/daCore/Persistence.py @@ -704,6 +704,27 @@ class Persistence(object): if pause: eval(input('Please press return to continue...\n')) + # --------------------------------------------------------- + def s2mvr(self): + """ + Renvoie la série sous la forme d'une unique matrice avec les données au + pas rangées par ligne + """ + try: + return numpy.asarray(self.__values) + except Exception: + raise TypeError("Base type is incompatible with numpy") + + def s2mvc(self): + """ + Renvoie la série sous la forme d'une unique matrice avec les données au + pas rangées par colonne + """ + try: + return numpy.asarray(self.__values).transpose() + except Exception: + raise TypeError("Base type is incompatible with numpy") + # --------------------------------------------------------- def setDataObserver(self, HookFunction = None, HookParameters = None, Scheduler = None): """ -- 2.39.2