From: Jean-Philippe ARGAUD Date: Sat, 6 Oct 2018 18:17:47 +0000 (+0200) Subject: Correction of Python 3 compatibility and examples X-Git-Tag: V9_2_0b_ok_ADAO~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=101e87f86f33799493b98013b19107c5c69061f2;p=modules%2Fadao.git Correction of Python 3 compatibility and examples --- diff --git a/examples/daSalome/test001_ADAO_JDC_using_strings.comm b/examples/daSalome/test001_ADAO_JDC_using_strings.comm index d8771a4..515b363 100644 --- a/examples/daSalome/test001_ADAO_JDC_using_strings.comm +++ b/examples/daSalome/test001_ADAO_JDC_using_strings.comm @@ -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 diff --git a/examples/daSalome/test001_ADAO_JDC_using_strings.py b/examples/daSalome/test001_ADAO_JDC_using_strings.py index 1d5955a..a703907 100644 --- a/examples/daSalome/test001_ADAO_JDC_using_strings.py +++ b/examples/daSalome/test001_ADAO_JDC_using_strings.py @@ -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 diff --git a/examples/daSalome/test002_ADAO_JDC_using_strings.comm b/examples/daSalome/test002_ADAO_JDC_using_strings.comm index 72bf031..9948538 100644 --- a/examples/daSalome/test002_ADAO_JDC_using_strings.comm +++ b/examples/daSalome/test002_ADAO_JDC_using_strings.comm @@ -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 diff --git a/examples/daSalome/test002_ADAO_JDC_using_strings.py b/examples/daSalome/test002_ADAO_JDC_using_strings.py index 83b3e12..6c640d5 100644 --- a/examples/daSalome/test002_ADAO_JDC_using_strings.py +++ b/examples/daSalome/test002_ADAO_JDC_using_strings.py @@ -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 diff --git a/examples/daSalome/test003_ADAO_JDC_using_scripts.comm.in b/examples/daSalome/test003_ADAO_JDC_using_scripts.comm.in index 929fc77..6aa7185 100644 --- a/examples/daSalome/test003_ADAO_JDC_using_scripts.comm.in +++ b/examples/daSalome/test003_ADAO_JDC_using_scripts.comm.in @@ -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 diff --git a/examples/daSalome/test003_ADAO_JDC_using_scripts.py.in b/examples/daSalome/test003_ADAO_JDC_using_scripts.py.in index 56dfe2b..76ec3aa 100644 --- a/examples/daSalome/test003_ADAO_JDC_using_scripts.py.in +++ b/examples/daSalome/test003_ADAO_JDC_using_scripts.py.in @@ -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 diff --git a/examples/daSalome/test003_bis_ADAO_JDC_using_user_data_init.comm.in b/examples/daSalome/test003_bis_ADAO_JDC_using_user_data_init.comm.in index 15263b5..04e4f70 100644 --- a/examples/daSalome/test003_bis_ADAO_JDC_using_user_data_init.comm.in +++ b/examples/daSalome/test003_bis_ADAO_JDC_using_user_data_init.comm.in @@ -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 diff --git a/examples/daSalome/test003_bis_ADAO_JDC_using_user_data_init.py.in b/examples/daSalome/test003_bis_ADAO_JDC_using_user_data_init.py.in index f44ed36..ee7b68f 100644 --- a/examples/daSalome/test003_bis_ADAO_JDC_using_user_data_init.py.in +++ b/examples/daSalome/test003_bis_ADAO_JDC_using_user_data_init.py.in @@ -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' diff --git a/examples/daSalome/test004_ADAO_JDC_using_scripts.comm.in b/examples/daSalome/test004_ADAO_JDC_using_scripts.comm.in index 0f5a50a..d439370 100644 --- a/examples/daSalome/test004_ADAO_JDC_using_scripts.comm.in +++ b/examples/daSalome/test004_ADAO_JDC_using_scripts.comm.in @@ -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 diff --git a/examples/daSalome/test004_ADAO_JDC_using_scripts.py.in b/examples/daSalome/test004_ADAO_JDC_using_scripts.py.in index a2a7f3c..e164ff8 100644 --- a/examples/daSalome/test004_ADAO_JDC_using_scripts.py.in +++ b/examples/daSalome/test004_ADAO_JDC_using_scripts.py.in @@ -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 diff --git a/examples/daSalome/test005_ADAO_Operators.comm.in b/examples/daSalome/test005_ADAO_Operators.comm.in index 8e8117a..06b365c 100644 --- a/examples/daSalome/test005_ADAO_Operators.comm.in +++ b/examples/daSalome/test005_ADAO_Operators.comm.in @@ -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 diff --git a/examples/daSalome/test005_ADAO_Operators.py.in b/examples/daSalome/test005_ADAO_Operators.py.in index e1d69dd..abd80e7 100644 --- a/examples/daSalome/test005_ADAO_Operators.py.in +++ b/examples/daSalome/test005_ADAO_Operators.py.in @@ -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 diff --git a/examples/daSalome/test006_Observers.comm.in b/examples/daSalome/test006_Observers.comm.in index 253c5a1..cb97907 100644 --- a/examples/daSalome/test006_Observers.comm.in +++ b/examples/daSalome/test006_Observers.comm.in @@ -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 """,),),); diff --git a/examples/daSalome/test006_Observers.py.in b/examples/daSalome/test006_Observers.py.in index 4d2364f..fb7aaaf 100644 --- a/examples/daSalome/test006_Observers.py.in +++ b/examples/daSalome/test006_Observers.py.in @@ -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 """ diff --git a/examples/daSkeletons/External_data_definition_by_scripts/Physical_simulation_functions.py b/examples/daSkeletons/External_data_definition_by_scripts/Physical_simulation_functions.py index b8caec8..d5e5511 100644 --- a/examples/daSkeletons/External_data_definition_by_scripts/Physical_simulation_functions.py +++ b/examples/daSkeletons/External_data_definition_by_scripts/Physical_simulation_functions.py @@ -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 diff --git a/resources/ADAOSchemaCatalog.xml b/resources/ADAOSchemaCatalog.xml index 4569aa1..07792d2 100644 --- a/resources/ADAOSchemaCatalog.xml +++ b/resources/ADAOSchemaCatalog.xml @@ -59,7 +59,7 @@