From d5af691fd96858fb54b01d703cbe60e5f7133bc6 Mon Sep 17 00:00:00 2001 From: Eric Fayolle Date: Tue, 21 Jun 2022 19:49:39 +0200 Subject: [PATCH] =?utf8?q?Mise=20au=20point=20g=C3=A9n=C3=A9ration=20scrip?= =?utf8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- generator/generator_UQ.py | 23 ++++++++++++++--------- generator/textePersalys.py | 3 ++- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/generator/generator_UQ.py b/generator/generator_UQ.py index 85be0289..7764079e 100644 --- a/generator/generator_UQ.py +++ b/generator/generator_UQ.py @@ -144,11 +144,12 @@ class UQGenerator(PythonGenerator): self.nomsDesVariablesInput = [] self.chaineDesVariablesInput='' for mc in self.lesVariablesInput : - self.nomsDesVariablesInput.append(mc.variableDeterministe.nom) if mc.variableDeterministe.etape.nature == 'OPERATEUR' : - self.chaineDesVariablesInput+=mc.variableDeterministe.etape.sd.nom +'__' + mc.variableDeterministe.nom + self.chaineDesVariablesInput+=mc.variableDeterministe.etape.sd.nom +'__' + mc.variableDeterministe.nom + ', ' + self.nomsDesVariablesInput.append(mc.variableDeterministe.etape.sd.nom +'__' + mc.variableDeterministe.nom) else : self.chaineDesVariablesInput+=mc.variableDeterministe.nom + ', ' + self.nomsDesVariablesInput.append(mc.variableDeterministe.nom) self.mcIncertains.append(mc.variableDeterministe) sectionOutput = etapeIncertitude.getChildOrChildInBloc('Output')[0] self.chaineDesVariablesInput=self.chaineDesVariablesInput[0:-2] @@ -203,12 +204,15 @@ class UQGenerator(PythonGenerator): def creeTexteInputVariables(self,indent): texte='' for v in self.lesVariablesInput : - nomVariableInput = v.variableDeterministe.nom + if v.variableDeterministe.etape.nature == 'OPERATEUR' : + nomVariableInput=v.variableDeterministe.etape.sd.nom +'__' + v.variableDeterministe.nom + else : + nomVariableInput=v.variableDeterministe.nom loiDistribution = v.getChildOrChildInBloc('Distribution').valeur # on cherche le bloc qui contient ce qui est necessaire a la loi # on est confiant !!!! sur l adequation du catalogue et des attributs des lois persalys # reflechir a cela - texte="{}{} = persalys.Input('{}', ot.{}(".format(indent,nomVariableInput,nomVariableInput,loiDistribution) + texte+="{}{} = persalys.Input('{}', ot.{}(".format(indent,nomVariableInput,nomVariableInput,loiDistribution) chaineArgs='' leBlocDesArgs=None for mc in v.mcListe : @@ -229,14 +233,14 @@ class UQGenerator(PythonGenerator): from functools import reduce as reduce # chaineDesVariablesInput=reduce(lambda x,y:x+','+y,l) - def getStrVarList(l): - return reduce(lambda x,y:x+', '+y, l) + def getStrVarList(l,sep): + return reduce(lambda x,y:x+sep+y, l) def getStrInitClass(l): - return getStrVarList( map(lambda x:'self.{} = {};'.format(x,x),l) ) + return getStrVarList( map(lambda x:'self.{} = {}'.format(x,x),l), '\n'+2*self.indent1 ) def getStrReplaceVar(l): - return getStrVarList( map(lambda x:"'@{}@': repr(self.{})".format(x,x), l) ) + return getStrVarList( map(lambda x:"'@{}@': repr(self.{})".format(x,x), l), ',' ) def getStrSelfVar(l): - return getStrVarList( map(lambda x:'self.{}'.format(x),l) ) + return getStrVarList( map(lambda x:'self.{}'.format(x),l), ',' ) wrapperDir = os.path.abspath(os.path.dirname(__file__)) wrapperName = "eficas_wrapper" @@ -247,6 +251,7 @@ class UQGenerator(PythonGenerator): wrapperDir=wrapperDir, wrapperName=wrapperName ) + print('self.nomsDesVariablesInput :',self.nomsDesVariablesInput) self.txtScriptPersalys += etudeScript.format( chaineDesVariablesInput = self.chaineDesVariablesInput, chaineSelfDesVariablesInput = getStrSelfVar(self.nomsDesVariablesInput), diff --git a/generator/textePersalys.py b/generator/textePersalys.py index 5f4f85b0..fe7f7c21 100644 --- a/generator/textePersalys.py +++ b/generator/textePersalys.py @@ -100,9 +100,10 @@ class Study: pass def get_results(self): + import random print('--------------------------------------- 4 ---------------------------------------') # return self.extract_probe(2,2), self.extract_balance(2, 2) - return 1.0 + return 1.0 +random.random() def run_case(self): print('--------------------------------------- 5 ---------------------------------------') -- 2.39.2