From faf16db36f26f278244dd86bae11b6696afdfcfb Mon Sep 17 00:00:00 2001 From: Jean-Philippe ARGAUD Date: Sun, 4 Jun 2017 23:24:59 +0200 Subject: [PATCH] Python 3 compatibility improvement (doc) --- doc/en/advanced.rst | 21 +++++++++------------ doc/en/bibliography.rst | 2 +- doc/en/conf.py | 4 +--- doc/en/license.rst | 2 +- doc/en/tui.rst | 41 +++++++++++++++++++++-------------------- 5 files changed, 33 insertions(+), 37 deletions(-) diff --git a/doc/en/advanced.rst b/doc/en/advanced.rst index 4a20a4f..71bf56e 100644 --- a/doc/en/advanced.rst +++ b/doc/en/advanced.rst @@ -55,7 +55,7 @@ command (see YACS documentation for more information). In all launching command Shell files examples, we choose to start and stop the SALOME application server in the same script. It is not mandatory, but it is -useful to avoid stalling SALOME sessions. +useful to avoid stalling SALOME sessions. The simplest example consist in only launching the given YACS sheme, which was previously generated by the user in the graphical interface. In this case, after @@ -149,10 +149,10 @@ load the types catalog to avoid weird difficulties:: xmlLoader = loader.YACSLoader() xmlLoader.registerProcCataLoader() try: - catalogAd = r.loadCatalog("proc", "") + catalogAd = r.loadCatalog("proc", "") + r.addCatalog(catalogAd) except: - pass - r.addCatalog(catalogAd) + pass try: p = xmlLoader.load("") @@ -196,7 +196,6 @@ in SALOME by launching the R interpreter in the shell "``salome shell``". Moreover, the package "*rPython*" has to be available, it can be installed by the user if required by the following R command:: - #-*-coding:iso-8859-1-*- # # IMPORTANT: to be run in R interpreter # ------------------------------------- @@ -212,7 +211,6 @@ and information from R. The approach is illustrated in the example In the R interpreter, one can run the following commands, directly coming from the simple example:: - #-*-coding:iso-8859-1-*- # # IMPORTANT: to be run in R interpreter # ------------------------------------- @@ -246,7 +244,6 @@ above example to use data from R to feed the three variables of background, observation and observation operator. We get in the end the optimal state also in a R variable. The other lines are identical. The example thus becomes:: - #-*-coding:iso-8859-1-*- # # IMPORTANT: to be run in R interpreter # ------------------------------------- @@ -302,16 +299,16 @@ Getting information on special variables during the ADAO calculation in YACS .. index:: single: Observer Template Some special internal optimization variables, used during calculations, can be -monitored during the ADAO calculation. These variables can be printed, -plotted, saved, etc. This can be done using "*observer*", that are scripts, -each associated with one variable. +monitored during the ADAO calculation. These variables can be printed, plotted, +saved, etc. This can be done using "*observer*", that are commands gathered in +scripts, each associated with one variable. Some templates are available when editing the ADAO case in graphical editor. These simple scripts can be customized by the user, either at the embedded edition stage, or at the edition stage before execution, to improve the tuning of the ADAO calculation. -To implement these "*observer*" efficiently, one can look to the +To implement these "*observer*" efficiently, one can look to the :ref:`ref_observers_requirements`. Getting more information when running a calculation @@ -341,7 +338,7 @@ following Python lines:: logging.getLogger().setLevel(logging.DEBUG) The standard logging module default level is "*WARNING*", the default level in -the ADAO module is "*INFO*". +the ADAO module is "*INFO*". It is also recommended to include some logging or debug mechanisms in the simulation code, and use them in conjunction with the two previous methods. But diff --git a/doc/en/bibliography.rst b/doc/en/bibliography.rst index 4e261ae..cfd786b 100644 --- a/doc/en/bibliography.rst +++ b/doc/en/bibliography.rst @@ -33,7 +33,7 @@ Bibliography .. [Bouttier99] Bouttier B., Courtier P., *Data assimilation concepts and methods*, Meteorological Training Course Lecture Series, ECMWF, 1999 -.. [Bocquet04] Bocquet M., *Introduction aux principes et méthodes de l'assimilation de données en géophysique*, Lecture Notes, 2014 +.. [Bocquet04] Bocquet M., *Introduction aux principes et méthodes de l'assimilation de données en géophysique*, Lecture Notes, 2014 .. [Buchinsky98] Buchinsky M., *Recent Advances in Quantile Regression Models: A Practical Guidline for Empirical Research*, Journal of Human Resources, 33(1), pp.88-126, 1998 diff --git a/doc/en/conf.py b/doc/en/conf.py index dd97d53..e5c2326 100644 --- a/doc/en/conf.py +++ b/doc/en/conf.py @@ -55,7 +55,7 @@ templates_path = ['_templates'] source_suffix = '.rst' # The encoding of source files. -#source_encoding = 'utf-8' +source_encoding = 'utf-8' # The master toctree document. master_doc = 'index' @@ -219,8 +219,6 @@ latex_documents = [ # If false, no module index is generated. #latex_use_modindex = True -source_encoding = 'iso-8859-15' - # -- Options for Epub output --------------------------------------------------- # Bibliographic Dublin Core info. diff --git a/doc/en/license.rst b/doc/en/license.rst index 19a41b7..d1fc4da 100644 --- a/doc/en/license.rst +++ b/doc/en/license.rst @@ -61,7 +61,7 @@ one of the references given below: * *ADAO, a SALOME module for Data Assimilation and Optimization*, http://www.salome-platform.org/ - * *ADAO, un module SALOME pour l'Assimilation de Données et l'Aide à + * *ADAO, un module SALOME pour l'Assimilation de Données et l'Aide à l'Optimisation*, http://www.salome-platform.org/ * *SALOME The Open Source Integration Platform for Numerical Simulation*, diff --git a/doc/en/tui.rst b/doc/en/tui.rst index 6aa00b9..8565054 100644 --- a/doc/en/tui.rst +++ b/doc/en/tui.rst @@ -204,12 +204,12 @@ for a detailed description on this subject. For instance, we give some script lines that allow to get the number of iterations of the optimization and the optimal value, and its size:: - print - print " Number of iterations :", len(case.get("CostFunctionJ")) + print("") + print(" Number of iterations : %i"%len(case.get("CostFunctionJ"))) Xa = case.get("Analysis") - print " Optimal analysis :", Xa[-1] - print " Size of the analysis :", len(Xa[-1]) - print + print(" Optimal analysis : %s"%(Xa[-1],)) + print(" Size of the analysis : %i"%len(Xa[-1])) + print("") These lines can be very simply added to the initial example of ADAO TUI calculation case given in :ref:`subsection_tui_example`. @@ -469,15 +469,16 @@ Setting the calculation, outputs, etc. .. index:: single: setObserver **setObserver** (*Variable, Template, String, Script, Info*) - This command allows to set an *observer* on the current or final calculation - variable. Reference should be made to the description of the - ':ref:`ref_observers_requirements` for their list and content, and to the - :ref:`section_reference` to know what are the observable quantities. One - defines as "*String*" the *observer* body, using a string including if - necessary line breaks. It is recommended to use the patterns available by - the argument "*Template*". In the case of a definition as "*Script*", the - file must contain only the body of the function, as described in the - :ref:`ref_observers_requirements`. + This command allows to set an *observer* on the current or final + calculation variable. Reference should be made to the description of the + ':ref:`ref_observers_requirements` for their list and content, and to the + :ref:`section_reference` to know what are the observable quantities. One + defines as "*String*" the *observer* body, using a string including if + necessary line breaks. It is recommended to use the patterns available by + the argument "*Template*". In the case of a definition as "*Script*", the + file must contain only the body of the function, as described in the + :ref:`ref_observers_requirements`. The "*Info*" variable contains an + information string or can be void. Perform the calculation +++++++++++++++++++++++ @@ -607,12 +608,12 @@ The set of commands that can be used is the following:: Xoptimum = case.get("Analysis")[-1] FX_at_optimum = case.get("SimulatedObservationAtOptimum")[-1] J_values = case.get("CostFunctionJ")[:] - print - print "Number of internal iterations...: %i"%len(J_values) - print "Initial state...................:",numpy.ravel(Xbackground) - print "Optimal state...................:",numpy.ravel(Xoptimum) - print "Simulation at optimal state.....:",numpy.ravel(FX_at_optimum) - print + print("") + print("Number of internal iterations...: %i"%len(J_values)) + print("Initial state...................: %s"%(numpy.ravel(Xbackground),)) + print("Optimal state...................: %s"%(numpy.ravel(Xoptimum),)) + print("Simulation at optimal state.....: %s"%(numpy.ravel(FX_at_optimum),)) + print("") The command set execution gives the following result:: -- 2.39.2