]> SALOME platform Git repositories - modules/adao.git/commitdiff
Salome HOME
Correction of Python 3 compatibility and examples
authorJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Sat, 6 Oct 2018 18:17:47 +0000 (20:17 +0200)
committerJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Sat, 6 Oct 2018 18:17:47 +0000 (20:17 +0200)
22 files changed:
examples/daSalome/test001_ADAO_JDC_using_strings.comm
examples/daSalome/test001_ADAO_JDC_using_strings.py
examples/daSalome/test002_ADAO_JDC_using_strings.comm
examples/daSalome/test002_ADAO_JDC_using_strings.py
examples/daSalome/test003_ADAO_JDC_using_scripts.comm.in
examples/daSalome/test003_ADAO_JDC_using_scripts.py.in
examples/daSalome/test003_bis_ADAO_JDC_using_user_data_init.comm.in
examples/daSalome/test003_bis_ADAO_JDC_using_user_data_init.py.in
examples/daSalome/test004_ADAO_JDC_using_scripts.comm.in
examples/daSalome/test004_ADAO_JDC_using_scripts.py.in
examples/daSalome/test005_ADAO_Operators.comm.in
examples/daSalome/test005_ADAO_Operators.py.in
examples/daSalome/test006_Observers.comm.in
examples/daSalome/test006_Observers.py.in
examples/daSkeletons/External_data_definition_by_scripts/Physical_simulation_functions.py
resources/ADAOSchemaCatalog.xml
src/daComposant/daCore/Interfaces.py
src/daComposant/daCore/Persistence.py
src/daComposant/daCore/PlatformInfo.py
src/daSalome/__init__.py
src/daSalome/adaoBuilder.py
src/daSalome/daYacsSchemaCreator/methods.py

index d8771a43db5ef133a3835f011347c18e3720420e..515b363978a31de629620d7830d2ac551bce184d 100644 (file)
@@ -21,5 +21,5 @@ ASSIMILATION_STUDY(StudyName='Test',
                                        ValueTemplate=
                                                   """import numpy
 xa=numpy.ravel(ADD.get('Analysis')[-1])
-print 'Analysis:',xa""",),);
-#VERSION_CATALOGUE:V8_3_0:FIN VERSION_CATALOGUE
\ No newline at end of file
+print('Analysis:',xa)""",),);
+#VERSION_CATALOGUE:V8_3_0:FIN VERSION_CATALOGUE
index 1d5955a409beacb557a0a843626c92c019df96cf..a703907f9930dacf5c29dc84a3b043747a2d1097 100644 (file)
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-study_config = {} 
+study_config = {}
 study_config['StudyType'] = 'ASSIMILATION_STUDY'
 study_config['Name'] = 'Test'
 study_config['Debug'] = '0'
@@ -41,5 +41,5 @@ Analysis_config = {}
 Analysis_config['From'] = 'String'
 Analysis_config['Data'] = """import numpy
 xa=numpy.ravel(ADD.get('Analysis')[-1])
-print 'Analysis:',xa"""
+print('Analysis:',xa)"""
 study_config['UserPostAnalysis'] = Analysis_config
index 72bf03167f5a69d321ccaddb1224da72a2c32122..9948538c87228dd2c89e9654c71a9466d21a2f9a 100644 (file)
@@ -21,5 +21,5 @@ ASSIMILATION_STUDY(StudyName='Test',
                                        ValueTemplate=
                                                   """import numpy
 xa=numpy.ravel(ADD.get('Analysis')[-1])
-print 'Analysis:',xa""",),);
+print('Analysis:',xa)""",),);
 #VERSION_CATALOGUE:V8_3_0:FIN VERSION_CATALOGUE
index 83b3e1260eb43290d1a092e0d99c73e54aae9e6e..6c640d59b1e25bee1cb0ce6eee9c48d84c5b1a9a 100644 (file)
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-study_config = {} 
+study_config = {}
 study_config['StudyType'] = 'ASSIMILATION_STUDY'
 study_config['Name'] = 'Test'
 study_config['Debug'] = '0'
@@ -41,5 +41,5 @@ Analysis_config = {}
 Analysis_config['From'] = 'String'
 Analysis_config['Data'] = """import numpy
 xa=numpy.ravel(ADD.get('Analysis')[-1])
