1 # -*- coding: utf-8 -*-
3 # Copyright (C) 2008-2021 EDF R&D
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 # Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D
24 Normalized interface for ADAO scripting (generic API)
26 __author__ = "Jean-Philippe ARGAUD"
32 from daCore.BasicObjects import State, Covariance, FullOperator, Operator
33 from daCore.BasicObjects import AlgorithmAndParameters, DataObserver
34 from daCore.BasicObjects import RegulationAndParameters, CaseLogger
35 from daCore.BasicObjects import UserScript, ExternalParameters
36 from daCore import PlatformInfo
38 from daCore import ExtendedLogging ; ExtendedLogging.ExtendedLogging() # A importer en premier
41 # ==============================================================================
43 """ ADAO Internal Data Structure Model """
44 def __init__(self, name = "", addViewers=None):
45 self.__name = str(name)
46 self.__directory = None
47 self.__case = CaseLogger(self.__name, "case", addViewers)
49 self.__adaoObject = {}
50 self.__StoredInputs = {}
51 self.__PostAnalysis = []
53 self.__Concepts = [ # Liste exhaustive
54 "AlgorithmParameters",
68 "ObservationOperator",
70 "RegulationParameters",
71 "SupplementaryParameters",
75 for ename in self.__Concepts:
76 self.__adaoObject[ename] = None
77 for ename in ("ObservationOperator", "EvolutionModel", "ControlModel"):
78 self.__adaoObject[ename] = {}
79 for ename in ("Observer", "UserPostAnalysis"):
80 self.__adaoObject[ename] = []
81 self.__StoredInputs[ename] = [] # Vide par defaut
82 self.__StoredInputs["Name"] = self.__name
83 self.__StoredInputs["Directory"] = self.__directory
85 # Récupère le chemin du répertoire parent et l'ajoute au path
86 # (Cela complète l'action de la classe PathManagement dans PlatformInfo,
87 # qui est activée dans Persistence)
88 self.__parent = os.path.abspath(os.path.join(os.path.dirname(__file__),".."))
89 sys.path.insert(0, self.__parent)
90 sys.path = PlatformInfo.uniq( sys.path ) # Conserve en unique exemplaire chaque chemin
93 Concept = None, # Premier argument
101 DiagonalSparseMatrix = None,
102 ExtraArguments = None,
104 InputFunctionAsMulti = False,
106 ObjectFunction = None,
110 ScalarSparseMatrix = None,
116 ThreeFunctions = None,
121 "Interface unique de definition de variables d'entrees par argument"
122 self.__case.register("set",dir(),locals(),None,True)
124 if Concept in ("Background", "CheckingPoint", "ControlInput", "Observation"):
125 commande = getattr(self,"set"+Concept)
126 commande(Vector, VectorSerie, Script, DataFile, ColNames, ColMajor, Stored, Scheduler, Checked )
127 elif Concept in ("BackgroundError", "ObservationError", "EvolutionError"):
128 commande = getattr(self,"set"+Concept)
129 commande(Matrix, ScalarSparseMatrix, DiagonalSparseMatrix,
130 Script, Stored, ObjectMatrix, Checked )
131 elif Concept == "AlgorithmParameters":
132 self.setAlgorithmParameters( Algorithm, Parameters, Script )
133 elif Concept == "RegulationParameters":
134 self.setRegulationParameters( Algorithm, Parameters, Script )
135 elif Concept == "Name":
137 elif Concept == "Directory":
138 self.setDirectory(String)
139 elif Concept == "Debug":
141 elif Concept == "NoDebug":
143 elif Concept == "Observer":
144 self.setObserver( Variable, Template, String, Script, Info, ObjectFunction, Scheduler )
145 elif Concept == "UserPostAnalysis":
146 self.setUserPostAnalysis( Template, String, Script )
147 elif Concept == "SupplementaryParameters":
148 self.setSupplementaryParameters( Parameters, Script )
149 elif Concept == "ObservationOperator":
150 self.setObservationOperator(
151 Matrix, OneFunction, ThreeFunctions, AppliedInXb,
152 Parameters, Script, ExtraArguments,
153 Stored, AvoidRC, InputFunctionAsMulti, Checked )
154 elif Concept in ("EvolutionModel", "ControlModel"):
155 commande = getattr(self,"set"+Concept)
157 Matrix, OneFunction, ThreeFunctions,
158 Parameters, Script, Scheduler, ExtraArguments,
159 Stored, AvoidRC, InputFunctionAsMulti, Checked )
161 raise ValueError("the variable named '%s' is not allowed."%str(Concept))
162 except Exception as e:
163 if isinstance(e, SyntaxError): msg = "at %s: %s"%(e.offset, e.text)
165 raise ValueError(("during settings, the following error occurs:\n"+\
166 "\n%s %s\n\nSee also the potential messages, "+\
167 "which can show the origin of the above error, "+\
168 "in the launching terminal.")%(str(e),msg))
170 # -----------------------------------------------------------
172 def setBackground(self,
182 "Definition d'un concept de calcul"
183 Concept = "Background"
184 self.__case.register("set"+Concept, dir(), locals())
185 self.__adaoObject[Concept] = State(
188 asPersistentVector = VectorSerie,
189 asScript = self.__with_directory(Script),
190 asDataFile = DataFile,
193 scheduledBy = Scheduler,
194 toBeChecked = Checked,
197 self.__StoredInputs[Concept] = self.__adaoObject[Concept].getO()
200 def setCheckingPoint(self,
210 "Definition d'un concept de calcul"
211 Concept = "CheckingPoint"
212 self.__case.register("set"+Concept, dir(), locals())
213 self.__adaoObject[Concept] = State(
216 asPersistentVector = VectorSerie,
217 asScript = self.__with_directory(Script),
218 asDataFile = DataFile,
221 scheduledBy = Scheduler,
222 toBeChecked = Checked,
225 self.__StoredInputs[Concept] = self.__adaoObject[Concept].getO()
228 def setControlInput(self,
238 "Definition d'un concept de calcul"
239 Concept = "ControlInput"
240 self.__case.register("set"+Concept, dir(), locals())
241 self.__adaoObject[Concept] = State(
244 asPersistentVector = VectorSerie,
245 asScript = self.__with_directory(Script),
246 asDataFile = DataFile,
249 scheduledBy = Scheduler,
250 toBeChecked = Checked,
253 self.__StoredInputs[Concept] = self.__adaoObject[Concept].getO()
256 def setObservation(self,
266 "Definition d'un concept de calcul"
267 Concept = "Observation"
268 self.__case.register("set"+Concept, dir(), locals())
269 self.__adaoObject[Concept] = State(
272 asPersistentVector = VectorSerie,
273 asScript = self.__with_directory(Script),
274 asDataFile = DataFile,
277 scheduledBy = Scheduler,
278 toBeChecked = Checked,
281 self.__StoredInputs[Concept] = self.__adaoObject[Concept].getO()
284 def setBackgroundError(self,
286 ScalarSparseMatrix = None,
287 DiagonalSparseMatrix = None,
292 "Definition d'un concept de calcul"
293 Concept = "BackgroundError"
294 self.__case.register("set"+Concept, dir(), locals())
295 self.__adaoObject[Concept] = Covariance(
297 asCovariance = Matrix,
298 asEyeByScalar = ScalarSparseMatrix,
299 asEyeByVector = DiagonalSparseMatrix,
300 asCovObject = ObjectMatrix,
301 asScript = self.__with_directory(Script),
302 toBeChecked = Checked,
305 self.__StoredInputs[Concept] = self.__adaoObject[Concept].getO()
308 def setObservationError(self,
310 ScalarSparseMatrix = None,
311 DiagonalSparseMatrix = None,
316 "Definition d'un concept de calcul"
317 Concept = "ObservationError"
318 self.__case.register("set"+Concept, dir(), locals())
319 self.__adaoObject[Concept] = Covariance(
321 asCovariance = Matrix,
322 asEyeByScalar = ScalarSparseMatrix,
323 asEyeByVector = DiagonalSparseMatrix,
324 asCovObject = ObjectMatrix,
325 asScript = self.__with_directory(Script),
326 toBeChecked = Checked,
329 self.__StoredInputs[Concept] = self.__adaoObject[Concept].getO()
332 def setEvolutionError(self,
334 ScalarSparseMatrix = None,
335 DiagonalSparseMatrix = None,
340 "Definition d'un concept de calcul"
341 Concept = "EvolutionError"
342 self.__case.register("set"+Concept, dir(), locals())
343 self.__adaoObject[Concept] = Covariance(
345 asCovariance = Matrix,
346 asEyeByScalar = ScalarSparseMatrix,
347 asEyeByVector = DiagonalSparseMatrix,
348 asCovObject = ObjectMatrix,
349 asScript = self.__with_directory(Script),
350 toBeChecked = Checked,
353 self.__StoredInputs[Concept] = self.__adaoObject[Concept].getO()
356 def setObservationOperator(self,
359 ThreeFunctions = None,
363 ExtraArguments = None,
366 InputFunctionAsMulti = False,
368 "Definition d'un concept de calcul"
369 Concept = "ObservationOperator"
370 self.__case.register("set"+Concept, dir(), locals())
371 self.__adaoObject[Concept] = FullOperator(
374 asOneFunction = OneFunction,
375 asThreeFunctions = ThreeFunctions,
376 asScript = self.__with_directory(Script),
378 appliedInX = AppliedInXb,
379 extraArguments = ExtraArguments,
381 inputAsMF = InputFunctionAsMulti,
383 toBeChecked = Checked,
386 self.__StoredInputs[Concept] = self.__adaoObject[Concept].getO()
389 def setEvolutionModel(self,
392 ThreeFunctions = None,
396 ExtraArguments = None,
399 InputFunctionAsMulti = False,
401 "Definition d'un concept de calcul"
402 Concept = "EvolutionModel"
403 self.__case.register("set"+Concept, dir(), locals())
404 self.__adaoObject[Concept] = FullOperator(
407 asOneFunction = OneFunction,
408 asThreeFunctions = ThreeFunctions,
409 asScript = self.__with_directory(Script),
412 extraArguments = ExtraArguments,
414 inputAsMF = InputFunctionAsMulti,
415 scheduledBy = Scheduler,
416 toBeChecked = Checked,
419 self.__StoredInputs[Concept] = self.__adaoObject[Concept].getO()
422 def setControlModel(self,
425 ThreeFunctions = None,
429 ExtraArguments = None,
432 InputFunctionAsMulti = False,
434 "Definition d'un concept de calcul"
435 Concept = "ControlModel"
436 self.__case.register("set"+Concept, dir(), locals())
437 self.__adaoObject[Concept] = FullOperator(
440 asOneFunction = OneFunction,
441 asThreeFunctions = ThreeFunctions,
442 asScript = self.__with_directory(Script),
445 extraArguments = ExtraArguments,
447 inputAsMF = InputFunctionAsMulti,
448 scheduledBy = Scheduler,
449 toBeChecked = Checked,
452 self.__StoredInputs[Concept] = self.__adaoObject[Concept].getO()
455 def setName(self, String=None):
456 "Definition d'un concept de calcul"
457 self.__case.register("setName",dir(),locals())
458 if String is not None:
459 self.__name = str(String)
462 self.__StoredInputs["Name"] = self.__name
464 def setDirectory(self, String=None):
465 "Definition d'un concept de calcul"
466 self.__case.register("setDirectory",dir(),locals())
467 if os.path.isdir(os.path.abspath(str(String))):
468 self.__directory = os.path.abspath(str(String))
470 self.__directory = None
471 self.__StoredInputs["Directory"] = self.__directory
473 def setDebug(self, __level = 10):
474 "NOTSET=0 < DEBUG=10 < INFO=20 < WARNING=30 < ERROR=40 < CRITICAL=50"
475 self.__case.register("setDebug",dir(),locals())
476 log = logging.getLogger()
477 log.setLevel( __level )
478 self.__StoredInputs["Debug"] = __level
479 self.__StoredInputs["NoDebug"] = False
482 def setNoDebug(self):
483 "NOTSET=0 < DEBUG=10 < INFO=20 < WARNING=30 < ERROR=40 < CRITICAL=50"
484 self.__case.register("setNoDebug",dir(),locals())
485 log = logging.getLogger()
486 log.setLevel( logging.WARNING )
487 self.__StoredInputs["Debug"] = logging.WARNING
488 self.__StoredInputs["NoDebug"] = True
491 def setAlgorithmParameters(self,
495 "Definition d'un concept de calcul"
496 Concept = "AlgorithmParameters"
497 self.__case.register("set"+Concept, dir(), locals())
498 self.__adaoObject[Concept] = AlgorithmAndParameters(
500 asAlgorithm = Algorithm,
502 asScript = self.__with_directory(Script),
506 def updateAlgorithmParameters(self,
509 "Mise a jour d'un concept de calcul"
510 if "AlgorithmParameters" not in self.__adaoObject or self.__adaoObject["AlgorithmParameters"] is None:
511 raise ValueError("\n\nNo algorithm registred, set one before updating parameters or executing\n")
512 self.__adaoObject["AlgorithmParameters"].updateParameters(
514 asScript = self.__with_directory(Script),
518 def setRegulationParameters(self,
522 "Definition d'un concept de calcul"
523 Concept = "RegulationParameters"
524 self.__case.register("set"+Concept, dir(), locals())
525 self.__adaoObject[Concept] = RegulationAndParameters(
527 asAlgorithm = Algorithm,
529 asScript = self.__with_directory(Script),
533 def setSupplementaryParameters(self,
536 "Definition d'un concept de calcul"
537 Concept = "SupplementaryParameters"
538 self.__case.register("set"+Concept, dir(), locals())
539 self.__adaoObject[Concept] = ExternalParameters(
542 asScript = self.__with_directory(Script),
546 def updateSupplementaryParameters(self,
549 "Mise a jour d'un concept de calcul"
550 Concept = "SupplementaryParameters"
551 if Concept not in self.__adaoObject or self.__adaoObject[Concept] is None:
552 self.__adaoObject[Concept] = ExternalParameters(name = Concept)
553 self.__adaoObject[Concept].updateParameters(
555 asScript = self.__with_directory(Script),
559 def setObserver(self,
565 ObjectFunction = None,
567 "Definition d'un concept de calcul"
569 self.__case.register("set"+Concept, dir(), locals())
570 self.__adaoObject[Concept].append( DataObserver(
572 onVariable = Variable,
573 asTemplate = Template,
575 asScript = self.__with_directory(Script),
576 asObsObject = ObjectFunction,
578 scheduledBy = Scheduler,
579 withAlgo = self.__adaoObject["AlgorithmParameters"]
583 def removeObserver(self,
585 ObjectFunction = None,
587 "Permet de retirer un observer à une ou des variable nommée"
588 if "AlgorithmParameters" not in self.__adaoObject:
589 raise ValueError("No algorithm registred, ask for one before removing observers")
591 # Vérification du nom de variable et typage
592 # -----------------------------------------
593 if isinstance(Variable, str):
594 VariableNames = (Variable,)
595 elif isinstance(Variable, list):
596 VariableNames = tuple(map( str, Variable ))
598 raise ValueError("The observer requires a name or a list of names of variables.")
600 # Association interne de l'observer à la variable
601 # -----------------------------------------------
602 for ename in VariableNames:
603 if ename not in self.__adaoObject["AlgorithmParameters"]:
604 raise ValueError("An observer requires to be removed on a variable named %s which does not exist."%ename)
606 return self.__adaoObject["AlgorithmParameters"].removeObserver( ename, ObjectFunction )
608 def setUserPostAnalysis(self,
612 "Definition d'un concept de calcul"
613 Concept = "UserPostAnalysis"
614 self.__case.register("set"+Concept, dir(), locals())
615 self.__adaoObject[Concept].append( repr(UserScript(
617 asTemplate = Template,
619 asScript = self.__with_directory(Script),
622 # -----------------------------------------------------------
624 def get(self, Concept=None, noDetails=True ):
625 "Recuperation d'une sortie du calcul"
626 if Concept is not None:
628 self.__case.register("get", dir(), locals(), Concept) # Break pickle in Python 2
631 if Concept in self.__StoredInputs:
632 return self.__StoredInputs[Concept]
634 elif self.__adaoObject["AlgorithmParameters"] is not None and Concept == "AlgorithmParameters":
635 return self.__adaoObject["AlgorithmParameters"].get()
637 elif self.__adaoObject["AlgorithmParameters"] is not None and Concept in self.__adaoObject["AlgorithmParameters"]:
638 return self.__adaoObject["AlgorithmParameters"].get( Concept )
640 elif Concept == "AlgorithmRequiredParameters" and self.__adaoObject["AlgorithmParameters"] is not None:
641 return self.__adaoObject["AlgorithmParameters"].getAlgorithmRequiredParameters(noDetails)
643 elif Concept == "AlgorithmRequiredInputs" and self.__adaoObject["AlgorithmParameters"] is not None:
644 return self.__adaoObject["AlgorithmParameters"].getAlgorithmInputArguments()
646 elif Concept == "AlgorithmAttributes" and self.__adaoObject["AlgorithmParameters"] is not None:
647 return self.__adaoObject["AlgorithmParameters"].getAlgorithmAttributes()
649 elif self.__adaoObject["SupplementaryParameters"] is not None and Concept == "SupplementaryParameters":
650 return self.__adaoObject["SupplementaryParameters"].get()
652 elif self.__adaoObject["SupplementaryParameters"] is not None and Concept in self.__adaoObject["SupplementaryParameters"]:
653 return self.__adaoObject["SupplementaryParameters"].get( Concept )
656 raise ValueError("The requested key \"%s\" does not exists as an input or a stored variable."%Concept)
659 allvariables.update( {"AlgorithmParameters":self.__adaoObject["AlgorithmParameters"].get()} )
660 if self.__adaoObject["SupplementaryParameters"] is not None:
661 allvariables.update( {"SupplementaryParameters":self.__adaoObject["SupplementaryParameters"].get()} )
662 # allvariables.update( self.__adaoObject["AlgorithmParameters"].get() )
663 allvariables.update( self.__StoredInputs )
664 allvariables.pop('Observer', None)
665 allvariables.pop('UserPostAnalysis', None)
668 # -----------------------------------------------------------
670 def get_available_variables(self):
672 Renvoie les variables potentiellement utilisables pour l'étude,
673 initialement stockées comme données d'entrées ou dans les algorithmes,
674 identifiés par les chaînes de caractères. L'algorithme doit avoir été
675 préalablement choisi sinon la méthode renvoie "None".
677 if len(list(self.__adaoObject["AlgorithmParameters"].keys())) == 0 and \
678 len(list(self.__StoredInputs.keys())) == 0:
682 if len(list(self.__adaoObject["AlgorithmParameters"].keys())) > 0:
683 variables.extend(list(self.__adaoObject["AlgorithmParameters"].keys()))
684 if self.__adaoObject["SupplementaryParameters"] is not None and \
685 len(list(self.__adaoObject["SupplementaryParameters"].keys())) > 0:
686 variables.extend(list(self.__adaoObject["SupplementaryParameters"].keys()))
687 if len(list(self.__StoredInputs.keys())) > 0:
688 variables.extend( list(self.__StoredInputs.keys()) )
689 variables.remove('Observer')
690 variables.remove('UserPostAnalysis')
694 def get_available_algorithms(self):
696 Renvoie la liste des algorithmes potentiellement utilisables, identifiés
697 par les chaînes de caractères.
700 for directory in sys.path:
701 trypath = os.path.join(directory,"daAlgorithms")
702 if os.path.isdir(trypath):
703 for fname in os.listdir(trypath):
704 if os.path.isfile(os.path.join(trypath,fname)):
705 root, ext = os.path.splitext(fname)
706 if ext != ".py": continue
707 fc = open(os.path.join(trypath,fname)).read()
708 iselal = bool("class ElementaryAlgorithm" in fc)
709 if iselal and ext == '.py' and root != '__init__':
714 def get_algorithms_main_path(self):
716 Renvoie le chemin pour le répertoire principal contenant les algorithmes
720 def add_algorithms_path(self, Path=None):
722 Ajoute au chemin de recherche des algorithmes un répertoire dans lequel
723 se trouve un sous-répertoire "daAlgorithms"
725 if not os.path.isdir(Path):
726 raise ValueError("The given "+Path+" argument must exist as a directory")
727 if not os.path.isdir(os.path.join(Path,"daAlgorithms")):
728 raise ValueError("The given \""+Path+"\" argument must contain a subdirectory named \"daAlgorithms\"")
729 if not os.path.isfile(os.path.join(Path,"daAlgorithms","__init__.py")):
730 raise ValueError("The given \""+Path+"/daAlgorithms\" path must contain a file named \"__init__.py\"")
731 sys.path.insert(0, os.path.abspath(Path))
732 sys.path = PlatformInfo.uniq( sys.path ) # Conserve en unique exemplaire chaque chemin
735 # -----------------------------------------------------------
737 def execute(self, Executor=None, SaveCaseInFile=None, nextStep=False):
738 "Lancement du calcul"
739 self.__case.register("execute",dir(),locals(),None,True)
740 self.updateAlgorithmParameters(Parameters={"nextStep":bool(nextStep)})
741 if not nextStep: Operator.CM.clearCache()
743 if Executor == "YACS": self.__executeYACSScheme( SaveCaseInFile )
744 else: self.__executePythonScheme( SaveCaseInFile )
745 except Exception as e:
746 if isinstance(e, SyntaxError): msg = "at %s: %s"%(e.offset, e.text)
748 raise ValueError(("during execution, the following error occurs:\n"+\
749 "\n%s %s\n\nSee also the potential messages, "+\
750 "which can show the origin of the above error, "+\
751 "in the launching terminal.\n")%(str(e),msg))
754 def __executePythonScheme(self, FileName=None):
755 "Lancement du calcul"
756 self.__case.register("executePythonScheme", dir(), locals())
757 if FileName is not None:
758 self.dump( FileName, "TUI")
759 self.__adaoObject["AlgorithmParameters"].executePythonScheme( self.__adaoObject )
762 def __executeYACSScheme(self, FileName=None):
763 "Lancement du calcul"
764 self.__case.register("executeYACSScheme", dir(), locals())
765 self.dump( FileName, "YACS")
766 self.__adaoObject["AlgorithmParameters"].executeYACSScheme( FileName )
769 # -----------------------------------------------------------
771 def dump(self, FileName=None, Formater="TUI"):
772 "Restitution normalisée des commandes"
773 __Upa = "\n".join(self.__PostAnalysis)
774 return self.__case.dump(FileName, Formater, __Upa)
776 def load(self, FileName=None, Content=None, Object=None, Formater="TUI"):
777 "Chargement normalisé des commandes"
778 __commands = self.__case.load(FileName, Content, Object, Formater)
779 from numpy import array, matrix
780 for __command in __commands:
781 if (__command.find("set")>-1 and __command.find("set_")<0) or 'UserPostAnalysis' in __command:
782 exec("self."+__command)
784 self.__PostAnalysis.append(__command)
788 FileNameFrom=None, ContentFrom=None, ObjectFrom=None, FormaterFrom="TUI",
789 FileNameTo=None, FormaterTo="TUI",
791 "Conversion normalisée des commandes"
793 FileName=FileNameFrom, Content=ContentFrom, Object=ObjectFrom, Formater=FormaterFrom
795 FileName=FileNameTo, Formater=FormaterTo
799 "Effacement du contenu du cas en cours"
800 self.__init__(self.__name)
802 # -----------------------------------------------------------
804 def __with_directory(self, __filename=None):
805 if os.path.exists(str(__filename)):
806 __fullpath = __filename
807 elif os.path.exists(os.path.join(str(self.__directory), str(__filename))):
808 __fullpath = os.path.join(self.__directory, str(__filename))
810 __fullpath = __filename
814 "Clarifie la visibilité des méthodes"
815 return ['set', 'get', 'execute', 'dump', 'load', '__doc__', '__init__', '__module__']
817 def prepare_to_pickle(self):
818 "Retire les variables non pickelisables, avec recopie efficace"
819 if self.__adaoObject['AlgorithmParameters'] is not None:
820 for k in self.__adaoObject['AlgorithmParameters'].keys():
821 if k == "Algorithm": continue
822 if k in self.__StoredInputs:
823 raise ValueError("The key \"%s\" to be transfered for pickling will overwrite an existing one."%(k,))
824 if self.__adaoObject['AlgorithmParameters'].hasObserver( k ):
825 self.__adaoObject['AlgorithmParameters'].removeObserver( k, "", True )
826 self.__StoredInputs[k] = self.__adaoObject['AlgorithmParameters'].pop(k, None)
827 if sys.version_info[0] == 2:
828 del self.__adaoObject # Because it breaks pickle in Python 2. Not required for Python 3
829 del self.__case # Because it breaks pickle in Python 2. Not required for Python 3
830 if sys.version_info.major < 3:
833 return self.__StoredInputs
835 # ==============================================================================
836 if __name__ == "__main__":
837 print('\n AUTODIAGNOSTIC\n')