From: Jean-Philippe ARGAUD Date: Sun, 8 Mar 2020 18:59:52 +0000 (+0100) Subject: Update and documentation of InputValuesTest X-Git-Tag: V9_5_0a2~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=087028cb881b07298c2b68bf8b2c080dff09a042;p=modules%2Fadao.git Update and documentation of InputValuesTest --- diff --git a/doc/en/ref_algorithm_FunctionTest.rst b/doc/en/ref_algorithm_FunctionTest.rst index c41eccb..91072d8 100644 --- a/doc/en/ref_algorithm_FunctionTest.rst +++ b/doc/en/ref_algorithm_FunctionTest.rst @@ -35,10 +35,12 @@ correctly and that its call is compatible with its usage in ADAO algorithms. In practice, it allows to call one or several times the operator, activating or not the "debug" mode during execution. -Statistics on input and output vectors for each execution of operator are given, -and an another global statistic is given at the end of the checking algorithm. -The precision of printed outputs can be controlled to facilitate automatic tests -of operator. +Statistics on input and output vectors for each execution of operator are +given, and an another global statistic is given at the end of the checking +algorithm. The precision of printed outputs can be controlled to facilitate +automatic tests of operator. It may also be useful to check the entries +themselves beforehand with the intended test +:ref:`section_ref_algorithm_InputValuesTest`. .. ------------------------------------ .. .. include:: snippets/Header2Algo02.rst @@ -87,5 +89,6 @@ StoreSupplementaryCalculations .. ------------------------------------ .. .. include:: snippets/Header2Algo06.rst +- :ref:`section_ref_algorithm_InputValuesTest` - :ref:`section_ref_algorithm_LinearityTest` - :ref:`section_ref_algorithm_ParallelFunctionTest` diff --git a/doc/en/ref_algorithm_InputValuesTest.rst b/doc/en/ref_algorithm_InputValuesTest.rst new file mode 100644 index 0000000..a3fb845 --- /dev/null +++ b/doc/en/ref_algorithm_InputValuesTest.rst @@ -0,0 +1,74 @@ +.. + Copyright (C) 2008-2020 EDF R&D + + This file is part of SALOME ADAO module. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com + + Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D + +.. index:: single: InputValuesTest +.. _section_ref_algorithm_InputValuesTest: + +Checking algorithm "*InputValuesTest*" +-------------------------------------- + +.. ------------------------------------ .. +.. include:: snippets/Header2Algo00.rst + +.. ------------------------------------ .. +.. include:: snippets/Header2Algo01.rst + +This algorithm verifies the content of the current input variables and the way +the data is interpreted or read during its acquisition, through the display of +size information and statistics on the inputs. It also allows to display the +whole content of the variables read in printed form for verification (*warning, +if a variable is large in size, this can be difficult*). + +.. ------------------------------------ .. +.. include:: snippets/Header2Algo02.rst + +.. include:: snippets/Background.rst + +.. include:: snippets/CheckingPoint.rst + +.. include:: snippets/Observation.rst + +*Tips for this algorithm:* + + Because *"ObservationOperator"* is a required command for ALL checking + algorithms in the graphical interface, you have to provide a value for it, + despite the fact that this command is not required for this test, and will + not be used. The easiest way is to give "1" as a STRING, + *"ObservationOperator"* having to be of type *Matrix*. + +.. ------------------------------------ .. +.. include:: snippets/Header2Algo03Chck.rst + +.. include:: snippets/NumberOfPrintedDigits.rst + +.. include:: snippets/PrintAllValuesFor.rst + +.. include:: snippets/ShowInformationOnlyFor.rst + +.. include:: snippets/SetDebug.rst + +.. ------------------------------------ .. +.. include:: snippets/Header2Algo06.rst + +- :ref:`section_ref_algorithm_FunctionTest` +- :ref:`section_ref_algorithm_ParallelFunctionTest` diff --git a/doc/en/ref_algorithm_ObserverTest.rst b/doc/en/ref_algorithm_ObserverTest.rst index 8b2f4a3..545a752 100644 --- a/doc/en/ref_algorithm_ObserverTest.rst +++ b/doc/en/ref_algorithm_ObserverTest.rst @@ -47,6 +47,6 @@ indicated in :ref:`section_ref_assimilation_keywords`. Because *"CheckingPoint"* and *"ObservationOperator"* are required commands for ALL checking algorithms in the interface, you have to provide a value - for them, despite the fact that these commands are not required for - *"ObserverTest"*, and will not be used. The easiest way is to give "1" as a - STRING for both, *"ObservationOperator"* having to be of type *Matrix*. + for them, despite the fact that these commands are not required for this + test, and will not be used. The easiest way is to give "1" as a STRING for + both, *"ObservationOperator"* having to be of type *Matrix*. diff --git a/doc/en/ref_algorithm_ParallelFunctionTest.rst b/doc/en/ref_algorithm_ParallelFunctionTest.rst index a16f883..f274da4 100644 --- a/doc/en/ref_algorithm_ParallelFunctionTest.rst +++ b/doc/en/ref_algorithm_ParallelFunctionTest.rst @@ -35,10 +35,12 @@ correctly in parallel and that its call is compatible with its usage in ADAO algorithms. In practice, it allows to call one or several times the operator in parallel, activating or not the "debug" mode during execution. -Statistics on input and output vectors for each execution of operator are given, -and an another global statistic is given at the end of the checking algorithm. -The precision of printed outputs can be controlled to facilitate automatic tests -of operator. +Statistics on input and output vectors for each execution of operator are +given, and an another global statistic is given at the end of the checking +algorithm. The precision of printed outputs can be controlled to facilitate +automatic tests of operator. It may also be useful to check the entries +themselves beforehand with the intended test +:ref:`section_ref_algorithm_InputValuesTest`. .. ------------------------------------ .. .. include:: snippets/Header2Algo02.rst @@ -88,4 +90,5 @@ StoreSupplementaryCalculations .. include:: snippets/Header2Algo06.rst - :ref:`section_ref_algorithm_FunctionTest` +- :ref:`section_ref_algorithm_InputValuesTest` - :ref:`section_ref_algorithm_LinearityTest` diff --git a/doc/en/ref_entry_types.rst b/doc/en/ref_entry_types.rst index 4fb1cf9..f8fbd19 100644 --- a/doc/en/ref_entry_types.rst +++ b/doc/en/ref_entry_types.rst @@ -34,6 +34,10 @@ computationaly. These pseudo-types explicitly represent mathematical forms :ref:`section_notations` are also used, together with :ref:`section_ref_entry_types_names`. +The explicit :ref:`section_ref_algorithm_InputValuesTest` test is designed so +that the user can specifically check some entries, with the same analysis and +criteria as during the usual setup of a study. + .. _section_ref_entry_types_math: Pseudo-types of mathematical representation of data diff --git a/doc/en/reference.rst b/doc/en/reference.rst index 3e48ba2..6f92201 100644 --- a/doc/en/reference.rst +++ b/doc/en/reference.rst @@ -134,6 +134,7 @@ The mathematical notations used afterward are explained in the section ref_algorithm_AdjointTest ref_algorithm_FunctionTest ref_algorithm_GradientTest + ref_algorithm_InputValuesTest ref_algorithm_LinearityTest ref_algorithm_LocalSensitivityTest ref_algorithm_ObserverTest diff --git a/doc/en/snippets/PrintAllValuesFor.rst b/doc/en/snippets/PrintAllValuesFor.rst new file mode 100644 index 0000000..9d0f0a8 --- /dev/null +++ b/doc/en/snippets/PrintAllValuesFor.rst @@ -0,0 +1,14 @@ +.. index:: single: PrintAllValuesFor + +PrintAllValuesFor + This key indicates the list of vector names whose detailed values are to be + printed, the default value being the empty list. If the named vector is not a + supplied entry, the name is simply ignored. The possible names are in the + following list: [ + "Background", + "CheckingPoint", + "Observation", + ]. + + Exemple : + ``{"PrintAllValuesFor":["Background"]}`` diff --git a/doc/en/snippets/ShowInformationOnlyFor.rst b/doc/en/snippets/ShowInformationOnlyFor.rst new file mode 100644 index 0000000..aabe3db --- /dev/null +++ b/doc/en/snippets/ShowInformationOnlyFor.rst @@ -0,0 +1,15 @@ +.. index:: single: ShowInformationOnlyFor + +ShowInformationOnlyFor + This key indicates the list of vector names whose summarized information + (size, min/max...) is to be printed, the default value being the set of + vectors. If the named vector is not a provided entry, the name is simply + ignored. This allows you to restrict summarized printing. The possible names + are in the following list: [ + "Background", + "CheckingPoint", + "Observation", + ]. + + Exemple : + ``{"ShowInformationOnlyFor":["Background"]}`` diff --git a/doc/fr/ref_algorithm_FunctionTest.rst b/doc/fr/ref_algorithm_FunctionTest.rst index 8d8ea47..0ec22a2 100644 --- a/doc/fr/ref_algorithm_FunctionTest.rst +++ b/doc/fr/ref_algorithm_FunctionTest.rst @@ -40,7 +40,8 @@ Une statistique sur les vecteurs en entrée et en sortie de chaque exécution de l'opérateur est indiquée, et une autre globale est fournie de manière récapitulative à la fin de l'algorithme de vérification. La précision d'affichage est contrôlable pour permettre l'automatisation des tests -d'opérateur. +d'opérateur. Il peut être aussi utile de vérifier préalablement les entrées +elles-mêmes avec le test prévu :ref:`section_ref_algorithm_InputValuesTest`. .. ------------------------------------ .. .. include:: snippets/Header2Algo02.rst @@ -89,5 +90,6 @@ StoreSupplementaryCalculations .. ------------------------------------ .. .. include:: snippets/Header2Algo06.rst +- :ref:`section_ref_algorithm_InputValuesTest` - :ref:`section_ref_algorithm_LinearityTest` - :ref:`section_ref_algorithm_ParallelFunctionTest` diff --git a/doc/fr/ref_algorithm_InputValuesTest.rst b/doc/fr/ref_algorithm_InputValuesTest.rst new file mode 100644 index 0000000..38a13d1 --- /dev/null +++ b/doc/fr/ref_algorithm_InputValuesTest.rst @@ -0,0 +1,77 @@ +.. + Copyright (C) 2008-2020 EDF R&D + + This file is part of SALOME ADAO module. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com + + Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D + +.. index:: single: InputValuesTest +.. _section_ref_algorithm_InputValuesTest: + +Algorithme de vérification "*InputValuesTest*" +---------------------------------------------- + +.. ------------------------------------ .. +.. include:: snippets/Header2Algo00.rst + +.. ------------------------------------ .. +.. include:: snippets/Header2Algo01.rst + +Cet algorithme permet de vérifier le contenu des variables d'entrée courantes +et la manière dont les données sont interprétées ou lues lors de leur +acquisition, à travers l'affichage des informations de taille et des +statistique sur les entrées. Il permet aussi de restituer la totalité du +contenu des variables lues sous forme imprimée pour vérification (*attention, +si une variable est de grande taille, cette restitution peut être +informatiquement problématique*). + +.. ------------------------------------ .. +.. include:: snippets/Header2Algo02.rst + +.. include:: snippets/Background.rst + +.. include:: snippets/CheckingPoint.rst + +.. include:: snippets/Observation.rst + +*Astuce pour cet algorithme :* + + Comme la commande *"ObservationOperator"* est requise pour TOUS les + algorithmes de vérification dans l'interface graphique, vous devez fournir + une valeur, malgré le fait que cette commandes ne soit pas nécessaires pour + cet test, et ne soit donc pas utilisée. La manière la plus simple est de + donner "1" comme un STRING, l'*"ObservationOperator"* devant être de type + *Matrix*. + +.. ------------------------------------ .. +.. include:: snippets/Header2Algo03Chck.rst + +.. include:: snippets/NumberOfPrintedDigits.rst + +.. include:: snippets/PrintAllValuesFor.rst + +.. include:: snippets/ShowInformationOnlyFor.rst + +.. include:: snippets/SetDebug.rst + +.. ------------------------------------ .. +.. include:: snippets/Header2Algo06.rst + +- :ref:`section_ref_algorithm_FunctionTest` +- :ref:`section_ref_algorithm_ParallelFunctionTest` diff --git a/doc/fr/ref_algorithm_ObserverTest.rst b/doc/fr/ref_algorithm_ObserverTest.rst index b9ff6c3..c6f314e 100644 --- a/doc/fr/ref_algorithm_ObserverTest.rst +++ b/doc/fr/ref_algorithm_ObserverTest.rst @@ -49,6 +49,6 @@ sont indiquées dans la :ref:`section_ref_checking_keywords`. Comme les commandes *"CheckingPoint"* et *"ObservationOperator"* sont requises pour TOUS les algorithmes de vérification dans l'interface, vous devez fournir une valeur, malgré le fait que ces commandes ne soient pas - nécessaires pour cet algorithme, et ne sont donc pas utilisées. La manière - la plus simple est de donner "1" comme un STRING pour les deux, + nécessaires pour ce test, et ne sont donc pas utilisées. La manière la plus + simple est de donner "1" comme un STRING pour les deux, l'*"ObservationOperator"* devant être de type *Matrix*. diff --git a/doc/fr/ref_algorithm_ParallelFunctionTest.rst b/doc/fr/ref_algorithm_ParallelFunctionTest.rst index 46046cc..56429f7 100644 --- a/doc/fr/ref_algorithm_ParallelFunctionTest.rst +++ b/doc/fr/ref_algorithm_ParallelFunctionTest.rst @@ -40,7 +40,8 @@ Une statistique sur les vecteurs en entrée et en sortie de chaque exécution de l'opérateur est indiquée, et une autre globale est fournie de manière récapitulative à la fin de l'algorithme de vérification. La précision d'affichage est contrôlable pour permettre l'automatisation des tests -d'opérateur. +d'opérateur. Il peut être aussi utile de vérifier préalablement les entrées +elles-mêmes avec le test prévu :ref:`section_ref_algorithm_InputValuesTest`. .. ------------------------------------ .. .. include:: snippets/Header2Algo02.rst @@ -90,4 +91,5 @@ StoreSupplementaryCalculations .. include:: snippets/Header2Algo06.rst - :ref:`section_ref_algorithm_FunctionTest` +- :ref:`section_ref_algorithm_InputValuesTest` - :ref:`section_ref_algorithm_LinearityTest` diff --git a/doc/fr/ref_entry_types.rst b/doc/fr/ref_entry_types.rst index 40049ce..fc2c023 100644 --- a/doc/fr/ref_entry_types.rst +++ b/doc/fr/ref_entry_types.rst @@ -34,6 +34,10 @@ simples (:ref:`section_ref_entry_types_info`), que l'on détaille ici. On utilise aussi les :ref:`section_notations`, en même temps que les :ref:`section_ref_entry_types_names`. +Le test explicite :ref:`section_ref_algorithm_InputValuesTest` est prévu pour +que l'utilisateur puisse vérifier spécifiquement certaines entrées, avec les +mêmes analyses et critères que lors de la mise en place usuelle d'une étude. + .. _section_ref_entry_types_math: Pseudo-types de représentation mathématique des données diff --git a/doc/fr/reference.rst b/doc/fr/reference.rst index 2d57133..645d6bf 100644 --- a/doc/fr/reference.rst +++ b/doc/fr/reference.rst @@ -135,6 +135,7 @@ section :ref:`section_theory`. ref_algorithm_AdjointTest ref_algorithm_FunctionTest ref_algorithm_GradientTest + ref_algorithm_InputValuesTest ref_algorithm_LinearityTest ref_algorithm_LocalSensitivityTest ref_algorithm_ObserverTest diff --git a/doc/fr/snippets/PrintAllValuesFor.rst b/doc/fr/snippets/PrintAllValuesFor.rst new file mode 100644 index 0000000..018d975 --- /dev/null +++ b/doc/fr/snippets/PrintAllValuesFor.rst @@ -0,0 +1,14 @@ +.. index:: single: PrintAllValuesFor + +PrintAllValuesFor + Cette clé indique la liste des noms de vecteurs dont les valeurs détaillées + sont à imprimer, la valeur par défaut étant la liste vide. Si le vecteur + nommé n'est pas une entrée fournie, le nom est simplement ignoré. Les noms + possibles sont dans la liste suivante : [ + "Background", + "CheckingPoint", + "Observation", + ]. + + Exemple : + ``{"PrintAllValuesFor":["Background"]}`` diff --git a/doc/fr/snippets/ShowInformationOnlyFor.rst b/doc/fr/snippets/ShowInformationOnlyFor.rst new file mode 100644 index 0000000..953c7b9 --- /dev/null +++ b/doc/fr/snippets/ShowInformationOnlyFor.rst @@ -0,0 +1,15 @@ +.. index:: single: ShowInformationOnlyFor + +ShowInformationOnlyFor + Cette clé indique la liste des noms de vecteurs dont les informations + synthétiques (taille, min/max...) sont à imprimer, la valeur par défaut étant + l'ensemble des vecteurs. Si le vecteur nommé n'est pas une entrée fournie, le + nom est simplement ignoré. Cela permet de restreindre les impressions + synthétiques. Les noms possibles sont dans la liste suivante : [ + "Background", + "CheckingPoint", + "Observation", + ]. + + Exemple : + ``{"ShowInformationOnlyFor":["Background"]}`` diff --git a/src/daComposant/daAlgorithms/InputValuesTest.py b/src/daComposant/daAlgorithms/InputValuesTest.py index 9a1dff7..6f2c60f 100644 --- a/src/daComposant/daAlgorithms/InputValuesTest.py +++ b/src/daComposant/daAlgorithms/InputValuesTest.py @@ -36,10 +36,21 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): minval = 0, ) self.defineRequiredParameter( - name = "PrintValuesFor", + name = "PrintAllValuesFor", default = [], typecast = tuple, - message = "Liste de vecteurs dont les valeurs sont à imprimer", + message = "Liste de noms de vecteurs dont les valeurs détaillées sont à imprimer", + listval = [ + "Background", + "CheckingPoint", + "Observation", + ] + ) + self.defineRequiredParameter( + name = "ShowInformationOnlyFor", + default = ["Background", "CheckingPoint", "Observation"], + typecast = tuple, + message = "Liste de noms de vecteurs dont les informations synthétiques sont à imprimer", listval = [ "Background", "CheckingPoint", @@ -63,12 +74,15 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): numpy.set_printoptions(precision=_p) # def __buildPrintableVectorProperties( __name, __vector ): - if __vector is None: return "" - if len(__vector) == 0: return "" - if hasattr(__vector,"name") and __name != __vector.name(): - return "" + if __vector is None: return "" + if len(__vector) == 0: return "" + if hasattr(__vector,"name") and __name != __vector.name(): return "" + if __name not in self._parameters["ShowInformationOnlyFor"]: return "" # - __title = "Information for %svector:"%(str(__name)+" ",) + if hasattr(__vector,"mins"): + __title = "Information for %svector series:"%(str(__name)+" ",) + else: + __title = "Information for %svector:"%(str(__name)+" ",) msgs = "\n" msgs += ("===> "+__title+"\n") msgs += (" "+("-"*len(__title))+"\n") @@ -94,7 +108,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): msgs += (" Serie of maximum values...: %s\n")%numpy.array(__vector.maxs()) else: msgs += (" Maximum of vector.........: %12."+str(_p)+"e\n")%__vector.max() - if self._parameters["SetDebug"] or __name in self._parameters["PrintValuesFor"]: + if self._parameters["SetDebug"] or __name in self._parameters["PrintAllValuesFor"]: msgs += ("\n") msgs += (" Printing all values :\n") msgs += ("%s"%(__vector,)) diff --git a/src/daComposant/daCore/BasicObjects.py b/src/daComposant/daCore/BasicObjects.py index 5d0e610..9535f5b 100644 --- a/src/daComposant/daCore/BasicObjects.py +++ b/src/daComposant/daCore/BasicObjects.py @@ -753,7 +753,7 @@ class Algorithm(object): _EI = numpy.diag(1./numpy.sqrt(numpy.diag(_A))) _C = numpy.dot(_EI, numpy.dot(_A, _EI)) self.StoredVariables["APosterioriCorrelations"].store( _C ) - if _oH is not None: + if _oH is not None and "Direct" in _oH and "Tangent" in _oH and "Adjoint" in _oH: logging.debug("%s Nombre d'évaluation(s) de l'opérateur d'observation direct/tangent/adjoint.: %i/%i/%i", self._name, _oH["Direct"].nbcalls(0),_oH["Tangent"].nbcalls(0),_oH["Adjoint"].nbcalls(0)) logging.debug("%s Nombre d'appels au cache d'opérateur d'observation direct/tangent/adjoint..: %i/%i/%i", self._name, _oH["Direct"].nbcalls(3),_oH["Tangent"].nbcalls(3),_oH["Adjoint"].nbcalls(3)) logging.debug("%s Taille mémoire utilisée de %.0f Mio", self._name, self._m.getUsedMemory("Mio"))