-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
study_config = {}
study_config['StudyType'] = 'ASSIMILATION_STUDY'
study_config['Name'] = 'Test'
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
study_config = {}
study_config['StudyType'] = 'ASSIMILATION_STUDY'
study_config['Name'] = 'Test'
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
study_config = {}
study_config['StudyType'] = 'ASSIMILATION_STUDY'
study_config['Name'] = 'Test'
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2017 EDF R&D
#
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
study_config = {}
study_config['StudyType'] = 'ASSIMILATION_STUDY'
study_config['Name'] = 'Test'
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2017 EDF R&D
#
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2017 EDF R&D
#
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
study_config = {}
study_config['StudyType'] = 'ASSIMILATION_STUDY'
study_config['Name'] = 'Test'
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2017 EDF R&D
#
ASSIMILATION_STUDY(StudyName='Test',
StudyRepertory='@prefix@/share/salome/adao_examples/daSalome',
AlgorithmParameters=_F(Algorithm='3DVAR',),
- Background=_F(Stored=0,
+ Background=_F(Stored=1,
INPUT_TYPE='Vector',
data=_F(FROM='String',
STRING='0 0 0',),),
UserPostAnalysis=_F(FROM='String',
STRING=
"""import numpy
-Xb = Study.getBackground()
+Xb = ADD.get("Background")
Xa = ADD.get("Analysis")[-1]
print
print "Size of Background...........= %i"%len(Xb.A1)
-#-*-coding:iso-8859-1-*-
-study_config = {}
+# -*- coding: utf-8 -*-
+study_config = {}
study_config['StudyType'] = 'ASSIMILATION_STUDY'
study_config['Name'] = 'Test'
study_config['Debug'] = '0'
Background_config['Type'] = 'Vector'
Background_config['From'] = 'String'
Background_config['Data'] = '0 0 0'
-Background_config['Stored'] = '0'
+Background_config['Stored'] = '1'
study_config['Background'] = Background_config
BackgroundError_config = {}
BackgroundError_config['Type'] = 'Matrix'
Analysis_config = {}
Analysis_config['From'] = 'String'
Analysis_config['Data'] = """import numpy
-Xb = Study.getBackground()
+Xb = ADD.get("Background")
Xa = ADD.get("Analysis")[-1]
print
print "Size of Background...........= %i"%len(Xb.A1)
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2017 EDF R&D
#
def FunctionH( X ):
return H * X
#
-def AdjointH( (X, Y) ):
+def AdjointH( paire ):
+ X, Y = paire
return H.T * Y
#
# The possible computations
-#-*-coding:iso-8859-1-*-
-study_config = {}
+# -*- coding: utf-8 -*-
+study_config = {}
study_config['StudyType'] = 'ASSIMILATION_STUDY'
study_config['Name'] = 'test_observers'
study_config['Debug'] = '0'
study_config['Algorithm'] = '3DVAR'
-AlgorithmParameters_config = {}
+AlgorithmParameters_config = {}
AlgorithmParameters_config['Type'] = 'Dict'
AlgorithmParameters_config['From'] = 'Script'
AlgorithmParameters_config['Data'] = 'test006_Observers_var.py'
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2017 EDF R&D
#
time.sleep(1)
return H * X
#
-def AdjointH( (X, Y) ):
+def AdjointH( paire ):
+ X, Y = paire
return H.T * Y
#
# The possible computations
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2017 EDF R&D
#
# ----------------------------------------------------------
ObservationError = R
-print xb
-print B
-print yo
-print R
+print(xb)
+print(B)
+print(yo)
+print(R)
#
# Definition of the init_data dictionnary
-print " ---> observerState"
-print " var =",var[-1]
-print " info =",info
+# -*- coding: utf-8 -*-
+print(" ---> observerState")
+print(" var =",var[-1])
+print(" info =",info)
#
import Gnuplot
import os
gp.plot( Gnuplot.Data( var[-1] ) )
filename = os.path.join("/tmp", "imageState_%02i.ps"%numero)
-print " imageState \"%s\""%filename
+print(" imageState \"%s\""%filename)
gp.hardcopy(filename=filename, color=1)
numero += 1
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2017 EDF R&D
#
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
study_config = {}
study_config['StudyType'] = 'CHECKING_STUDY'
study_config['Name'] = 'Elementary gradient test'
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
study_config = {}
study_config['StudyType'] = 'CHECKING_STUDY'
study_config['Name'] = 'Test'
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
study_config = {}
study_config['StudyType'] = 'CHECKING_STUDY'
study_config['Name'] = 'Test'
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2017 EDF R&D
#
# ==============================================================================
if __name__ == "__main__":
- print
- print "AUTODIAGNOSTIC"
- print "=============="
+ print("")
+ print("AUTODIAGNOSTIC")
+ print("==============")
- print
- print "True_state = ", True_state()
- print
- print "B or R =\n",Simple_Matrix(3)
- print
- print "B or R =\n",Simple_Matrix(4, diagonal=numpy.arange(4,dtype=float))
- print
+ print("")
+ print("True_state = ", True_state())
+ print("")
+ print("B or R =\n",Simple_Matrix(3))
+ print("")
+ print("B or R =\n",Simple_Matrix(4, diagonal=numpy.arange(4,dtype=float)))
+ print("")
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2017 EDF R&D
#
""" Direct non-linear simulation operator """
#
# --------------------------------------> EXAMPLE TO BE REMOVED
- if type(XX) is type(numpy.matrix([])): # EXAMPLE TO BE REMOVED
+ if isinstance(XX, type(numpy.matrix([]))): # EXAMPLE TO BE REMOVED
HX = XX.A1.tolist() # EXAMPLE TO BE REMOVED
- elif type(XX) is type(numpy.array([])): # EXAMPLE TO BE REMOVED
+ elif isinstance(XX, type(numpy.array([]))): # EXAMPLE TO BE REMOVED
HX = numpy.matrix(XX).A1.tolist() # EXAMPLE TO BE REMOVED
else: # EXAMPLE TO BE REMOVED
HX = XX # EXAMPLE TO BE REMOVED
# ==============================================================================
if __name__ == "__main__":
- print
- print "AUTODIAGNOSTIC"
- print "=============="
+ print("")
+ print("AUTODIAGNOSTIC")
+ print("==============")
from Physical_data_and_covariance_matrices import True_state
X0, noms = True_state()
FX = DirectOperator( X0 )
- print "FX =", FX
- print
+ print("FX =", FX)
+ print("")
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2017 EDF R&D
#
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2017 EDF R&D
#
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2017 EDF R&D
#
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2017 EDF R&D
#
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2017 EDF R&D
#
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2017 EDF R&D
#
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2017 EDF R&D
#
#
# Verifying the results by printing
# ---------------------------------
-print
-print "obs = [%s]"%(", ".join(["%.4f"%v for v in ADD.get("Observation").A1]))
-print
-print "xb = [%s]"%(", ".join(["%.4f"%v for v in ADD.get("Background").A1]))
-print "xt = [%s]"%(", ".join(["%.4f"%v for v in numpy.array(xt)]))
-print "xa = [%s]"%(", ".join(["%.4f"%v for v in numpy.array(xa)]))
-print
+print("")
+print("obs = [%s]"%(", ".join(["%.4f"%v for v in ADD.get("Observation").A1])))
+print("")
+print("xb = [%s]"%(", ".join(["%.4f"%v for v in ADD.get("Background").A1])))
+print("xt = [%s]"%(", ".join(["%.4f"%v for v in numpy.array(xt)])))
+print("xa = [%s]"%(", ".join(["%.4f"%v for v in numpy.array(xa)])))
+print("")
for i in range( len(x_series) ):
- print "Step %2i : J = %.4e X = [%s]"%(i, J[i], ", ".join(["%.4f"%v for v in x_series[i]]))
-print
+ print("Step %2i : J = %.4e X = [%s]"%(i, J[i], ", ".join(["%.4f"%v for v in x_series[i]])))
+print("")
#
# ==============================================================================
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2017 EDF R&D
#
for s in ['+', 'rc1', 'rc2', 'rc3']:
v1 = v1.replace(s,'',1)
v2 = v2.replace(s,'',1)
- v11,v12,v13 = map(float,v1.split('.'))
- v21,v22,v23 = map(float,v2.split('.'))
+ v11,v12,v13 = list(map(float,v1.split('.')))
+ v21,v22,v23 = list(map(float,v2.split('.')))
lv1 = 1e6*v11 + 1e3*v12 + v13
lv2 = 1e6*v21 + 1e3*v22 + v23
return lv1 >= lv2
def minimalVersion():
"Description"
- print " Les versions minimales attendues sont :"
- print " - Python systeme....: %s"%minimal_python_version
- print " - Numpy.............: %s"%minimal_numpy_version
- print " - Scipy.............: %s"%minimal_scipy_version
- print " - Matplotlib........: %s"%minimal_matplotlib_version
- print
+ print(" Les versions minimales attendues sont :")
+ print(" - Python systeme....: %s"%minimal_python_version)
+ print(" - Numpy.............: %s"%minimal_numpy_version)
+ print(" - Scipy.............: %s"%minimal_scipy_version)
+ print(" - Matplotlib........: %s"%minimal_matplotlib_version)
+ print("")
import sys
def testSysteme():
"Test des versions de modules"
- print " Les versions disponibles sont :"
+ print(" Les versions disponibles sont :")
v=sys.version.split()
- print " - Python systeme....: %s"%v[0]
+ print(" - Python systeme....: %s"%v[0])
assert compare_versions(sys.version.split()[0], minimal_python_version)
#
try:
import numpy
- print " - Numpy.............: %s"%numpy.version.version
+ print(" - Numpy.............: %s"%numpy.version.version)
assert compare_versions(numpy.version.version, minimal_numpy_version)
except ImportError:
return 1
#
try:
import scipy
- print " - Scipy.............: %s"%scipy.version.version
+ print(" - Scipy.............: %s"%scipy.version.version)
assert compare_versions(scipy.version.version, minimal_scipy_version)
except ImportError:
return 1
try:
import matplotlib
mplversion = matplotlib.__version__
- print " - Matplotlib........: %s"%mplversion
+ print(" - Matplotlib........: %s"%mplversion)
assert compare_versions(mplversion, minimal_matplotlib_version)
#
- print
+ print("")
backends_OK = []
backends_KO = []
backend_now = matplotlib.get_backend()
except ValueError:
backends_KO.append(backend)
#
- print " Backends disponibles pour Matplotlib %s :"%mplversion
- print " Defaut initial......: '%s'"%backend_now
- print " Fonctionnant........:"
+ print(" Backends disponibles pour Matplotlib %s :"%mplversion)
+ print(" Defaut initial......: '%s'"%backend_now)
+ print(" Fonctionnant........:")
for b in backends_OK:
- print " '%s'"%b
- print " Non fonctionnant....:"
+ print(" '%s'"%b)
+ print(" Non fonctionnant....:")
for b in backends_KO:
- print " '%s'"%b
- print " (Le backend 'bidon' n'est ici que pour verifier le test, il n'existe pas)"
+ print(" '%s'"%b)
+ print(" (Le backend 'bidon' n'est ici que pour verifier le test, il n'existe pas)")
except ImportError:
pass
- print
+ print("")
#
return 0
# ==============================================================================
if __name__ == "__main__":
- print '\n AUTODIAGNOSTIC \n'
+ print('\nAUTODIAGNOSTIC\n')
minimalVersion()
sys.exit(testSysteme())
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2017 EDF R&D
#
numpy.set_printoptions(precision=5)
def testSysteme():
- print " Les caracteristiques des applications et outils systeme :"
- import sys ; v=sys.version.split() ; print " - Python systeme....: %s"%v[0]
- import numpy ; print " - Numpy.............: %s"%numpy.version.version
+ print(" Les caracteristiques des applications et outils systeme :")
+ import sys ; v=sys.version.split() ; print(" - Python systeme....: %s"%v[0])
+ import numpy ; print(" - Numpy.............: %s"%numpy.version.version)
try:
- import scipy ; print " - Scipy.............: %s"%scipy.version.version
+ import scipy ; print(" - Scipy.............: %s"%scipy.version.version)
except:
- print " - Scipy.............: %s"%("absent",)
+ print(" - Scipy.............: %s"%("absent",))
try:
- import numpy.distutils.system_info as sysinfo ; la = sysinfo.get_info('lapack') ; print " - Lapack............: %s/lib%s.so"%(la['library_dirs'][0],la['libraries'][0])
+ import numpy.distutils.system_info as sysinfo ; la = sysinfo.get_info('lapack') ; print(" - Lapack............: %s/lib%s.so"%(la['library_dirs'][0],la['libraries'][0]))
except:
- print " - Lapack............: %s"%("absent",)
- print
+ print(" - Lapack............: %s"%("absent",))
+ print("")
return True
def testNumpy01(dimension = 3, precision = 1.e-17, repetitions = 10):
"Test Numpy"
__d = int(dimension)
- print " Taille du test..................................: %.0e"%__d
+ print(" Taille du test..................................: %.0e"%__d)
t_init = time.time()
A = numpy.array([numpy.arange(dimension)+1.,]*__d)
x = numpy.arange(__d)+1.
- print " La duree elapsed moyenne de l'initialisation est: %4.1f s"%(time.time()-t_init)
+ print(" La duree elapsed moyenne de l'initialisation est: %4.1f s"%(time.time()-t_init))
#
t_init = time.time()
for i in range(repetitions):
b = numpy.dot(A,x)
- print " La duree elapsed pour %3i produits est de.......: %4.1f s"%(repetitions, time.time()-t_init)
+ print(" La duree elapsed pour %3i produits est de.......: %4.1f s"%(repetitions, time.time()-t_init))
r = [__d*(__d+1.)*(2.*__d+1.)/6.,]*__d
if max(abs(b-r)) > precision:
raise ValueError("Resultat du test errone (1)")
else:
- print " Test correct, erreur maximale inferieure a %s"%precision
- print
+ print(" Test correct, erreur maximale inferieure a %s"%precision)
+ print("")
del A, x, b
def testNumpy02(dimension = 3, precision = 1.e-17, repetitions = 100):
"Test Numpy"
__d = int(dimension)
- print " Taille du test..................................: %.0e"%__d
+ print(" Taille du test..................................: %.0e"%__d)
t_init = time.time()
A = numpy.random.normal(0.,1.,size=(__d,__d))
x = numpy.random.normal(0.,1.,size=(__d,))
- print " La duree elapsed moyenne de l'initialisation est: %4.1f s"%(time.time()-t_init)
+ print(" La duree elapsed moyenne de l'initialisation est: %4.1f s"%(time.time()-t_init))
#
t_init = time.time()
for i in range(repetitions):
b = numpy.dot(A,x)
- print " La duree elapsed pour %3i produits est de.......: %4.1f s"%(repetitions, time.time()-t_init)
- print
+ print(" La duree elapsed pour %3i produits est de.......: %4.1f s"%(repetitions, time.time()-t_init))
+ print("")
del A, x, b
# ==============================================================================
if __name__ == "__main__":
- print '\n AUTODIAGNOSTIC \n'
+ print('\nAUTODIAGNOSTIC\n')
testSysteme()
numpy.random.seed(1000)
testNumpy01(dimension = 1.e4)
testNumpy02(dimension = 3.e3)
- print
+ print("")
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2017 EDF R&D
#
# ==============================================================================
if __name__ == "__main__":
- print '\n AUTODIAGNOSTIC \n'
- print """Exemple de la doc :
+ print('\nAUTODIAGNOSTIC\n')
+ print("""Exemple de la doc :
Un exemple simple de creation d'un cas de calcul TUI ADAO
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- """
+ """)
xa = test1()
assertAlmostEqualArrays(xa, [0.25, 0.80, 0.95], places = 5)
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2017 EDF R&D
#
def assertAlmostEqualArrays(first, second, places=7, msg=None, delta=None):
"Compare two vectors, like unittest.assertAlmostEqual"
if msg is not None:
- print msg
+ print(msg)
if delta is not None:
if ( (numpy.asarray(first) - numpy.asarray(second)) > float(delta) ).any():
raise AssertionError("%s != %s within %s places"%(first,second,delta))
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2017 EDF R&D
#
# ==============================================================================
if __name__ == "__main__":
- print '\n AUTODIAGNOSTIC \n'
- print """Exemple de la doc :
+ print('\nAUTODIAGNOSTIC\n')
+ print("""Exemple de la doc :
Creation detaillee d'un cas de calcul TUI ADAO
++++++++++++++++++++++++++++++++++++++++++++++
Les deux resultats sont testes pour etre identiques.
- """
+ """)
xa1 = test1()
xa2 = test2()
ecart = assertAlmostEqualArrays(xa1, xa2, places = 15)
- print " Difference maximale entre les deux : %.2e"%ecart
+ print(" Difference maximale entre les deux : %.2e"%ecart)
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2017 EDF R&D
#
def assertAlmostEqualArrays(first, second, places=7, msg=None, delta=None):
"Compare two vectors, like unittest.assertAlmostEqual"
if msg is not None:
- print msg
+ print(msg)
if delta is not None:
if ( (numpy.asarray(first) - numpy.asarray(second)) > float(delta) ).any():
raise AssertionError("%s != %s within %s places"%(first,second,delta))
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2017 EDF R&D
#
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("")
#
return case.get("Analysis")[-1]
# ==============================================================================
if __name__ == "__main__":
- print '\n AUTODIAGNOSTIC \n'
- print """Exemple de la doc :
+ print('\nAUTODIAGNOSTIC\n')
+ print("""Exemple de la doc :
Exploitation independante des resultats d'un cas de calcul
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- """
+ """)
xa = test1()
assertAlmostEqualArrays(xa, [ 2., 3., 4.])
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2017 EDF R&D
#
def assertAlmostEqualArrays(first, second, places=7, msg=None, delta=None):
"Compare two vectors, like unittest.assertAlmostEqual"
if msg is not None:
- print msg
+ print(msg)
if delta is not None:
if ( (numpy.asarray(first) - numpy.asarray(second)) > float(delta) ).any():
raise AssertionError("%s != %s within %s places"%(first,second,delta))
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2017 EDF R&D
#
"""Verification de la disponibilite de l'ensemble des algorithmes\n(Utilisation d'un operateur matriciel)"""
Xa = {}
for algo in ("3DVAR", "Blue", "ExtendedBlue", "LinearLeastSquares", "NonLinearLeastSquares", "DerivativeFreeOptimization"):
- print
+ print("")
msg = "Algorithme en test : %s"%algo
- print msg+"\n"+"-"*len(msg)
+ print(msg+"\n"+"-"*len(msg))
#
adaopy = adaoBuilder.New()
adaopy.setAlgorithmParameters(Algorithm=algo, Parameters={"EpsilonMinimumExponent":-10, "Bounds":[[-1,10.],[-1,10.],[-1,10.]]})
del adaopy
#
for algo in ("ExtendedKalmanFilter", "KalmanFilter", "UnscentedKalmanFilter", "4DVAR"):
- print
+ print("")
msg = "Algorithme en test : %s"%algo
- print msg+"\n"+"-"*len(msg)
+ print(msg+"\n"+"-"*len(msg))
#
adaopy = adaoBuilder.New()
adaopy.setAlgorithmParameters(Algorithm=algo, Parameters={"EpsilonMinimumExponent":-10, })
del adaopy
#
for algo in ("ParticleSwarmOptimization", "QuantileRegression", ):
- print
+ print("")
msg = "Algorithme en test : %s"%algo
- print msg+"\n"+"-"*len(msg)
+ print(msg+"\n"+"-"*len(msg))
#
adaopy = adaoBuilder.New()
adaopy.setAlgorithmParameters(Algorithm=algo, Parameters={"BoxBounds":3*[[-1,3]], "SetSeed":1000, })
del adaopy
#
for algo in ("EnsembleBlue", ):
- print
+ print("")
msg = "Algorithme en test : %s"%algo
- print msg+"\n"+"-"*len(msg)
+ print(msg+"\n"+"-"*len(msg))
#
adaopy = adaoBuilder.New()
adaopy.setAlgorithmParameters(Algorithm=algo, Parameters={"SetSeed":1000, })
Xa[algo] = adaopy.get("Analysis")[-1]
del adaopy
#
- print
+ print("")
msg = "Tests des ecarts attendus :"
- print msg+"\n"+"="*len(msg)
+ print(msg+"\n"+"="*len(msg))
verify_similarity_of_algo_results(("3DVAR", "Blue", "ExtendedBlue", "4DVAR", "DerivativeFreeOptimization"), Xa)
verify_similarity_of_algo_results(("LinearLeastSquares", "NonLinearLeastSquares"), Xa)
verify_similarity_of_algo_results(("ExtendedKalmanFilter", "KalmanFilter", "UnscentedKalmanFilter"), Xa)
- print " Les resultats obtenus sont corrects."
- print
+ print(" Les resultats obtenus sont corrects.")
+ print("")
#
return 0
M = numpy.matrix("1 0 0;0 2 0;0 0 3")
def H(x): return M * numpy.asmatrix(numpy.ravel( x )).T
for algo in ("3DVAR", "Blue", "ExtendedBlue", "NonLinearLeastSquares", "DerivativeFreeOptimization"):
- print
+ print("")
msg = "Algorithme en test : %s"%algo
- print msg+"\n"+"-"*len(msg)
+ print(msg+"\n"+"-"*len(msg))
#
adaopy = adaoBuilder.New()
adaopy.setAlgorithmParameters(Algorithm=algo, Parameters={"EpsilonMinimumExponent":-10, "Bounds":[[-1,10.],[-1,10.],[-1,10.]]})
M = numpy.matrix("1 0 0;0 2 0;0 0 3")
def H(x): return M * numpy.asmatrix(numpy.ravel( x )).T
for algo in ("ExtendedKalmanFilter", "KalmanFilter", "UnscentedKalmanFilter", "4DVAR"):
- print
+ print("")
msg = "Algorithme en test : %s"%algo
- print msg+"\n"+"-"*len(msg)
+ print(msg+"\n"+"-"*len(msg))
#
adaopy = adaoBuilder.New()
adaopy.setAlgorithmParameters(Algorithm=algo, Parameters={"EpsilonMinimumExponent":-10, })
M = numpy.matrix("1 0 0;0 1 0;0 0 1")
def H(x): return M * numpy.asmatrix(numpy.ravel( x )).T
for algo in ("ParticleSwarmOptimization", "QuantileRegression", ):
- print
+ print("")
msg = "Algorithme en test : %s"%algo
- print msg+"\n"+"-"*len(msg)
+ print(msg+"\n"+"-"*len(msg))
#
adaopy = adaoBuilder.New()
adaopy.setAlgorithmParameters(Algorithm=algo, Parameters={"BoxBounds":3*[[-1,3]], "SetSeed":1000, })
Xa[algo] = adaopy.get("Analysis")[-1]
del adaopy
#
- print
+ print("")
msg = "Tests des ecarts attendus :"
- print msg+"\n"+"="*len(msg)
+ print(msg+"\n"+"="*len(msg))
verify_similarity_of_algo_results(("3DVAR", "Blue", "ExtendedBlue", "4DVAR", "DerivativeFreeOptimization"), Xa)
verify_similarity_of_algo_results(("ExtendedKalmanFilter", "KalmanFilter", "UnscentedKalmanFilter"), Xa)
- print " Les resultats obtenus sont corrects."
- print
+ print(" Les resultats obtenus sont corrects.")
+ print("")
#
return 0
def almost_equal_vectors(v1, v2, precision = 1.e-15, msg = ""):
"""Comparaison de deux vecteurs"""
- print " Difference maximale %s: %.2e"%(msg, max(abs(v2 - v1)))
+ print(" Difference maximale %s: %.2e"%(msg, max(abs(v2 - v1))))
return max(abs(v2 - v1)) < precision
def verify_similarity_of_algo_results(serie = [], Xa = {}):
- print " Comparaisons :"
+ print(" Comparaisons :")
for algo1 in serie:
for algo2 in serie:
if algo1 is algo2: break
assert almost_equal_vectors( Xa[algo1], Xa[algo2], 5.e-5, "entre %s et %s "%(algo1, algo2) )
- print " Algorithmes dont les resultats sont similaires : %s\n"%(serie,)
+ print(" Algorithmes dont les resultats sont similaires : %s\n"%(serie,))
#===============================================================================
if __name__ == "__main__":
- print '\n AUTODIAGNOSTIC \n'
+ print('\nAUTODIAGNOSTIC\n')
test1()
test2()
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
#
# Copyright (C) 2008-2017 EDF R&D
#
# ==============================================================================
def test1():
for algo in ("AdjointTest", "FunctionTest", "GradientTest", "LinearityTest", "TangentTest"):
- print
+ print("")
msg = "Algorithme en test : %s"%algo
- print msg+"\n"+"-"*len(msg)
+ print(msg+"\n"+"-"*len(msg))
#
adaopy = adaoBuilder.New()
adaopy.setAlgorithmParameters(Algorithm=algo, Parameters={"EpsilonMinimumExponent":-10,"NumberOfRepetition":2, "SetSeed":1000})
del adaopy
#
for algo in ("ObserverTest", ):
- print
+ print("")
msg = "Algorithme en test : %s"%algo
- print msg+"\n"+"-"*len(msg)
+ print(msg+"\n"+"-"*len(msg))
#
adaopy = adaoBuilder.New()
adaopy.setAlgorithmParameters(Algorithm=algo)
del adaopy
#
for algo in ("SamplingTest", ):
- print
+ print("")
msg = "Algorithme en test : %s"%algo
- print msg+"\n"+"-"*len(msg)
+ print(msg+"\n"+"-"*len(msg))
#
adaopy = adaoBuilder.New()
adaopy.setAlgorithmParameters(Algorithm=algo, Parameters={
# ==============================================================================
if __name__ == "__main__":
- print '\n AUTODIAGNOSTIC \n'
+ print('\nAUTODIAGNOSTIC\n')
test1()