-print 'Analysis:',xa"""
+print('Analysis:',xa)"""
 study_config['UserPostAnalysis'] = Analysis_config
index 929fc7712635a1b38ceac083cbb22e211620d349..6aa71852ab6c359b41c1075f5b1fe8ad7e721a42 100644 (file)
@@ -22,5 +22,5 @@ ASSIMILATION_STUDY(StudyName='Test',
                                        ValueTemplate=
                                                   """import numpy
 xa=numpy.ravel(ADD.get('Analysis')[-1])
-print 'Analysis:',xa""",),);
+print('Analysis:',xa)""",),);
 #VERSION_CATALOGUE:V8_3_0:FIN VERSION_CATALOGUE
index 56dfe2bd0b85a8c6181dee79d50e45034d08cbde..76ec3aa66591411c82316c2bf4af2dc9aafa8f28 100644 (file)
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-study_config = {} 
+study_config = {}
 study_config['StudyType'] = 'ASSIMILATION_STUDY'
 study_config['Name'] = 'Test'
 study_config['Debug'] = '0'
@@ -42,5 +42,5 @@ Analysis_config = {}
 Analysis_config['From'] = 'String'
 Analysis_config['Data'] = """import numpy
 xa=numpy.ravel(ADD.get('Analysis')[-1])
-print 'Analysis:',xa"""
+print('Analysis:',xa)"""
 study_config['UserPostAnalysis'] = Analysis_config
index 15263b5ecefda1936e53d228d7913a5f2c9c29f4..04e4f70c81b4c100ea0b95c679f74f5a69c95474 100644 (file)
@@ -26,5 +26,5 @@ ASSIMILATION_STUDY(StudyName='Test',
                                        ValueTemplate=
                                                   """import numpy
 xa=numpy.ravel(ADD.get('Analysis')[-1])
-print 'Analysis:',xa""",),);
+print('Analysis:',xa)""",),);
 #VERSION_CATALOGUE:V8_3_0:FIN VERSION_CATALOGUE
index f44ed367090672d56890b330641b5f6b54d17d70..ee7b68fceb364d82a035bd325e865b4493f57759 100644 (file)
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-study_config = {} 
+study_config = {}
 study_config['StudyType'] = 'ASSIMILATION_STUDY'
 study_config['Name'] = 'Test'
 study_config['Debug'] = '0'
@@ -42,7 +42,7 @@ Analysis_config = {}
 Analysis_config['From'] = 'String'
 Analysis_config['Data'] = """import numpy
 xa=numpy.ravel(ADD.get('Analysis')[-1])
-print 'Analysis:',xa"""
+print('Analysis:',xa)"""
 study_config['UserPostAnalysis'] = Analysis_config
 Init_config = {}
 Init_config['Type'] = 'Dict'
index 0f5a50a29ffb1bd15ff4b9235deabba1e715a371..d4393708cae6b583936c0d738faac2474b5d6c4c 100644 (file)
@@ -21,9 +21,9 @@ ASSIMILATION_STUDY(StudyName='Test',
                                        STRING=
 """import numpy
 Xa = ADD.get("Analysis")[-1]
-print
-print "Size of Analysis = %i"%len(Xa)
-print "Min, mean, max   = %8.3f, %8.3f, %8.3f"%(min(Xa),numpy.mean(Xa),max(Xa))
-print
+print()
+print("Size of Analysis = %i"%len(Xa))
+print("Min, mean, max   = %8.3f, %8.3f, %8.3f"%(min(Xa),numpy.mean(Xa),max(Xa)))
+print()
 """,),);
 #VERSION_CATALOGUE:V8_3_0:FIN VERSION_CATALOGUE
index a2a7f3c5f86604912c37305c23b89e6dcc7e3f58..e164ff89832ca2a6c1267f752e3ccad88f49618d 100644 (file)
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-study_config = {} 
+study_config = {}
 study_config['StudyType'] = 'ASSIMILATION_STUDY'
 study_config['Name'] = 'Test'
 study_config['Debug'] = '0'
