From: Jean-Philippe ARGAUD Date: Sun, 30 Dec 2018 10:17:57 +0000 (+0100) Subject: Adding multi-functions input capabilities (5) X-Git-Tag: V9_3_0.1-prealpha1~18 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=48d9372eabb52836ebe48c95806c8259bf337c14;p=modules%2Fadao.git Adding multi-functions input capabilities (5) --- diff --git a/src/daComposant/daCore/Aidsm.py b/src/daComposant/daCore/Aidsm.py index c70c725..df5de42 100644 --- a/src/daComposant/daCore/Aidsm.py +++ b/src/daComposant/daCore/Aidsm.py @@ -145,8 +145,8 @@ class Aidsm(object): commande = getattr(self,"set"+Concept) commande( Matrix, OneFunction, ThreeFunctions, - Parameters, Script, Scheduler, Stored, AvoidRC, Checked ) - + Parameters, Script, Scheduler, + Stored, AvoidRC, InputAsMF, Checked ) else: raise ValueError("the variable named '%s' is not allowed."%str(Concept)) except Exception as e: diff --git a/src/daComposant/daCore/BasicObjects.py b/src/daComposant/daCore/BasicObjects.py index e914120..1f26d6e 100644 --- a/src/daComposant/daCore/BasicObjects.py +++ b/src/daComposant/daCore/BasicObjects.py @@ -218,7 +218,7 @@ class Operator(object): if argsAsSerie: return HxValue else: return HxValue[-1] - def appliedControledFormTo(self, paire ): + def appliedControledFormTo(self, paires, argsAsSerie = False ): """ Permet de restituer le résultat de l'application de l'opérateur à une paire (xValue, uValue). Cette méthode se contente d'appliquer, son @@ -228,17 +228,30 @@ class Operator(object): - xValue : argument X adapté pour appliquer l'opérateur - uValue : argument U adapté pour appliquer l'opérateur """ - assert len(paire) == 2, "Incorrect number of arguments" - xValue, uValue = paire + if argsAsSerie: _xuValue = paires + else: _xuValue = (paires,) + PlatformInfo.isIterable( _xuValue, True, " in Operator.appliedControledFormTo" ) + # if self.__Matrix is not None: - self.__addOneMatrixCall() - return self.__Matrix * xValue - elif uValue is not None: - self.__addOneMethodCall() - return self.__Method( (xValue, uValue) ) + HxValue = [] + for paire in _xuValue: + _xValue, _uValue = paire + self.__addOneMatrixCall() + HxValue.append( self.__Matrix * _xValue ) else: - self.__addOneMethodCall() - return self.__Method( xValue ) + HxValue = [] + for paire in _xuValue: + _xuValue = [] + _xValue, _uValue = paire + if _uValue is not None: + _xuValue.append( paire ) + else: + _xuValue.append( _xValue ) + self.__addOneMethodCall( len(_xuValue) ) + HxValue = self.__Method( _xuValue ) # Calcul MF + # + if argsAsSerie: return HxValue + else: return HxValue[-1] def appliedInXTo(self, paires, argsAsSerie = False ): """ @@ -270,18 +283,27 @@ class Operator(object): if argsAsSerie: return HxValue else: return HxValue[-1] - def asMatrix(self, ValueForMethodForm = "UnknownVoidValue"): + def asMatrix(self, ValueForMethodForm = "UnknownVoidValue", argsAsSerie = False): """ Permet de renvoyer l'opérateur sous la forme d'une matrice """ if self.__Matrix is not None: self.__addOneMatrixCall() - return self.__Matrix + mValue = [self.__Matrix,] elif ValueForMethodForm is not "UnknownVoidValue": # Ne pas utiliser "None" - self.__addOneMethodCall() - return numpy.matrix( self.__Method( (ValueForMethodForm, None) ) ) + mValue = [] + if argsAsSerie: + self.__addOneMethodCall( len(ValueForMethodForm) ) + for _vfmf in ValueForMethodForm: + mValue.append( numpy.matrix( self.__Method(((_vfmf, None),)) ) ) + else: + self.__addOneMethodCall() + mValue = self.__Method(((ValueForMethodForm, None),)) else: raise ValueError("Matrix form of the operator defined as a function/method requires to give an operating point.") + # + if argsAsSerie: return mValue + else: return mValue[-1] def shape(self): """ diff --git a/src/daComposant/daCore/Interfaces.py b/src/daComposant/daCore/Interfaces.py index 8e2a247..8e0deb0 100644 --- a/src/daComposant/daCore/Interfaces.py +++ b/src/daComposant/daCore/Interfaces.py @@ -123,6 +123,7 @@ class _TUIViewer(GenericCaseViewer): if k == "ColMajor" and not __v: continue if k == "AvoidRC" and __v: continue if k == "noDetails": continue + if k == "InputAsMF" and not __v: continue if isinstance(__v,Persistence.Persistence): __v = __v.values() if callable(__v): __text = self._missing%__v.__name__+__text if isinstance(__v,dict):