From 44b072259be9a96e6aa4a5988c7f641a9779d9c7 Mon Sep 17 00:00:00 2001 From: Jean-Philippe ARGAUD Date: Tue, 31 Jan 2023 06:12:15 +0100 Subject: [PATCH] Minor documentation and code review corrections (40) --- doc/en/notations.rst | 32 ++++++++++++------- doc/en/ref_algorithm_AdjointTest.rst | 2 +- doc/en/ref_algorithm_FunctionTest.rst | 4 ++- doc/en/ref_algorithm_SamplingTest.rst | 3 ++ doc/en/scripts/simple_KalmanFilter1.py | 2 +- doc/en/snippets/Header2Algo09.rst | 2 +- doc/en/snippets/ModuleCompatibility.rst | 4 +-- doc/fr/ref_algorithm_FunctionTest.rst | 3 +- ...thm_MeasurementsOptimalPositioningTask.rst | 4 +-- doc/fr/ref_algorithm_SamplingTest.rst | 3 ++ doc/fr/scripts/simple_KalmanFilter1.py | 2 +- doc/fr/snippets/ModuleCompatibility.rst | 4 +-- .../daAlgorithms/LocalSensitivityTest.py | 4 +-- src/daComposant/daAlgorithms/SamplingTest.py | 8 +++-- src/daComposant/daCore/BasicObjects.py | 2 +- src/daComposant/daCore/PlatformInfo.py | 5 ++- 16 files changed, 53 insertions(+), 31 deletions(-) diff --git a/doc/en/notations.rst b/doc/en/notations.rst index 539f3bd..de7c1a6 100644 --- a/doc/en/notations.rst +++ b/doc/en/notations.rst @@ -26,24 +26,29 @@ Notations and common conventions ================================ +.. index:: single: File (naming) +.. index:: single: File (type) + In all this documentation, we use standard notations of linear algebra, data assimilation (as described in [Ide97]_) and optimization. -For algebraic formulations, vectors are written horizontally or vertically -without making a difference. Matrices are written either normally, or with a -condensed notation, consisting in the use of a space to separate the values, -and a "``;``" to separate the rows of the matrix, in a continuous line. +For algebraic formulations, **vectors** are written horizontally or vertically +without making a difference. **Matrices** can be written either normally as a +serie of number series, either in text condensed notation, consisting in the +use of a space to separate the values, and a "``;``" to separate the rows of +the matrix, in a continuous line. -Files can be indicated by an absolute or relative path. For some old or shared -file systems, the full name with the path must not contain more than 256 -characters. In the case of Python files, it is advisable not to use dots in the -name apart for the extension, to prevent difficulties in using it that are -complicated to diagnose. +**Files** can be indicated by an absolute or relative path. For some old or +shared file systems, the full name, including the path, must not contain more +than 256 characters. In the case of Python files, it is advisable not to use +dots in the name apart for the extension, to prevent difficulties in using it +that are then complicated to diagnose. -File type and naming conventions rely heavily on the extensions of the files -themselves. Some of them are briefly specified here, without being exhaustive: +**File type and naming conventions** rely heavily on the extensions of the +files themselves. Some of them are briefly specified here, without being +exhaustive: -- extension ``.py`` : data or commands text file of Python source type +- extension ``.py`` : data or commands text file of Python type - extension ``.comm`` : commands text file of ADAO EFICAS type - extension ``.xml`` : data text file of XML type or commands (for YACS, not exclusive) - extension ``.txt`` : data text file with space separator @@ -54,6 +59,9 @@ themselves. Some of them are briefly specified here, without being exhaustive: - extension ``.npz`` : data binary file of type Numpy multi-variables - extension ``.sdf`` : data binary file of type Scientific Data Format +For the use of some of these files, one can refer to the keyword "*DataFile*" +as :ref:`section_ref_entry_types_info`. + .. ------------------------------------ .. .. include:: snippets/Header2Algo07.rst diff --git a/doc/en/ref_algorithm_AdjointTest.rst b/doc/en/ref_algorithm_AdjointTest.rst index d18f962..07d899f 100644 --- a/doc/en/ref_algorithm_AdjointTest.rst +++ b/doc/en/ref_algorithm_AdjointTest.rst @@ -38,7 +38,7 @@ For all formulas, with :math:`\mathbf{x}` the current verification point, we take :math:`\mathbf{dx}_0=Normal(0,\mathbf{x})` and :math:`\mathbf{dx}=\alpha_0*\mathbf{dx}_0` with :math:`\alpha_0` a scaling user parameter, defaulting to 1. :math:`F` is the computational operator or code -(which is here acquired by the observation operator command +(which is here defined by the observation operator command "*ObservationOperator*"). One can observe the following residue, which is the difference of two scalar diff --git a/doc/en/ref_algorithm_FunctionTest.rst b/doc/en/ref_algorithm_FunctionTest.rst index 3b57c3e..81755ae 100644 --- a/doc/en/ref_algorithm_FunctionTest.rst +++ b/doc/en/ref_algorithm_FunctionTest.rst @@ -33,7 +33,9 @@ Checking algorithm "*FunctionTest*" This algorithm allows to verify that a given operator :math:`F`, in particular the observation one, is working 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. +times the operator, activating or not the "debug" mode during execution. The +:math:`F` operator is considered to depend on the vector variable +:math:`\mathbf{x}`. 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 diff --git a/doc/en/ref_algorithm_SamplingTest.rst b/doc/en/ref_algorithm_SamplingTest.rst index 63fbcee..a978e7f 100644 --- a/doc/en/ref_algorithm_SamplingTest.rst +++ b/doc/en/ref_algorithm_SamplingTest.rst @@ -103,6 +103,7 @@ StoreSupplementaryCalculations "CurrentState", "EnsembleOfSimulations", "EnsembleOfStates", + "Innovation", "InnovationAtCurrentState", "SimulatedObservationAtCurrentState", ]. @@ -134,6 +135,8 @@ StoreSupplementaryCalculations .. include:: snippets/EnsembleOfStates.rst +.. include:: snippets/Innovation.rst + .. include:: snippets/InnovationAtCurrentState.rst .. include:: snippets/SimulatedObservationAtCurrentState.rst diff --git a/doc/en/scripts/simple_KalmanFilter1.py b/doc/en/scripts/simple_KalmanFilter1.py index 4910a21..eba52d5 100644 --- a/doc/en/scripts/simple_KalmanFilter1.py +++ b/doc/en/scripts/simple_KalmanFilter1.py @@ -44,7 +44,7 @@ Xa = case.get("Analysis") Pa = case.get("APosterioriCovariance") # print("") -print(" Final a posteriori variance:",Pa[-1]) +print(" Final a posteriori variance:", Pa[-1]) print("") # #------------------------------------------------------------------------------- diff --git a/doc/en/snippets/Header2Algo09.rst b/doc/en/snippets/Header2Algo09.rst index 5ad6b83..0024c9d 100644 --- a/doc/en/snippets/Header2Algo09.rst +++ b/doc/en/snippets/Header2Algo09.rst @@ -3,4 +3,4 @@ Python (TUI) use examples Here is a very simple use of the given algorithm and its parameters, written in :ref:`section_tui`, and from which input information allow to define an -equivalent cas in graphical interface. +equivalent case in graphical user interface. diff --git a/doc/en/snippets/ModuleCompatibility.rst b/doc/en/snippets/ModuleCompatibility.rst index 2acdc40..1fb912a 100644 --- a/doc/en/snippets/ModuleCompatibility.rst +++ b/doc/en/snippets/ModuleCompatibility.rst @@ -12,8 +12,8 @@ guarantee). :header: "Tool", "Minimal version", "Reached version" :widths: 20, 10, 10 - Python, 3.6.5, 3.10.8 - Numpy, 1.14.3, 1.24.1 + Python, 3.6.5, 3.10.9 + Numpy, 1.14.3, 1.24.2 Scipy, 1.1.0, 1.10.0 MatplotLib, 2.2.2, 3.6.3 GnuplotPy, 1.8, 1.8 diff --git a/doc/fr/ref_algorithm_FunctionTest.rst b/doc/fr/ref_algorithm_FunctionTest.rst index 34599b5..c1c8fc7 100644 --- a/doc/fr/ref_algorithm_FunctionTest.rst +++ b/doc/fr/ref_algorithm_FunctionTest.rst @@ -34,7 +34,8 @@ Cet algorithme permet de vérifier qu'un opérateur :math:`F` quelconque, dont e particulier celui d'observation, fonctionne correctement et que son appel se déroule de manière compatible avec son usage dans les algorithmes d'ADAO. De manière pratique, il permet d'appeler une ou plusieurs fois l'opérateur, en -activant ou non le mode "debug" lors de l'exécution. +activant ou non le mode "debug" lors de l'exécution. L'opérateur :math:`F` est +considéré comme dépendant d'une variable vectorielle :math:`\mathbf{x}`. 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 diff --git a/doc/fr/ref_algorithm_MeasurementsOptimalPositioningTask.rst b/doc/fr/ref_algorithm_MeasurementsOptimalPositioningTask.rst index c53d924..b862906 100644 --- a/doc/fr/ref_algorithm_MeasurementsOptimalPositioningTask.rst +++ b/doc/fr/ref_algorithm_MeasurementsOptimalPositioningTask.rst @@ -58,8 +58,8 @@ Il y a deux manières d'utiliser cet algorithme: #. Dans son usage le plus simple, si l'ensemble des vecteurs d'état est pré-existant, il suffit de le fournir par l'option "*EnsembleOfSnapshots*" - d'algorithme. C'est par exemple le cas l'ensemble des états a été généré par - un :ref:`section_ref_algorithm_EnsembleOfSimulationGenerationTask`. + d'algorithme. C'est par exemple le cas si l'ensemble des états a été généré + par un :ref:`section_ref_algorithm_EnsembleOfSimulationGenerationTask`. #. Si l'ensemble des vecteurs d'état doit être obtenu par des simulations au cours de l'algorithme, alors on doit fournir l'opérateur de simulation ou d'observation :math:`H` et le plan d'expérience de l'espace des états diff --git a/doc/fr/ref_algorithm_SamplingTest.rst b/doc/fr/ref_algorithm_SamplingTest.rst index f4bae25..7d7553f 100644 --- a/doc/fr/ref_algorithm_SamplingTest.rst +++ b/doc/fr/ref_algorithm_SamplingTest.rst @@ -106,6 +106,7 @@ StoreSupplementaryCalculations "CurrentState", "EnsembleOfSimulations", "EnsembleOfStates", + "Innovation", "InnovationAtCurrentState", "SimulatedObservationAtCurrentState", ]. @@ -137,6 +138,8 @@ StoreSupplementaryCalculations .. include:: snippets/EnsembleOfStates.rst +.. include:: snippets/Innovation.rst + .. include:: snippets/InnovationAtCurrentState.rst .. include:: snippets/SimulatedObservationAtCurrentState.rst diff --git a/doc/fr/scripts/simple_KalmanFilter1.py b/doc/fr/scripts/simple_KalmanFilter1.py index c81d2a5..b8425a7 100644 --- a/doc/fr/scripts/simple_KalmanFilter1.py +++ b/doc/fr/scripts/simple_KalmanFilter1.py @@ -44,7 +44,7 @@ Xa = case.get("Analysis") Pa = case.get("APosterioriCovariance") # print("") -print(" Variance a posteriori finale :",Pa[-1]) +print(" Variance a posteriori finale :", Pa[-1]) print("") # #------------------------------------------------------------------------------- diff --git a/doc/fr/snippets/ModuleCompatibility.rst b/doc/fr/snippets/ModuleCompatibility.rst index 06d4ce4..cbe7325 100644 --- a/doc/fr/snippets/ModuleCompatibility.rst +++ b/doc/fr/snippets/ModuleCompatibility.rst @@ -12,8 +12,8 @@ la version atteinte (mais cela reste sans garantie). :header: "Outil", "Version minimale", "Version atteinte" :widths: 20, 10, 10 - Python, 3.6.5, 3.10.8 - Numpy, 1.14.3, 1.24.1 + Python, 3.6.5, 3.10.9 + Numpy, 1.14.3, 1.24.2 Scipy, 1.1.0, 1.10.0 MatplotLib, 2.2.2, 3.6.3 GnuplotPy, 1.8, 1.8 diff --git a/src/daComposant/daAlgorithms/LocalSensitivityTest.py b/src/daComposant/daAlgorithms/LocalSensitivityTest.py index 2578746..89f5962 100644 --- a/src/daComposant/daAlgorithms/LocalSensitivityTest.py +++ b/src/daComposant/daAlgorithms/LocalSensitivityTest.py @@ -81,9 +81,9 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): HXb = Ht @ Xb HXb = numpy.ravel( HXb ).reshape((-1,1)) if Y.size != HXb.size: - raise ValueError("The size %i of observations Y and %i of observed calculation H(X) are different, they have to be identical."%(Y.size,HXb.size)) + raise ValueError("The size %i of observations Yobs and %i of observed calculation F(X) are different, they have to be identical."%(Y.size,HXb.size)) if max(Y.shape) != max(HXb.shape): - raise ValueError("The shapes %s of observations Y and %s of observed calculation H(X) are different, they have to be identical."%(Y.shape,HXb.shape)) + raise ValueError("The shapes %s of observations Yobs and %s of observed calculation F(X) are different, they have to be identical."%(Y.shape,HXb.shape)) self.StoredVariables["SimulatedObservationAtCurrentState"].store( HXb ) # self._post_run(HO) diff --git a/src/daComposant/daAlgorithms/SamplingTest.py b/src/daComposant/daAlgorithms/SamplingTest.py index 4f543d2..0d7c577 100644 --- a/src/daComposant/daAlgorithms/SamplingTest.py +++ b/src/daComposant/daAlgorithms/SamplingTest.py @@ -21,10 +21,9 @@ # Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D import numpy, logging -from daCore import BasicObjects, NumericObjects +from daCore import BasicObjects, NumericObjects, PlatformInfo from daAlgorithms.Atoms import eosg -from daCore.PlatformInfo import PlatformInfo -mfp = PlatformInfo().MaximumPrecision() +mfp = PlatformInfo.PlatformInfo().MaximumPrecision() # ============================================================================== class ElementaryAlgorithm(BasicObjects.Algorithm): @@ -90,6 +89,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): "CurrentState", "EnsembleOfSimulations", "EnsembleOfStates", + "Innovation", "InnovationAtCurrentState", "SimulatedObservationAtCurrentState", ] @@ -147,6 +147,8 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): Jo = numpy.max( numpy.abs(_Innovation) ) # J = Jb + Jo + if self._toStore("Innovation"): + self.StoredVariables["Innovation"].store( _Innovation ) if self._toStore("CurrentState"): self.StoredVariables["CurrentState"].store( _X ) if self._toStore("InnovationAtCurrentState"): diff --git a/src/daComposant/daCore/BasicObjects.py b/src/daComposant/daCore/BasicObjects.py index eefbea3..acddc35 100644 --- a/src/daComposant/daCore/BasicObjects.py +++ b/src/daComposant/daCore/BasicObjects.py @@ -976,7 +976,7 @@ class Algorithm(object): except Exception: raise KeyError(msg) - def run(self, Xb=None, Y=None, H=None, M=None, R=None, B=None, Q=None, Parameters=None): + def run(self, Xb=None, Y=None, U=None, HO=None, EM=None, CM=None, R=None, B=None, Q=None, Parameters=None): """ Doit implémenter l'opération élémentaire de calcul algorithmique. """ diff --git a/src/daComposant/daCore/PlatformInfo.py b/src/daComposant/daCore/PlatformInfo.py index 128cebb..7279509 100644 --- a/src/daComposant/daCore/PlatformInfo.py +++ b/src/daComposant/daCore/PlatformInfo.py @@ -122,7 +122,10 @@ class PlatformInfo(object): __msg += "\n%s%30s : %s" %(__prefix,"sys.executable",sys.executable) __msg += "\n%s%30s : %s" %(__prefix,"sys.version",sys.version.replace('\n','')) __msg += "\n%s%30s : %s" %(__prefix,"sys.getfilesystemencoding",str(sys.getfilesystemencoding())) - __msg += "\n%s%30s : %s" %(__prefix,"locale.getdefaultlocale",str(locale.getdefaultlocale())) + if sys.version_info.major == 3 and sys.version_info.minor < 11: # Python 3.10 + __msg += "\n%s%30s : %s" %(__prefix,"locale.getdefaultlocale",str(locale.getdefaultlocale())) + else: + __msg += "\n%s%30s : %s" %(__prefix,"locale.getlocale",str(locale.getlocale())) __msg += "\n" __msg += "\n%s%30s : %s" %(__prefix,"os.cpu_count",os.cpu_count()) if hasattr(os, 'sched_getaffinity'): -- 2.39.2