From f6a434c133c5958c16d163992499250cc216eaa0 Mon Sep 17 00:00:00 2001 From: Jean-Philippe ARGAUD Date: Sat, 5 Feb 2022 22:01:43 +0100 Subject: [PATCH] Minor documentation and code review corrections (19) with pyflakes3 --- bin/AdaoYacsSchemaCreator.py | 5 +-- src/daComposant/daCore/Aidsm.py | 2 +- src/daComposant/daCore/BasicObjects.py | 5 +-- src/daComposant/daCore/Interfaces.py | 10 ++--- src/daComposant/daCore/Persistence.py | 38 ++++++++----------- src/daComposant/daCore/PlatformInfo.py | 13 +++++-- src/daComposant/daCore/Templates.py | 32 ++++++++-------- src/daEficas/configuration_ADAO.py | 3 +- src/daEficas/generator_adao.py | 3 +- src/daSalome/adaoBuilder.py | 4 +- .../daGUI/daGuiImpl/adaoModuleHelper.py | 1 + 11 files changed, 54 insertions(+), 62 deletions(-) diff --git a/bin/AdaoYacsSchemaCreator.py b/bin/AdaoYacsSchemaCreator.py index 43b91df..00c1c05 100644 --- a/bin/AdaoYacsSchemaCreator.py +++ b/bin/AdaoYacsSchemaCreator.py @@ -22,10 +22,7 @@ # # Author: André Ribes, andre.ribes@edf.fr, EDF R&D -import sys -import os -import traceback -import logging +import os, sys, logging logging.basicConfig(level=logging.WARNING, format='%(levelname)-8s %(message)s') logging.debug("-- Starting AdaoYacsSchemaCreator --") diff --git a/src/daComposant/daCore/Aidsm.py b/src/daComposant/daCore/Aidsm.py index d285135..b05b188 100644 --- a/src/daComposant/daCore/Aidsm.py +++ b/src/daComposant/daCore/Aidsm.py @@ -169,7 +169,7 @@ class Aidsm(object): if isinstance(e, SyntaxError): msg = "at %s: %s"%(e.offset, e.text) else: msg = "" raise ValueError(("during settings, the following error occurs:\n"+\ - "\n%s %s\n\nSee also the potential messages, "+\ + "\n%s%s\n\nSee also the potential messages, "+\ "which can show the origin of the above error, "+\ "in the launching terminal.")%(str(e),msg)) diff --git a/src/daComposant/daCore/BasicObjects.py b/src/daComposant/daCore/BasicObjects.py index 3b6b0d5..47b8c37 100644 --- a/src/daComposant/daCore/BasicObjects.py +++ b/src/daComposant/daCore/BasicObjects.py @@ -1925,12 +1925,12 @@ class Covariance(object): raise ValueError("The \"%s\" covariance matrix is not positive-definite. Please check your vector input."%(self.__name,)) if self.ismatrix() and (self.__check or logging.getLogger().level < logging.WARNING): try: - L = numpy.linalg.cholesky( self.__C ) + numpy.linalg.cholesky( self.__C ) except: raise ValueError("The %s covariance matrix is not symmetric positive-definite. Please check your matrix input."%(self.__name,)) if self.isobject() and (self.__check or logging.getLogger().level < logging.WARNING): try: - L = self.__C.cholesky() + self.__C.cholesky() except: raise ValueError("The %s covariance object is not symmetric positive-definite. Please check your matrix input."%(self.__name,)) @@ -2340,7 +2340,6 @@ def MultiFonction( if __mpEnabled: _jobs = __xserie # logging.debug("MULTF Internal multiprocessing calculations begin : evaluation of %i point(s)"%(len(_jobs),)) - import multiprocessing with multiprocessing.Pool(__mpWorkers) as pool: __multiHX = pool.map( _sFunction, _jobs ) pool.close() diff --git a/src/daComposant/daCore/Interfaces.py b/src/daComposant/daCore/Interfaces.py index bc25f13..7d860be 100644 --- a/src/daComposant/daCore/Interfaces.py +++ b/src/daComposant/daCore/Interfaces.py @@ -652,7 +652,7 @@ class _ReportViewer(GenericCaseViewer): if k == "self": continue if isinstance(__v,Persistence.Persistence): __v = __v.values() numpy.set_printoptions(precision=15,threshold=1000000,linewidth=1000*15) - __ktext += "\n %s = %s, "%(k,repr(__v)) + __ktext += "\n %s = %s,"%(k,repr(__v)) numpy.set_printoptions(precision=8,threshold=1000,linewidth=75) if len(__ktext) > 0: __text += " with values:" + __ktext @@ -902,7 +902,7 @@ class ImportFromFile(object): __header.append(__line) __skiprows += 1 __line = fid.readline().strip() - __varsline = __line + __varsline = __line # Ligne de labels par convention for i in range(max(0,__nblines)): __header.append(fid.readline()) return (__header, __varsline, __skiprows) @@ -950,7 +950,7 @@ class ImportFromFile(object): return self.__supportedformats def getvalue(self, ColNames=None, ColIndex=None ): - "Renvoie la ou les variables demandees par la liste de leurs noms" + "Renvoie la ou les variables demandées par la liste de leurs noms" # Uniquement si mise à jour if ColNames is not None: self._colnames = tuple(ColNames) if ColIndex is not None: self._colindex = str(ColIndex) @@ -1061,7 +1061,7 @@ class ImportScalarLinesFromFile(ImportFromFile): raise ValueError("Unkown file format \"%s\""%self._format) # def getvalue(self, VarNames = None, HeaderNames=()): - "Renvoie la ou les variables demandees par la liste de leurs noms" + "Renvoie la ou les variables demandées par la liste de leurs noms" if VarNames is not None: __varnames = tuple(VarNames) else: __varnames = None # @@ -1095,7 +1095,7 @@ class ImportScalarLinesFromFile(ImportFromFile): for i in range(1,len(HeaderNames)): __converters[i] = __replaceNone else: - raise ValueError("Can not find names of columns for initial values. Wrong first line is:\n \"%s\""%__firstline) + raise ValueError("Can not find names of columns for initial values. Wrong first line is:\n \"%s\""%self._varsline) # if self._format == "text/plain": __content = numpy.loadtxt(self._filename, dtype = __dtypes, usecols = __usecols, skiprows = self._skiprows, converters = __converters) diff --git a/src/daComposant/daCore/Persistence.py b/src/daComposant/daCore/Persistence.py index 06f916d..8e6e355 100644 --- a/src/daComposant/daCore/Persistence.py +++ b/src/daComposant/daCore/Persistence.py @@ -21,14 +21,14 @@ # Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D """ - Définit des outils de persistence et d'enregistrement de séries de valeurs + Définit des outils de persistance et d'enregistrement de séries de valeurs pour analyse ultérieure ou utilisation de calcul. """ __author__ = "Jean-Philippe ARGAUD" __all__ = [] -import os, sys, numpy, copy -import gzip, bz2 +import os, numpy, copy, math +import gzip, bz2, pickle from daCore.PlatformInfo import PathManagement ; PathManagement() from daCore.PlatformInfo import has_gnuplot, PlatformInfo @@ -36,18 +36,10 @@ mfp = PlatformInfo().MaximumPrecision() if has_gnuplot: import Gnuplot -if sys.version_info.major < 3: - range = xrange - iLong = long - import cPickle as pickle -else: - iLong = int - import pickle - # ============================================================================== class Persistence(object): """ - Classe générale de persistence définissant les accesseurs nécessaires + Classe générale de persistance définissant les accesseurs nécessaires (Template) """ def __init__(self, name="", unit="", basetype=str): @@ -105,7 +97,7 @@ class Persistence(object): def pop(self, item=None): """ - Retire une valeur enregistree par son index de stockage. Sans argument, + Retire une valeur enregistrée par son index de stockage. Sans argument, retire le dernier objet enregistre. """ if item is not None: @@ -255,18 +247,18 @@ class Persistence(object): return allKeys # --------------------------------------------------------- - # Pour compatibilite + # Pour compatibilité def stepnumber(self): "Nombre de pas" return len(self.__values) - # Pour compatibilite + # Pour compatibilité def stepserie(self, **kwargs): "Nombre de pas filtrés" __indexOfFilteredItems = self.__filteredIndexes(**kwargs) return __indexOfFilteredItems - # Pour compatibilite + # Pour compatibilité def steplist(self, **kwargs): "Nombre de pas filtrés" __indexOfFilteredItems = self.__filteredIndexes(**kwargs) @@ -487,9 +479,9 @@ class Persistence(object): """ try: if numpy.version.version >= '1.1.0': - return numpy.array(self.__values).std(ddof=ddof,axis=0).astype('float') + return numpy.asarray(self.__values).std(ddof=ddof,axis=0).astype('float') else: - return numpy.array(self.__values).std(axis=0).astype('float') + return numpy.asarray(self.__values).std(axis=0).astype('float') except: raise TypeError("Base type is incompatible with numpy") @@ -500,7 +492,7 @@ class Persistence(object): les types élémentaires numpy. """ try: - return numpy.array(self.__values).sum(axis=0) + return numpy.asarray(self.__values).sum(axis=0) except: raise TypeError("Base type is incompatible with numpy") @@ -511,7 +503,7 @@ class Persistence(object): les types élémentaires numpy. """ try: - return numpy.array(self.__values).min(axis=0) + return numpy.asarray(self.__values).min(axis=0) except: raise TypeError("Base type is incompatible with numpy") @@ -522,7 +514,7 @@ class Persistence(object): les types élémentaires numpy. """ try: - return numpy.array(self.__values).max(axis=0) + return numpy.asarray(self.__values).max(axis=0) except: raise TypeError("Base type is incompatible with numpy") @@ -533,7 +525,7 @@ class Persistence(object): les types élémentaires numpy. """ try: - return numpy.array(self.__values).cumsum(axis=0) + return numpy.asarray(self.__values).cumsum(axis=0) except: raise TypeError("Base type is incompatible with numpy") @@ -627,7 +619,7 @@ class Persistence(object): elif isinstance(Scheduler,range): # Considéré comme un itérateur Schedulers = Scheduler elif isinstance(Scheduler,(list,tuple)): # Considéré comme des index explicites - Schedulers = [iLong(i) for i in Scheduler] # map( long, Scheduler ) + Schedulers = [int(i) for i in Scheduler] # map( long, Scheduler ) else: # Dans tous les autres cas, activé par défaut Schedulers = range( 0, maxiter ) # diff --git a/src/daComposant/daCore/PlatformInfo.py b/src/daComposant/daCore/PlatformInfo.py index f23b2a2..3a01d6a 100644 --- a/src/daComposant/daCore/PlatformInfo.py +++ b/src/daComposant/daCore/PlatformInfo.py @@ -98,13 +98,18 @@ class PlatformInfo(object): __msg += "\n%s%30s : %s" %(__prefix,"platform.dist",str(platform.dist())) elif sys.platform.startswith('darwin'): if hasattr(platform, 'mac_ver'): - __macosxv = {'5': 'Leopard', '6': 'Snow Leopard', '7': 'Lion', - '8': 'Mountain Lion', '9': 'Mavericks', '10': 'Yosemite', - '11': 'El Capitan', '12': 'Sierra'} + __macosxv = { + '0': 'Cheetah', '1': 'Puma', '2': 'Jaguar', + '3': 'Panther', '4': 'Tiger', '5': 'Leopard', + '6': 'Snow Leopard', '7': 'Lion', '8': 'Mountain Lion', + '9': 'Mavericks', '10': 'Yosemite', '11': 'El Capitan', + '12': 'Sierra', '13': 'High Sierra', '14': 'Mojave', + '15': 'Catalina', '16': 'Big Sur', '17': 'Monterey', + } for key in __macosxv: if (platform.mac_ver()[0].split('.')[1] == key): __msg += "\n%s%30s : %s" %(__prefix, - "platform.mac_ver",str(platform.mac_ver()[0]+"(" + macosx_dict[key]+")")) + "platform.mac_ver",str(platform.mac_ver()[0]+"(" + __macosxv[key]+")")) elif hasattr(platform, 'dist'): __msg += "\n%s%30s : %s" %(__prefix,"platform.dist",str(platform.dist())) elif os.name == 'nt': diff --git a/src/daComposant/daCore/Templates.py b/src/daComposant/daCore/Templates.py index bd4ffc1..1d0ce76 100644 --- a/src/daComposant/daCore/Templates.py +++ b/src/daComposant/daCore/Templates.py @@ -110,112 +110,112 @@ ObserverTemplates.store( ) ObserverTemplates.store( name = "ValueSaver", - content = """import numpy, re\nv=numpy.array(var[-1], ndmin=1)\nglobal istep\ntry:\n istep += 1\nexcept:\n istep = 0\nf='/tmp/value_%s_%05i.txt'%(info,istep)\nf=re.sub('\\s','_',f)\nprint('Value saved in \"%s\"'%f)\nnumpy.savetxt(f,v)""", + content = """import numpy, re\nv=numpy.array(var[-1], ndmin=1)\nglobal istep\ntry:\n istep+=1\nexcept:\n istep=0\nf='/tmp/value_%s_%05i.txt'%(info,istep)\nf=re.sub('\\s','_',f)\nprint('Value saved in \"%s\"'%f)\nnumpy.savetxt(f,v)""", fr_FR = "Enregistre la valeur courante de la variable dans un fichier du répertoire '/tmp' nommé 'value...txt' selon le nom de la variable et l'étape d'enregistrement", en_EN = "Save the current value of the variable in a file of the '/tmp' directory named 'value...txt' from the variable name and the saving step", order = "next", ) ObserverTemplates.store( name = "ValueSerieSaver", - content = """import numpy, re\nv=numpy.array(var[:], ndmin=1)\nglobal istep\ntry:\n istep += 1\nexcept:\n istep = 0\nf='/tmp/value_%s_%05i.txt'%(info,istep)\nf=re.sub('\\s','_',f)\nprint('Value saved in \"%s\"'%f)\nnumpy.savetxt(f,v)""", + content = """import numpy, re\nv=numpy.array(var[:], ndmin=1)\nglobal istep\ntry:\n istep+=1\nexcept:\n istep=0\nf='/tmp/value_%s_%05i.txt'%(info,istep)\nf=re.sub('\\s','_',f)\nprint('Value saved in \"%s\"'%f)\nnumpy.savetxt(f,v)""", fr_FR = "Enregistre la série des valeurs de la variable dans un fichier du répertoire '/tmp' nommé 'value...txt' selon le nom de la variable et l'étape", en_EN = "Save the value series of the variable in a file of the '/tmp' directory named 'value...txt' from the variable name and the saving step", order = "next", ) ObserverTemplates.store( name = "ValuePrinterAndSaver", - content = """import numpy, re\nv=numpy.array(var[-1], ndmin=1)\nprint(str(info)+" "+str(v))\nglobal istep\ntry:\n istep += 1\nexcept:\n istep = 0\nf='/tmp/value_%s_%05i.txt'%(info,istep)\nf=re.sub('\\s','_',f)\nprint('Value saved in \"%s\"'%f)\nnumpy.savetxt(f,v)""", + content = """import numpy, re\nv=numpy.array(var[-1], ndmin=1)\nprint(str(info)+" "+str(v))\nglobal istep\ntry:\n istep+=1\nexcept:\n istep=0\nf='/tmp/value_%s_%05i.txt'%(info,istep)\nf=re.sub('\\s','_',f)\nprint('Value saved in \"%s\"'%f)\nnumpy.savetxt(f,v)""", fr_FR = "Imprime sur la sortie standard et, en même temps enregistre dans un fichier du répertoire '/tmp', la valeur courante de la variable", en_EN = "Print on standard output and, in the same time save in a file of the '/tmp' directory, the current value of the variable", order = "next", ) ObserverTemplates.store( name = "ValueIndexPrinterAndSaver", - content = """import numpy, re\nv=numpy.array(var[-1], ndmin=1)\nprint(str(info)+(" index %i:"%(len(var)-1))+" "+str(v))\nglobal istep\ntry:\n istep += 1\nexcept:\n istep = 0\nf='/tmp/value_%s_%05i.txt'%(info,istep)\nf=re.sub('\\s','_',f)\nprint('Value saved in \"%s\"'%f)\nnumpy.savetxt(f,v)""", + content = """import numpy, re\nv=numpy.array(var[-1], ndmin=1)\nprint(str(info)+(" index %i:"%(len(var)-1))+" "+str(v))\nglobal istep\ntry:\n istep+=1\nexcept:\n istep=0\nf='/tmp/value_%s_%05i.txt'%(info,istep)\nf=re.sub('\\s','_',f)\nprint('Value saved in \"%s\"'%f)\nnumpy.savetxt(f,v)""", fr_FR = "Imprime sur la sortie standard et, en même temps enregistre dans un fichier du répertoire '/tmp', la valeur courante de la variable, en ajoutant son index", en_EN = "Print on standard output and, in the same time save in a file of the '/tmp' directory, the current value of the variable, adding its index", order = "next", ) ObserverTemplates.store( name = "ValueSeriePrinterAndSaver", - content = """import numpy, re\nv=numpy.array(var[:], ndmin=1)\nprint(str(info)+" "+str(v))\nglobal istep\ntry:\n istep += 1\nexcept:\n istep = 0\nf='/tmp/value_%s_%05i.txt'%(info,istep)\nf=re.sub('\\s','_',f)\nprint('Value saved in \"%s\"'%f)\nnumpy.savetxt(f,v)""", + content = """import numpy, re\nv=numpy.array(var[:], ndmin=1)\nprint(str(info)+" "+str(v))\nglobal istep\ntry:\n istep+=1\nexcept:\n istep=0\nf='/tmp/value_%s_%05i.txt'%(info,istep)\nf=re.sub('\\s','_',f)\nprint('Value saved in \"%s\"'%f)\nnumpy.savetxt(f,v)""", fr_FR = "Imprime sur la sortie standard et, en même temps, enregistre dans un fichier du répertoire '/tmp', la série des valeurs de la variable", en_EN = "Print on standard output and, in the same time, save in a file of the '/tmp' directory, the value series of the variable", order = "next", ) ObserverTemplates.store( name = "ValueGnuPlotter", - content = """import numpy, Gnuplot\nv=numpy.array(var[-1], ndmin=1)\nglobal ifig, gp\ntry:\n ifig += 1\n gp(' set style data lines')\nexcept:\n ifig = 0\n gp = Gnuplot.Gnuplot(persist=1)\n gp(' set style data lines')\ngp('set title \"%s (Figure %i)\"'%(info,ifig))\ngp.plot( Gnuplot.Data( v, with_='lines lw 2' ) )""", + content = """import numpy, Gnuplot\nv=numpy.array(var[-1], ndmin=1)\nglobal ifig, gp\ntry:\n ifig+=1\n gp('set style data lines')\nexcept:\n ifig=0\n gp=Gnuplot.Gnuplot(persist=1)\n gp('set style data lines')\ngp('set title \"%s (Figure %i)\"'%(info,ifig))\ngp.plot( Gnuplot.Data( v, with_='lines lw 2' ) )""", fr_FR = "Affiche graphiquement avec Gnuplot la valeur courante de la variable", en_EN = "Graphically plot with Gnuplot the current value of the variable", order = "next", ) ObserverTemplates.store( name = "ValueSerieGnuPlotter", - content = """import numpy, Gnuplot\nv=numpy.array(var[:], ndmin=1)\nglobal ifig, gp\ntry:\n ifig += 1\n gp(' set style data lines')\nexcept:\n ifig = 0\n gp = Gnuplot.Gnuplot(persist=1)\n gp(' set style data lines')\ngp('set title \"%s (Figure %i)\"'%(info,ifig))\ngp.plot( Gnuplot.Data( v, with_='lines lw 2' ) )""", + content = """import numpy, Gnuplot\nv=numpy.array(var[:], ndmin=1)\nglobal ifig, gp\ntry:\n ifig+=1\n gp('set style data lines')\nexcept:\n ifig=0\n gp=Gnuplot.Gnuplot(persist=1)\n gp('set style data lines')\ngp('set title \"%s (Figure %i)\"'%(info,ifig))\ngp.plot( Gnuplot.Data( v, with_='lines lw 2' ) )""", fr_FR = "Affiche graphiquement avec Gnuplot la série des valeurs de la variable", en_EN = "Graphically plot with Gnuplot the value series of the variable", order = "next", ) ObserverTemplates.store( name = "ValuePrinterAndGnuPlotter", - content = """print(str(info)+" "+str(var[-1]))\nimport numpy, Gnuplot\nv=numpy.array(var[-1], ndmin=1)\nglobal ifig,gp\ntry:\n ifig += 1\n gp(' set style data lines')\nexcept:\n ifig = 0\n gp = Gnuplot.Gnuplot(persist=1)\n gp(' set style data lines')\ngp('set title \"%s (Figure %i)\"'%(info,ifig))\ngp.plot( Gnuplot.Data( v, with_='lines lw 2' ) )""", + content = """print(str(info)+' '+str(var[-1]))\nimport numpy, Gnuplot\nv=numpy.array(var[-1], ndmin=1)\nglobal ifig,gp\ntry:\n ifig+=1\n gp('set style data lines')\nexcept:\n ifig=0\n gp=Gnuplot.Gnuplot(persist=1)\n gp('set style data lines')\ngp('set title \"%s (Figure %i)\"'%(info,ifig))\ngp.plot( Gnuplot.Data( v, with_='lines lw 2' ) )""", fr_FR = "Imprime sur la sortie standard et, en même temps, affiche graphiquement avec Gnuplot la valeur courante de la variable", en_EN = "Print on standard output and, in the same time, graphically plot with Gnuplot the current value of the variable", order = "next", ) ObserverTemplates.store( name = "ValueSeriePrinterAndGnuPlotter", - content = """print(str(info)+" "+str(var[:]))\nimport numpy, Gnuplot\nv=numpy.array(var[:], ndmin=1)\nglobal ifig,gp\ntry:\n ifig += 1\n gp(' set style data lines')\nexcept:\n ifig = 0\n gp = Gnuplot.Gnuplot(persist=1)\n gp(' set style data lines')\ngp('set title \"%s (Figure %i)\"'%(info,ifig))\ngp.plot( Gnuplot.Data( v, with_='lines lw 2' ) )""", + content = """print(str(info)+' '+str(var[:]))\nimport numpy, Gnuplot\nv=numpy.array(var[:], ndmin=1)\nglobal ifig,gp\ntry:\n ifig+=1\n gp('set style data lines')\nexcept:\n ifig=0\n gp=Gnuplot.Gnuplot(persist=1)\n gp('set style data lines')\ngp('set title \"%s (Figure %i)\"'%(info,ifig))\ngp.plot( Gnuplot.Data( v, with_='lines lw 2' ) )""", fr_FR = "Imprime sur la sortie standard et, en même temps, affiche graphiquement avec Gnuplot la série des valeurs de la variable", en_EN = "Print on standard output and, in the same time, graphically plot with Gnuplot the value series of the variable", order = "next", ) ObserverTemplates.store( name = "ValuePrinterSaverAndGnuPlotter", - content = """print(str(info)+" "+str(var[-1]))\nimport numpy, re\nv=numpy.array(var[-1], ndmin=1)\nglobal istep\ntry:\n istep += 1\nexcept:\n istep = 0\nf='/tmp/value_%s_%05i.txt'%(info,istep)\nf=re.sub('\\s','_',f)\nprint('Value saved in \"%s\"'%f)\nnumpy.savetxt(f,v)\nimport Gnuplot\nglobal ifig,gp\ntry:\n ifig += 1\n gp(' set style data lines')\nexcept:\n ifig = 0\n gp = Gnuplot.Gnuplot(persist=1)\n gp(' set style data lines')\ngp('set title \"%s (Figure %i)\"'%(info,ifig))\ngp.plot( Gnuplot.Data( v, with_='lines lw 2' ) )""", + content = """print(str(info)+' '+str(var[-1]))\nimport numpy, re\nv=numpy.array(var[-1], ndmin=1)\nglobal istep\ntry:\n istep+=1\nexcept:\n istep=0\nf='/tmp/value_%s_%05i.txt'%(info,istep)\nf=re.sub('\\s','_',f)\nprint('Value saved in \"%s\"'%f)\nnumpy.savetxt(f,v)\nimport Gnuplot\nglobal ifig,gp\ntry:\n ifig+=1\n gp('set style data lines')\nexcept:\n ifig=0\n gp=Gnuplot.Gnuplot(persist=1)\n gp('set style data lines')\ngp('set title \"%s (Figure %i)\"'%(info,ifig))\ngp.plot( Gnuplot.Data( v, with_='lines lw 2' ) )""", fr_FR = "Imprime sur la sortie standard et, en même temps, enregistre dans un fichier du répertoire '/tmp' et affiche graphiquement la valeur courante de la variable", en_EN = "Print on standard output and, in the same, time save in a file of the '/tmp' directory and graphically plot the current value of the variable", order = "next", ) ObserverTemplates.store( name = "ValueSeriePrinterSaverAndGnuPlotter", - content = """print(str(info)+" "+str(var[:]))\nimport numpy, re\nv=numpy.array(var[:], ndmin=1)\nglobal istep\ntry:\n istep += 1\nexcept:\n istep = 0\nf='/tmp/value_%s_%05i.txt'%(info,istep)\nf=re.sub('\\s','_',f)\nprint('Value saved in \"%s\"'%f)\nnumpy.savetxt(f,v)\nimport Gnuplot\nglobal ifig,gp\ntry:\n ifig += 1\n gp(' set style data lines')\nexcept:\n ifig = 0\n gp = Gnuplot.Gnuplot(persist=1)\n gp(' set style data lines')\ngp('set title \"%s (Figure %i)\"'%(info,ifig))\ngp.plot( Gnuplot.Data( v, with_='lines lw 2' ) )""", + content = """print(str(info)+' '+str(var[:]))\nimport numpy, re\nv=numpy.array(var[:], ndmin=1)\nglobal istep\ntry:\n istep+=1\nexcept:\n istep=0\nf='/tmp/value_%s_%05i.txt'%(info,istep)\nf=re.sub('\\s','_',f)\nprint('Value saved in \"%s\"'%f)\nnumpy.savetxt(f,v)\nimport Gnuplot\nglobal ifig,gp\ntry:\n ifig+=1\n gp('set style data lines')\nexcept:\n ifig=0\n gp=Gnuplot.Gnuplot(persist=1)\n gp('set style data lines')\ngp('set title \"%s (Figure %i)\"'%(info,ifig))\ngp.plot( Gnuplot.Data( v, with_='lines lw 2' ) )""", fr_FR = "Imprime sur la sortie standard et, en même temps, enregistre dans un fichier du répertoire '/tmp' et affiche graphiquement la série des valeurs de la variable", en_EN = "Print on standard output and, in the same, time save in a file of the '/tmp' directory and graphically plot the value series of the variable", order = "next", ) ObserverTemplates.store( name = "ValueMean", - content = """import numpy\nprint(str(info)+" "+str(numpy.nanmean(var[-1])))""", + content = """import numpy\nprint(str(info)+' '+str(numpy.nanmean(var[-1])))""", fr_FR = "Imprime sur la sortie standard la moyenne de la valeur courante de la variable", en_EN = "Print on standard output the mean of the current value of the variable", order = "next", ) ObserverTemplates.store( name = "ValueStandardError", - content = """import numpy\nprint(str(info)+" "+str(numpy.nanstd(var[-1])))""", + content = """import numpy\nprint(str(info)+' '+str(numpy.nanstd(var[-1])))""", fr_FR = "Imprime sur la sortie standard l'écart-type de la valeur courante de la variable", en_EN = "Print on standard output the standard error of the current value of the variable", order = "next", ) ObserverTemplates.store( name = "ValueVariance", - content = """import numpy\nprint(str(info)+" "+str(numpy.nanvar(var[-1])))""", + content = """import numpy\nprint(str(info)+' '+str(numpy.nanvar(var[-1])))""", fr_FR = "Imprime sur la sortie standard la variance de la valeur courante de la variable", en_EN = "Print on standard output the variance of the current value of the variable", order = "next", ) ObserverTemplates.store( name = "ValueL2Norm", - content = """import numpy\nv = numpy.ravel( var[-1] )\nprint(str(info)+" "+str(float( numpy.linalg.norm(v) )))""", + content = """import numpy\nv = numpy.ravel( var[-1] )\nprint(str(info)+' '+str(float( numpy.linalg.norm(v) )))""", fr_FR = "Imprime sur la sortie standard la norme L2 de la valeur courante de la variable", en_EN = "Print on standard output the L2 norm of the current value of the variable", order = "next", ) ObserverTemplates.store( name = "ValueRMS", - content = """import numpy\nv = numpy.ravel( var[-1] )\nprint(str(info)+" "+str(float( numpy.sqrt((1./v.size)*numpy.dot(v,v)) )))""", + content = """import numpy\nv = numpy.ravel( var[-1] )\nprint(str(info)+' '+str(float( numpy.sqrt((1./v.size)*numpy.dot(v,v)) )))""", fr_FR = "Imprime sur la sortie standard la racine de la moyenne des carrés (RMS), ou moyenne quadratique, de la valeur courante de la variable", en_EN = "Print on standard output the root mean square (RMS), or quadratic mean, of the current value of the variable", order = "next", diff --git a/src/daEficas/configuration_ADAO.py b/src/daEficas/configuration_ADAO.py index 952be8d..9219710 100644 --- a/src/daEficas/configuration_ADAO.py +++ b/src/daEficas/configuration_ADAO.py @@ -27,8 +27,7 @@ """ # Modules Python # print "passage dans la surcharge de configuration pour Adao" -import os, sys, string, types, re -import traceback +import os from PyQt5.QtGui import * # Modules Eficas diff --git a/src/daEficas/generator_adao.py b/src/daEficas/generator_adao.py index 4175816..8e13416 100644 --- a/src/daEficas/generator_adao.py +++ b/src/daEficas/generator_adao.py @@ -23,7 +23,6 @@ # Author: André Ribes, andre.ribes@edf.fr, EDF R&D from generator.generator_python import PythonGenerator -import traceback import logging def entryPoint(): @@ -69,7 +68,7 @@ class AdaoGenerator(PythonGenerator): self.logger.debug("EFICAS case is not valid, python command file for YACS schema generation cannot be created") self.logger.debug(self.text_da) self.dictMCVal = {} - # traceback.print_exc() + # import traceback ; traceback.print_exc() return self.text_comm def writeDefault(self, fn): diff --git a/src/daSalome/adaoBuilder.py b/src/daSalome/adaoBuilder.py index 4f955a6..1ee8c14 100644 --- a/src/daSalome/adaoBuilder.py +++ b/src/daSalome/adaoBuilder.py @@ -55,8 +55,8 @@ class New(_Aidsm): """ Generic ADAO TUI builder """ - def __init__(self, name = ""): - _Aidsm.__init__(self, name) + def __init__(self, __name = ""): + _Aidsm.__init__(self, __name) class Gui(object): """ diff --git a/src/daSalome/daGUI/daGuiImpl/adaoModuleHelper.py b/src/daSalome/daGUI/daGuiImpl/adaoModuleHelper.py index cf651e5..a24e895 100644 --- a/src/daSalome/daGUI/daGuiImpl/adaoModuleHelper.py +++ b/src/daSalome/daGUI/daGuiImpl/adaoModuleHelper.py @@ -37,6 +37,7 @@ __all__ = [ "getObjectID", ] +import os from omniORB import CORBA from SALOME_NamingServicePy import SALOME_NamingServicePy_i from LifeCycleCORBA import LifeCycleCORBA -- 2.39.2