@@ -42,9 +42,9 @@ Analysis_config = {}
 Analysis_config['From'] = 'String'
 Analysis_config['Data'] = """import numpy
 Xa = ADD.get("Analysis")[-1]
-print
-print "Size of Analysis = %i"%len(Xa)
-print "Min, mean, max   = %8.3f, %8.3f, %8.3f"%(min(Xa),numpy.mean(Xa),max(Xa))
-print
+print()
+print("Size of Analysis = %i"%len(Xa))
+print("Min, mean, max   = %8.3f, %8.3f, %8.3f"%(min(Xa),numpy.mean(Xa),max(Xa)))
+print()
 """
 study_config['UserPostAnalysis'] = Analysis_config
index 8e8117a84d13852cc27eda7564599f49f71e29df..06b365cee102323b98f64fa160b95909c5127fc0 100644 (file)
@@ -27,10 +27,10 @@ ASSIMILATION_STUDY(StudyName='Test',
 """import numpy
 Xb = ADD.get("Background")
 Xa = ADD.get("Analysis")[-1]
-print
-print "Size of Background...........= %i"%len(Xb.A1)
-print "Size of Analysis.............= %i"%len(Xa)
-print "Min, mean, max of Analysis...= %8.3f, %8.3f, %8.3f"%(min(Xa),numpy.mean(Xa),max(Xa))
-print
+print()
+print("Size of Background...........= %i"%len(Xb.A1))
+print("Size of Analysis.............= %i"%len(Xa))
+print("Min, mean, max of Analysis...= %8.3f, %8.3f, %8.3f"%(min(Xa),numpy.mean(Xa),max(Xa)))
+print()
 """,),);
 #VERSION_CATALOGUE:V8_3_0:FIN VERSION_CATALOGUE
index e1d69dd5247c7d3f2cadc65d0ce676b43dbd7e0f..abd80e772b0fc576d6e3207a3db61bc0dd5f53e5 100644 (file)
@@ -53,10 +53,10 @@ Analysis_config['From'] = 'String'
 Analysis_config['Data'] = """import numpy
 Xb = ADD.get("Background")
 Xa = ADD.get("Analysis")[-1]
-print
-print "Size of Background...........= %i"%len(Xb.A1)
-print "Size of Analysis.............= %i"%len(Xa)
-print "Min, mean, max of Analysis...= %8.3f, %8.3f, %8.3f"%(min(Xa),numpy.mean(Xa),max(Xa))
-print
+print()
+print("Size of Background...........= %i"%len(Xb.A1))
+print("Size of Analysis.............= %i"%len(Xa))
+print("Min, mean, max of Analysis...= %8.3f, %8.3f, %8.3f"%(min(Xa),numpy.mean(Xa),max(Xa)))
+print()
 """
 study_config['UserPostAnalysis'] = Analysis_config
