From 37db6e4c4cb20322017c1feed20772efe8b4b18c Mon Sep 17 00:00:00 2001 From: Jean-Philippe ARGAUD Date: Sat, 3 Jan 2015 21:54:37 +0100 Subject: [PATCH] Simplifying ADAO interface to results --- src/daComposant/daCore/AssimilationStudy.py | 24 +++++++++++++++---- .../daYacsIntegration/daOptimizerLoop.py | 5 ++-- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/daComposant/daCore/AssimilationStudy.py b/src/daComposant/daCore/AssimilationStudy.py index c981715..68deecf 100644 --- a/src/daComposant/daCore/AssimilationStudy.py +++ b/src/daComposant/daCore/AssimilationStudy.py @@ -1024,15 +1024,29 @@ class AssimilationStudy: log = logging.getLogger() log.setLevel( logging.WARNING ) + def __dir__(self): + # return set(self.__dict__.keys() + dir(self.__class__)) + return ['get', '__doc__', '__init__', '__module__'] + def prepare_to_pickle(self): """ Retire les variables non pickelisables """ - self.__algorithmFile = None - self.__diagnosticFile = None - self.__HO = {} - self.__EM = {} - self.__CM = {} + del self.__B + del self.__CM # non pickelisable + del self.__EM # non pickelisable + del self.__HO # non pickelisable + del self.__Parameters + del self.__Q + del self.__R + del self.__U + del self.__X + del self.__Xb + del self.__Y + del self.__algorithmFile # non pickelisable + del self.__algorithmName + del self.__diagnosticFile # non pickelisable + self.__class__.__doc__ = "" # ============================================================================== if __name__ == "__main__": diff --git a/src/daSalome/daYacsIntegration/daOptimizerLoop.py b/src/daSalome/daYacsIntegration/daOptimizerLoop.py index f3941e0..9b91b29 100644 --- a/src/daSalome/daYacsIntegration/daOptimizerLoop.py +++ b/src/daSalome/daYacsIntegration/daOptimizerLoop.py @@ -432,11 +432,10 @@ class AssimilationAlgorithm_asynch(SALOMERuntime.OptimizerAlgASync): print '-'*60 def getAlgoResult(self): - #print "getAlgoResult" - self.ADD.prepare_to_pickle() - # Remove data observers cannot pickle assimilation study object + # Remove data observers, required to pickle assimilation study object for observer_name in self.da_study.observers_dict.keys(): self.ADD.removeDataObserver(observer_name, self.obs) + self.ADD.prepare_to_pickle() result = pickle.dumps(self.da_study) # Careful : pickle is mandatory over cPickle ! return result -- 2.39.2