]> SALOME platform Git repositories - modules/adao.git/commitdiff
Salome HOME
Correction of Python 3 compatibility
authorJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Mon, 8 Oct 2018 18:28:15 +0000 (20:28 +0200)
committerJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Mon, 8 Oct 2018 18:28:15 +0000 (20:28 +0200)
src/daComposant/daCore/Aidsm.py
src/daSalome/daGUI/daGuiImpl/adaoCase.py
src/daSalome/daYacsIntegration/daOptimizerLoop.py

index 953ef8de5ce8be5dfc74025108066913dc9d4af0..a13a09392aea60cf3bcf864c9e92af1a9cb48294 100644 (file)
@@ -742,7 +742,10 @@ class Aidsm(object):
         if sys.version_info[0] == 2:
             del self.__adaoObject # Because it breaks pickle in Python 2. Not required for Python 3
             del self.__case       # Because it breaks pickle in Python 2. Not required for Python 3
-        return 0
+        if sys.version_info.major < 3:
+            return 0
+        else:
+            return self.__StoredInputs
 
 # ==============================================================================
 if __name__ == "__main__":
index 8c209630eec51ab9f80e8e87067955555b3b9f9d..7f65168811622aa30a3e9591ccb5652758c2517f 100644 (file)
@@ -118,8 +118,8 @@ class AdaoCase:
   def validationReportforJDC(self):
     rtn = "<i>Validation report is empty.</i>"
     if self.eficas_editor.jdc:
-      rtn  = u"Validation report for the selected ADAO case:\n\n"
-      rtn += unicode( self.eficas_editor.jdc.report())
+      rtn  = "Validation report for the selected ADAO case:\n\n"
+      rtn += self.eficas_editor.jdc.report()
     return rtn
 
   def showTreeAdaoCase(self):
index ea8ad0b5adc04b860d93fb2648efdc999df5cad4..3a44bd2330e9f04bc39434f85d1b07447d1b536c 100644 (file)
@@ -30,6 +30,7 @@ except:
     import pickle
 import numpy
 import threading
+import sys
 
 # Pour disposer des classes dans l'espace de nommage lors du pickle
 from daCore.AssimilationStudy import AssimilationStudy
@@ -361,7 +362,7 @@ class AssimilationAlgorithm_asynch(SALOMERuntime.OptimizerAlgASync):
     self.pool.destroyAll()
 
   def obs(self, var, info):
-    # print "Call observer %s" % info
+    # print("Call observer %s with var type %s" %(info,type(var))
     sample = pilot.StructAny_New(self.runtime.getTypeCode('SALOME_TYPES/ParametricInput'))
 
     # Fake data
@@ -445,9 +446,11 @@ class AssimilationAlgorithm_asynch(SALOMERuntime.OptimizerAlgASync):
 #     # Remove data observers, required to pickle assimilation study object
 #     for observer_name in list(self.da_study.observers_dict.keys()):
 #       self.ADD.removeDataObserver(observer_name, self.obs)
-    self.da_study.YI_prepare_to_pickle()
-    result = pickle.dumps(self.da_study)
-    return result
+    if sys.version_info.major < 3:
+        self.da_study.YI_prepare_to_pickle()
+        return pickle.dumps(self.da_study)
+    else:
+        return pickle.dumps(self.da_study.getResults().prepare_to_pickle())
 
   # Obligatoire ???
   def finish(self):