From: Jean-Philippe ARGAUD Date: Wed, 5 Apr 2017 15:59:31 +0000 (+0200) Subject: Python 3 compatibility improvement X-Git-Tag: V8_3_0rc1~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=591eaa013875041a9d2063babf9e14b7a02555b0;p=modules%2Fadao.git Python 3 compatibility improvement --- diff --git a/doc/en/ref_observers_requirements.rst b/doc/en/ref_observers_requirements.rst index ed64185..60f422a 100644 --- a/doc/en/ref_observers_requirements.rst +++ b/doc/en/ref_observers_requirements.rst @@ -90,7 +90,7 @@ Print on standard output the current value of the variable. :: - print info, var[-1] + print(str(info)+" "+str(var[-1])) .. index:: single: ValueAndIndexPrinter (Observer) @@ -101,7 +101,7 @@ Print on standard output the current value of the variable, adding its index. :: - print str(info)+" index %i:"%(len(var)-1), var[-1] + print(str(info)+(" index %i:"%(len(var)-1))+" "+str(var[-1])) .. index:: single: ValueSeriePrinter (Observer) @@ -112,7 +112,7 @@ Print on standard output the value series of the variable. :: - print info, var[:] + print(str(info)+" "+str(var[:])) .. index:: single: ValueSaver (Observer) @@ -132,7 +132,7 @@ Save the current value of the variable in a file of the '/tmp' directory named ' istep = 0 f='/tmp/value_%s_%05i.txt'%(info,istep) f=re.sub('\s','_',f) - print 'Value saved in "%s"'%f + print('Value saved in "%s"'%f) numpy.savetxt(f,v) .. index:: single: ValueSerieSaver (Observer) @@ -153,7 +153,7 @@ Save the value series of the variable in a file of the '/tmp' directory named 'v istep = 0 f='/tmp/value_%s_%05i.txt'%(info,istep) f=re.sub('\s','_',f) - print 'Value saved in "%s"'%f + print('Value saved in "%s"'%f) numpy.savetxt(f,v) .. index:: single: ValuePrinterAndSaver (Observer) @@ -167,7 +167,7 @@ Print on standard output and, in the same time save in a file, the current value import numpy, re v=numpy.array(var[-1], ndmin=1) - print info,v + print(str(info)+" "+str(v)) global istep try: istep += 1 @@ -175,7 +175,7 @@ Print on standard output and, in the same time save in a file, the current value istep = 0 f='/tmp/value_%s_%05i.txt'%(info,istep) f=re.sub('\s','_',f) - print 'Value saved in "%s"'%f + print('Value saved in "%s"'%f) numpy.savetxt(f,v) .. index:: single: ValueIndexPrinterAndSaver (Observer) @@ -189,7 +189,7 @@ Print on standard output and, in the same time save in a file, the current value import numpy, re v=numpy.array(var[-1], ndmin=1) - print str(info)+" index %i:"%(len(var)-1),v + print(str(info)+(" index %i:"%(len(var)-1))+" "+str(v)) global istep try: istep += 1 @@ -197,7 +197,7 @@ Print on standard output and, in the same time save in a file, the current value istep = 0 f='/tmp/value_%s_%05i.txt'%(info,istep) f=re.sub('\s','_',f) - print 'Value saved in "%s"'%f + print('Value saved in "%s"'%f) numpy.savetxt(f,v) .. index:: single: ValueSeriePrinterAndSaver (Observer) @@ -211,7 +211,7 @@ Print on standard output and, in the same time, save in a file the value series import numpy, re v=numpy.array(var[:], ndmin=1) - print info,v + print(str(info)+" "+str(v)) global istep try: istep += 1 @@ -219,7 +219,7 @@ Print on standard output and, in the same time, save in a file the value series istep = 0 f='/tmp/value_%s_%05i.txt'%(info,istep) f=re.sub('\s','_',f) - print 'Value saved in "%s"'%f + print('Value saved in "%s"'%f) numpy.savetxt(f,v) .. index:: single: ValueGnuPlotter (Observer) @@ -275,7 +275,7 @@ Print on standard output and, in the same time, graphically plot with Gnuplot th :: - print info, var[-1] + print(str(info)+" "+str(var[-1])) import numpy, Gnuplot v=numpy.array(var[-1], ndmin=1) global ifig,gp @@ -298,7 +298,7 @@ Print on standard output and, in the same time, graphically plot with Gnuplot th :: - print info, var[:] + print(str(info)+" "+str(var[:])) import numpy, Gnuplot v=numpy.array(var[:], ndmin=1) global ifig,gp @@ -321,7 +321,7 @@ Print on standard output and, in the same, time save in a file and graphically p :: - print info, var[-1] + print(str(info)+" "+str(var[-1])) import numpy, re v=numpy.array(var[-1], ndmin=1) global istep @@ -331,7 +331,7 @@ Print on standard output and, in the same, time save in a file and graphically p istep = 0 f='/tmp/value_%s_%05i.txt'%(info,istep) f=re.sub('\s','_',f) - print 'Value saved in "%s"'%f + print('Value saved in "%s"'%f) numpy.savetxt(f,v) import Gnuplot global ifig,gp @@ -354,7 +354,7 @@ Print on standard output and, in the same, time save in a file and graphically p :: - print info, var[:] + print(str(info)+" "+str(var[:])) import numpy, re v=numpy.array(var[:], ndmin=1) global istep @@ -364,7 +364,7 @@ Print on standard output and, in the same, time save in a file and graphically p istep = 0 f='/tmp/value_%s_%05i.txt'%(info,istep) f=re.sub('\s','_',f) - print 'Value saved in "%s"'%f + print('Value saved in "%s"'%f) numpy.savetxt(f,v) import Gnuplot global ifig,gp @@ -388,7 +388,7 @@ Print on standard output the mean of the current value of the variable. :: import numpy - print info, numpy.nanmean(var[-1]) + print(str(info)+" "+str(numpy.nanmean(var[-1]))) .. index:: single: ValueStandardError (Observer) @@ -400,7 +400,7 @@ Print on standard output the standard error of the current value of the variable :: import numpy - print info, numpy.nanstd(var[-1]) + print(str(info)+" "+str(numpy.nanstd(var[-1]))) .. index:: single: ValueVariance (Observer) @@ -412,7 +412,7 @@ Print on standard output the variance of the current value of the variable. :: import numpy - print info, numpy.nanvar(var[-1]) + print(str(info)+" "+str(numpy.nanvar(var[-1]))) .. index:: single: ValueL2Norm (Observer) @@ -425,7 +425,7 @@ Print on standard output the L2 norm of the current value of the variable. import numpy v = numpy.matrix( numpy.ravel( var[-1] ) ) - print info, float( numpy.linalg.norm(v) ) + print(str(info)+" "+str(float( numpy.linalg.norm(v) ))) .. index:: single: ValueRMS (Observer) @@ -438,4 +438,4 @@ Print on standard output the root mean square (RMS), or quadratic mean, of the c import numpy v = numpy.matrix( numpy.ravel( var[-1] ) ) - print info, float( numpy.sqrt((1./v.size)*(v*v.T)) ) + print(str(info)+" "+str(float( numpy.sqrt((1./v.size)*(v*v.T)) ))) diff --git a/doc/fr/ref_observers_requirements.rst b/doc/fr/ref_observers_requirements.rst index 421c375..7e6c43c 100644 --- a/doc/fr/ref_observers_requirements.rst +++ b/doc/fr/ref_observers_requirements.rst @@ -93,7 +93,7 @@ Imprime sur la sortie standard la valeur courante de la variable. :: - print info, var[-1] + print(str(info)+" "+str(var[-1])) .. index:: single: ValueAndIndexPrinter (Observer) @@ -104,7 +104,7 @@ Imprime sur la sortie standard la valeur courante de la variable, en ajoutant so :: - print str(info)+" index %i:"%(len(var)-1), var[-1] + print(str(info)+(" index %i:"%(len(var)-1))+" "+str(var[-1])) .. index:: single: ValueSeriePrinter (Observer) @@ -115,7 +115,7 @@ Imprime sur la sortie standard la s :: - print info, var[:] + print(str(info)+" "+str(var[:])) .. index:: single: ValueSaver (Observer) @@ -135,7 +135,7 @@ Enregistre la valeur courante de la variable dans un fichier du r istep = 0 f='/tmp/value_%s_%05i.txt'%(info,istep) f=re.sub('\s','_',f) - print 'Value saved in "%s"'%f + print('Value saved in "%s"'%f) numpy.savetxt(f,v) .. index:: single: ValueSerieSaver (Observer) @@ -156,7 +156,7 @@ Enregistre la s istep = 0 f='/tmp/value_%s_%05i.txt'%(info,istep) f=re.sub('\s','_',f) - print 'Value saved in "%s"'%f + print('Value saved in "%s"'%f) numpy.savetxt(f,v) .. index:: single: ValuePrinterAndSaver (Observer) @@ -170,7 +170,7 @@ Imprime sur la sortie standard et, en m import numpy, re v=numpy.array(var[-1], ndmin=1) - print info,v + print(str(info)+" "+str(v)) global istep try: istep += 1 @@ -178,7 +178,7 @@ Imprime sur la sortie standard et, en m istep = 0 f='/tmp/value_%s_%05i.txt'%(info,istep) f=re.sub('\s','_',f) - print 'Value saved in "%s"'%f + print('Value saved in "%s"'%f) numpy.savetxt(f,v) .. index:: single: ValueIndexPrinterAndSaver (Observer) @@ -192,7 +192,7 @@ Imprime sur la sortie standard et, en m import numpy, re v=numpy.array(var[-1], ndmin=1) - print str(info)+" index %i:"%(len(var)-1),v + print(str(info)+(" index %i:"%(len(var)-1))+" "+str(v)) global istep try: istep += 1 @@ -200,7 +200,7 @@ Imprime sur la sortie standard et, en m istep = 0 f='/tmp/value_%s_%05i.txt'%(info,istep) f=re.sub('\s','_',f) - print 'Value saved in "%s"'%f + print('Value saved in "%s"'%f) numpy.savetxt(f,v) .. index:: single: ValueSeriePrinterAndSaver (Observer) @@ -214,7 +214,7 @@ Imprime sur la sortie standard et, en m import numpy, re v=numpy.array(var[:], ndmin=1) - print info,v + print(str(info)+" "+str(v)) global istep try: istep += 1 @@ -222,7 +222,7 @@ Imprime sur la sortie standard et, en m istep = 0 f='/tmp/value_%s_%05i.txt'%(info,istep) f=re.sub('\s','_',f) - print 'Value saved in "%s"'%f + print('Value saved in "%s"'%f) numpy.savetxt(f,v) .. index:: single: ValueGnuPlotter (Observer) @@ -278,7 +278,7 @@ Imprime sur la sortie standard et, en m :: - print info, var[-1] + print(str(info)+" "+str(var[-1])) import numpy, Gnuplot v=numpy.array(var[-1], ndmin=1) global ifig,gp @@ -301,7 +301,7 @@ Imprime sur la sortie standard et, en m :: - print info, var[:] + print(str(info)+" "+str(var[:])) import numpy, Gnuplot v=numpy.array(var[:], ndmin=1) global ifig,gp @@ -324,7 +324,7 @@ Imprime sur la sortie standard et, en m :: - print info, var[-1] + print(str(info)+" "+str(var[-1])) import numpy, re v=numpy.array(var[-1], ndmin=1) global istep @@ -334,7 +334,7 @@ Imprime sur la sortie standard et, en m istep = 0 f='/tmp/value_%s_%05i.txt'%(info,istep) f=re.sub('\s','_',f) - print 'Value saved in "%s"'%f + print('Value saved in "%s"'%f) numpy.savetxt(f,v) import Gnuplot global ifig,gp @@ -357,7 +357,7 @@ Imprime sur la sortie standard et, en m :: - print info, var[:] + print(str(info)+" "+str(var[:])) import numpy, re v=numpy.array(var[:], ndmin=1) global istep @@ -367,7 +367,7 @@ Imprime sur la sortie standard et, en m istep = 0 f='/tmp/value_%s_%05i.txt'%(info,istep) f=re.sub('\s','_',f) - print 'Value saved in "%s"'%f + print('Value saved in "%s"'%f) numpy.savetxt(f,v) import Gnuplot global ifig,gp @@ -391,7 +391,7 @@ Imprime sur la sortie standard la moyenne de la valeur courante de la variable. :: import numpy - print info, numpy.nanmean(var[-1]) + print(str(info)+" "+str(numpy.nanmean(var[-1]))) .. index:: single: ValueStandardError (Observer) @@ -403,7 +403,7 @@ Imprime sur la sortie standard l' :: import numpy - print info, numpy.nanstd(var[-1]) + print(str(info)+" "+str(numpy.nanstd(var[-1]))) .. index:: single: ValueVariance (Observer) @@ -415,7 +415,7 @@ Imprime sur la sortie standard la variance de la valeur courante de la variable. :: import numpy - print info, numpy.nanvar(var[-1]) + print(str(info)+" "+str(numpy.nanvar(var[-1]))) .. index:: single: ValueL2Norm (Observer) @@ -428,7 +428,7 @@ Imprime sur la sortie standard la norme L2 de la valeur courante de la variable. import numpy v = numpy.matrix( numpy.ravel( var[-1] ) ) - print info, float( numpy.linalg.norm(v) ) + print(str(info)+" "+str(float( numpy.linalg.norm(v) ))) .. index:: single: ValueRMS (Observer) @@ -441,4 +441,4 @@ Imprime sur la sortie standard la racine de la moyenne des carr import numpy v = numpy.matrix( numpy.ravel( var[-1] ) ) - print info, float( numpy.sqrt((1./v.size)*(v*v.T)) ) + print(str(info)+" "+str(float( numpy.sqrt((1./v.size)*(v*v.T)) )))