index 253c5a1c4aa927760ebddde0b9fa8d24820d6371..cb9790776822593f48971cd95f2d38852e68fbdf 100644 (file)
@@ -29,7 +29,7 @@ ASSIMILATION_STUDY(StudyName='test_observers',
                                        ValueTemplate=
                                                   """import numpy
 xa=numpy.ravel(ADD.get('Analysis')[-1])
-print 'Analysis:',xa""",),
+print('Analysis:',xa)""",),
                    Observers=_F(SELECTION=('CurrentState','CostFunctionJ',),
                                 CurrentState_data=_F(Info='CurrentState',
                                                      NodeType='Script',
@@ -37,9 +37,9 @@ print 'Analysis:',xa""",),
                                 CostFunctionJ_data=_F(Info='CostFunctionJ',
                                                       NodeType='String',
                                                       Value=
-"""print "  ---> observerCost"
-print "       var  =",var[:]
-print "       info =",info
+"""print("  ---> observerCost")
+print("       var  =",var[:])
+print("       info =",info)
 #
 import Gnuplot
 import os
@@ -52,7 +52,7 @@ gp('set style data lines')
 gp('set title  "'+str(info)+'"')
 gp.plot( Gnuplot.Data( var[:] ) )
 filename = os.path.join("/tmp", "imageCost_%02i.ps"%numero)
-print "       imageCost %s"%filename
+print("       imageCost %s"%filename)
 gp.hardcopy(filename=filename, color=1)
 numero += 1
 """,),),);
index 4d2364f91c55c3ce7401e8e00e6ca87d4f9f7b89..fb7aaaf32be86a91ac983eb7b758c20c4ab983fe 100644 (file)
@@ -53,7 +53,7 @@ Analysis_config = {}
 Analysis_config['From'] = 'String'
 Analysis_config['Data'] = """import numpy
 xa=numpy.ravel(ADD.get('Analysis')[-1])
-print 'Analysis:',xa"""
+print('Analysis:',xa)"""
 study_config['UserPostAnalysis'] = Analysis_config
 Init_config = {}
 Init_config['Type'] = 'Dict'
@@ -65,9 +65,9 @@ observers = {}
 observers["CostFunctionJ"] = {}
 observers["CostFunctionJ"]["number"] = 3
 observers["CostFunctionJ"]["nodetype"] = "String"
-observers["CostFunctionJ"]["String"] = """print "  ---> observerCost"
-print "       var  =",var[:]
-print "       info =",info
+observers["CostFunctionJ"]["String"] = """print("  ---> observerCost")
+print("       var  =",var[:])
+print("       info =",info)
 #
 import Gnuplot
 import os
@@ -80,7 +80,7 @@ gp('set style data lines')
 gp('set title  "'+str(info)+'"')
 gp.plot( Gnuplot.Data( var[:] ) )
 filename = os.path.join("/tmp", "imageCost_%02i.ps"%numero)
-print "       imageCost %s"%filename
+print("       imageCost %s"%filename)
 gp.hardcopy(filename=filename, color=1)
 numero += 1
 """
index b8caec8359d19f596bb607010de700857717771f..d5e55112ddd812ad8eb092e33e4c7a550973f637 100644 (file)
@@ -49,7 +49,7 @@ def DirectOperator( XX ):
     return numpy.array( HX )
 
 # ==============================================================================
-from daNumerics.ApproximatedDerivatives import FDApproximation
+from adao.daNumerics.ApproximatedDerivatives import FDApproximation
 FDA = FDApproximation( DirectOperator )
 TangentOperator = FDA.TangentOperator
 AdjointOperator = FDA.AdjointOperator
index 4569aa13b076792b467f361f8b5af04e04649523..07792d23c3b3a43f8d50f5501cefff0a528af221 100644 (file)
@@ -59,7 +59,7 @@
     <script><code>
 
 <![CDATA[
-import numpy, logging
+import sys, numpy, logging
 logging.debug("CREATE YI Entering in CreateAssimilationStudy")
 print("Entering in the assimilation study")
 print("Name is set to........:", Name)
@@ -67,7 +67,8 @@ print("Algorithm is set to...:", Algorithm)
 
 try:
     # Create Assimilation study
-    import adao
+    if sys.version_info.major > 2:
+        import adao
     from daYacsIntegration.daStudy import *
     assim_study = daStudy(Name, Algorithm, Debug)
 
@@ -546,11 +547,11 @@ logging.debug("       switching to value : "+str(switch_value))
 
   <inline name="ExtractDataNode">
     <script><code><![CDATA[
-import logging
+import sys, logging
 logging.debug("TERMINATE Entering in ExtractDataNode")
-try:
+if sys.version_info.major < 3:
   import cPickle as pickle
-except:
+else:
   import pickle
 from daCore.AssimilationStudy import AssimilationStudy
 var = None
index 01a3001c4ebae377ea77f4e7ea2f5dfe91a8fcb0..3c1f5d4b834f4fe4dff93ffb451714a3c0890945 100644 (file)
@@ -28,10 +28,10 @@ __all__ = []
 
 import os
 import sys
-import logging
-import copy
 import numpy
 import mimetypes
+import logging
+import copy
 from daCore import Persistence
 from daCore import PlatformInfo
 from daCore import Templates
@@ -101,7 +101,7 @@ class _TUIViewer(GenericCaseViewer):
         self._addLine("# -*- coding: utf-8 -*-")
         self._addLine("#\n# Python script using ADAO TUI\n#")
         self._addLine("from numpy import array, matrix")
-        self._addLine("import adaoBuilder")
+        self._addLine("from adao import adaoBuilder")
         self._addLine("%s = adaoBuilder.New('%s')"%(self._objname, self._name))
         if self._content is not None:
             for command in self._content:
@@ -422,7 +422,7 @@ class _SCDViewer(GenericCaseViewer):
         self._addLine("Analysis_config['From'] = 'String'")
         self._addLine("Analysis_config['Data'] = \"\"\"import numpy")
         self._addLine("xa=numpy.ravel(ADD.get('Analysis')[-1])")
-        self._addLine("print 'Analysis:',xa\"\"\"")
+        self._addLine("print('Analysis:',xa)\"\"\"")
         self._addLine("study_config['UserPostAnalysis'] = Analysis_config")
     def __loadVariablesByScript(self):
         __ExecVariables = {} # Necessaire pour recuperer la variable
index 2b8608717c69a44108aa7c89873cce87622e53d8..43c18965cd6860bcd12bba63770886e998609e75 100644 (file)
 __author__ = "Jean-Philippe ARGAUD"
 __all__ = []
 
-import sys, numpy, copy
+import os, sys, numpy, copy
+import gzip, bz2
 
 from daCore.PlatformInfo import PathManagement ; PathManagement()
+from daCore.PlatformInfo import has_gnuplot
+if has_gnuplot:
+    import Gnuplot
 
 if sys.version_info.major < 3:
     range = xrange
@@ -67,7 +71,6 @@ class Persistence(object):
         self.__tags     = []
         #
         self.__dynamic  = False
-        self.__gnuplot  = None
         self.__g        = None
         self.__title    = None
         self.__ltitle   = None
@@ -339,21 +342,18 @@ class Persistence(object):
         "Préparation des plots"
         #
         # Vérification de la disponibilité du module Gnuplot
-        try:
-            import Gnuplot
-            self.__gnuplot = Gnuplot
-        except:
+        if not has_gnuplot:
             raise ImportError("The Gnuplot module is required to plot the object.")
         #
         # Vérification et compléments sur les paramètres d'entrée
         if persist:
-            self.__gnuplot.GnuplotOpts.gnuplot_command = 'gnuplot -persist -geometry '+geometry
+            Gnuplot.GnuplotOpts.gnuplot_command = 'gnuplot -persist -geometry '+geometry
         else:
-            self.__gnuplot.GnuplotOpts.gnuplot_command = 'gnuplot -geometry '+geometry
+            Gnuplot.GnuplotOpts.gnuplot_command = 'gnuplot -geometry '+geometry
         if ltitle is None:
             ltitle = ""
-        self.__g = self.__gnuplot.Gnuplot() # persist=1
-        self.__g('set terminal '+self.__gnuplot.GnuplotOpts.default_term)
+        self.__g = Gnuplot.Gnuplot() # persist=1
+        self.__g('set terminal '+Gnuplot.GnuplotOpts.default_term)
         self.__g('set style data lines')
         self.__g('set grid')
         self.__g('set autoscale')
@@ -412,7 +412,6 @@ class Persistence(object):
                          attendant un Return
                          Par défaut, pause = True
         """
-        import os
         if not self.__dynamic:
             self.__preplots(title, xlabel, ylabel, ltitle, geometry, persist, pause )
             if dynamic:
@@ -436,7 +435,7 @@ class Persistence(object):
             else:
                 Steps = list(range(len(self.__values[index])))
             #
-            self.__g.plot( self.__gnuplot.Data( Steps, self.__values[index], title=ltitle ) )
+            self.__g.plot( Gnuplot.Data( Steps, self.__values[index], title=ltitle ) )
             #
             if filename != "":
                 i += 1
@@ -455,7 +454,7 @@ class Persistence(object):
         #
         self.__g('set title  "'+str(self.__title))
         Steps = list(range(len(self.__values)))
-        self.__g.plot( self.__gnuplot.Data( Steps, self.__values, title=self.__ltitle ) )
+        self.__g.plot( Gnuplot.Data( Steps, self.__values, title=self.__ltitle ) )
         #
         if self.__pause:
             eval(input('Please press return to continue...\n'))
@@ -578,25 +577,22 @@ class Persistence(object):
         """
         #
         # Vérification de la disponibilité du module Gnuplot
-        try:
-            import Gnuplot
-            self.__gnuplot = Gnuplot
-        except:
+        if not has_gnuplot:
             raise ImportError("The Gnuplot module is required to plot the object.")
         #
         # Vérification et compléments sur les paramètres d'entrée
         if persist:
-            self.__gnuplot.GnuplotOpts.gnuplot_command = 'gnuplot -persist -geometry '+geometry
+            Gnuplot.GnuplotOpts.gnuplot_command = 'gnuplot -persist -geometry '+geometry
         else:
-            self.__gnuplot.GnuplotOpts.gnuplot_command = 'gnuplot -geometry '+geometry
+            Gnuplot.GnuplotOpts.gnuplot_command = 'gnuplot -geometry '+geometry
         if ltitle is None:
             ltitle = ""
         if isinstance(steps,list) or isinstance(steps, numpy.ndarray):
             Steps = list(steps)
         else:
             Steps = list(range(len(self.__values[0])))
-        self.__g = self.__gnuplot.Gnuplot() # persist=1
-        self.__g('set terminal '+self.__gnuplot.GnuplotOpts.default_term)
+        self.__g = Gnuplot.Gnuplot() # persist=1
+        self.__g('set terminal '+Gnuplot.GnuplotOpts.default_term)
         self.__g('set style data lines')
         self.__g('set grid')
         self.__g('set autoscale')
@@ -606,9 +602,9 @@ class Persistence(object):
         #
         # Tracé du ou des vecteurs demandés
         indexes = list(range(len(self.__values)))
-        self.__g.plot( self.__gnuplot.Data( Steps, self.__values[indexes.pop(0)], title=ltitle+" (pas 0)" ) )
+        self.__g.plot( Gnuplot.Data( Steps, self.__values[indexes.pop(0)], title=ltitle+" (pas 0)" ) )
         for index in indexes:
-            self.__g.replot( self.__gnuplot.Data( Steps, self.__values[index], title=ltitle+" (pas %i)"%index ) )
+            self.__g.replot( Gnuplot.Data( Steps, self.__values[index], title=ltitle+" (pas %i)"%index ) )
         #
         if filename != "":
             self.__g.hardcopy(filename=filename, color=1)
@@ -880,7 +876,6 @@ class CompositePersistence(object):
         Enregistre l'objet dans le fichier indiqué selon le "mode" demandé,
         et renvoi le nom du fichier
         """
-        import os
         if filename is None:
             if compress == "gzip":
                 filename = os.tempnam( os.getcwd(), 'dacp' ) + ".pkl.gz"
@@ -893,10 +888,8 @@ class CompositePersistence(object):
         #
         if mode == "pickle":
             if compress == "gzip":
-                import gzip
                 output = gzip.open( filename, 'wb')
             elif compress == "bzip2":
-                import bz2
                 output = bz2.BZ2File( filename, 'wb')
             else:
                 output = open( filename, 'wb')
@@ -911,7 +904,6 @@ class CompositePersistence(object):
         """
         Recharge un objet composite sauvé en fichier
         """
-        import os
         if filename is None:
             raise ValueError("A file name if requested to load a composite.")
         else:
@@ -919,10 +911,8 @@ class CompositePersistence(object):
         #
         if mode == "pickle":
             if compress == "gzip":
-                import gzip
                 pkl_file = gzip.open( filename, 'rb')
             elif compress == "bzip2":
-                import bz2
                 pkl_file = bz2.BZ2File( filename, 'rb')
             else:
                 pkl_file = open(filename, 'rb')
index fc776bba0758fcdef8d37ebfcd37903603d6dd53..e46bbb41e95ce64bb10c76262d2360acb0b74a45 100644 (file)
@@ -27,8 +27,8 @@
     le code et la plateforme sous forme de strings, ou d'afficher directement
     les informations disponibles par les méthodes. L'impression directe d'un
     objet de cette classe affiche les informations minimales. Par exemple :
-        print PlatformInfo()
-        print PlatformInfo().getVersion()
+        print(PlatformInfo())
+        print(PlatformInfo().getVersion())
         created = PlatformInfo().getDate()
 
     La classe "PathManagement" permet de mettre à jour les chemins système pour
index 8a60968f782b1693bf26fea82752ae4a76a60f69..50fbc2fb0d5cb0ef9ff9dff03fcfef1000d6527d 100644 (file)
@@ -127,3 +127,4 @@ import os, sys
 sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
 
 from daCore.version import name, version, year, date
+from daYacsIntegration.daOptimizerLoop import *
index 2d40574ec66b215ab72deae5f44436832aded7df..17d47df267abbc64a16803200bf1399016ced1dd 100644 (file)
@@ -28,7 +28,7 @@
     Usage by an example:
 
         from numpy import array, matrix
-        import adaoBuilder
+        from adao import adaoBuilder
         case = adaoBuilder.New()
         case.set( 'AlgorithmParameters', Algorithm='3DVAR' )
         case.set( 'Background',          Vector=[0, 1, 2] )
index 806ebb95f9ed0b688baf51874425b1f471346999..428440d6526c59b87340fea4bf4149c224f8cffc 100644 (file)
@@ -391,7 +391,10 @@ def create_yacs_proc(study_config):
   ADAO_Case.edAddCFLink(CAS_node, compute_bloc)
   # We use an optimizer loop
   name = "Execute" + study_config["Algorithm"]
-  algLib = "daYacsIntegration.py"
+  if sys.version_info.major < 3:
+    algLib = "daYacsIntegration.py"
+  else:
+    algLib = "adao.py"
   factoryName = "AssimilationAlgorithm_asynch"
   #~ optimizer_node = runtime.createOptimizerLoop(name, algLib, factoryName, "")
   optimizer_node = runtime.createOptimizerLoop(name, algLib, factoryName, True)
@@ -554,7 +557,10 @@ def create_yacs_proc(study_config):
     node_script += """    DirectOperator\n"""
     node_script += """except NameError:\n"""
     node_script += """    raise ValueError("ComputationFunctionNode: DirectOperator not found in the imported user script file")\n"""
-    node_script += """from daNumerics import ApproximatedDerivatives\n"""
+    if sys.version_info.major < 3:
+        node_script += """from daNumerics import ApproximatedDerivatives\n"""
+    else:
+        node_script += """from adao.daNumerics import ApproximatedDerivatives\n"""
     node_script += """FDA = ApproximatedDerivatives.FDApproximation(\n"""
     node_script += """    Function   = DirectOperator,\n"""
     node_script += """    increment  = %s,\n"""%str(ScriptWithOneFunction['DifferentialIncrement'])
@@ -751,7 +757,10 @@ def create_yacs_proc(study_config):
       node_script += """    DirectOperator\n"""
       node_script += """except NameError:\n"""
       node_script += """    raise ValueError("ComputationFunctionNode: DirectOperator not found in the imported user script file")\n"""
-      node_script += """from daNumerics import ApproximatedDerivatives\n"""
+      if sys.version_info.major < 3:
+          node_script += """from daNumerics import ApproximatedDerivatives\n"""
+      else:
+          node_script += """from adao.daNumerics import ApproximatedDerivatives\n"""
       node_script += """FDA = ApproximatedDerivatives.FDApproximation(\n"""
       node_script += """    Function   = DirectOperator,\n"""
       node_script += """    increment  = %s,\n"""%str(ScriptWithOneFunction['DifferentialIncrement'])