<type name="long" kind="int"/>
<struct name="SALOME_TYPES/Parameter">
<member type="string" name="name"></member>
- <member type="string" name="value"></member>
+ <member type="pyobj" name="value"></member>
</struct>
<sequence content="SALOME_TYPES/Parameter" name="SALOME_TYPES/ParameterList"></sequence>
<sequence content="double" name="SALOME_TYPES/Variable"></sequence>
exec("matrix="+matrix_in_string)
matrix = numpy.matrix(matrix)
else:
+ matrix_in_string=matrix_in_string.replace("'","").replace('"','')
matrix = numpy.matrix(matrix_in_string)
type = "Matrix"
logging.debug("CREATE YI Matrix is %s"%matrix)
exec("matrix="+matrix_in_string)
matrix = numpy.matrix(matrix)
else:
+ matrix_in_string=matrix_in_string.replace("'","").replace('"','')
matrix = numpy.matrix(matrix_in_string)
type = "ScalarSparseMatrix"
logging.debug("CREATE YI ScalarSparseMatrix is %s"%matrix)
exec("matrix="+matrix_in_string)
matrix = numpy.matrix(matrix)
else:
+ matrix_in_string=matrix_in_string.replace("'","").replace('"','')
matrix = numpy.matrix(matrix_in_string)
type = "DiagonalSparseMatrix"
logging.debug("CREATE YI DiagonalSparseMatrix is %s"%matrix)
exec("vector="+vector_in_string)
vector = numpy.matrix(vector)
else:
+ vector_in_string=vector_in_string.replace("'","").replace('"','')
vector = numpy.matrix(vector_in_string)
type = "Vector"
logging.debug("Vector is %s"%vector)
<inline name="SimpleUserAnalysis">
<script><code><![CDATA[
#-*- coding: utf-8 -*-
-import logging
+import sys, logging
logging.debug("TERMINATE Entering in SimpleUserAnalysis")
-ADD = Study.getResults()
+if sys.version_info.major < 3:
+ ADD = Study.getResults()
+else:
+ ADD = Study
# User code is below
]]></code></script>
</inline>
<inline name="ReadForSwitchNode">
- <script><code><![CDATA[
-import logging
+ <script><code><![CDATA[import sys, logging
+if sys.version_info.major > 3: import adao
logging.debug("CREATE YI Entering in ReadForSwitchNode")
-logging.debug(" with input data : "+str(data["specificParameters"]))
+logging.debug(" with input data : ",list(data["specificParameters"]))
switch_value = -1
for param in data["specificParameters"]:
if param["name"] == "switch_value":
</inline>
<inline name="ExtractDataNode">
- <script><code><![CDATA[
-import sys, logging
+ <script><code><![CDATA[import sys, logging
+if sys.version_info.major > 3: import adao
logging.debug("TERMINATE Entering in ExtractDataNode")
-if sys.version_info.major < 3:
- import cPickle as pickle
-else:
- import pickle
from daCore.AssimilationStudy import AssimilationStudy
var = None
info = None
for param in data["specificParameters"]:
if param["name"] == "var":
- var = pickle.loads(param["value"])
+ var = param["value"]
if param["name"] == "info":
info = param["value"]
]]></code></script>
import numpy
import threading
import sys
+import traceback
# Pour disposer des classes dans l'espace de nommage lors du pickle
from daCore.AssimilationStudy import AssimilationStudy
from daYacsIntegration import daStudy
-
class OptimizerHooks:
def __init__(self, optim_algo, switch_value=-1):
specificParameters = pilot.SequenceAny_New(self.optim_algo.runtime.getTypeCode("SALOME_TYPES/Parameter"))
method_name = pilot.StructAny_New(self.optim_algo.runtime.getTypeCode('SALOME_TYPES/Parameter'))
method_name.setEltAtRank("name", "method")
- method_name.setEltAtRank("value", method)
+ if sys.version_info.major < 3:
+ method_name.setEltAtRank("value", method)
+ else:
+ method_name.setEltAtRank("value", pickle.dumps(method))
specificParameters.pushBack(method_name)
# print self.optim_algo.has_observer
if self.optim_algo.has_observer:
obs_switch = pilot.StructAny_New(self.optim_algo.runtime.getTypeCode('SALOME_TYPES/Parameter'))
obs_switch.setEltAtRank("name", "switch_value")
- obs_switch.setEltAtRank("value", "1")
+ if sys.version_info.major < 3:
+ obs_switch.setEltAtRank("value", "1")
+ else:
+ obs_switch.setEltAtRank("value", pickle.dumps("1"))
specificParameters.pushBack(obs_switch)
if self.optim_algo.has_evolution_model:
obs_switch = pilot.StructAny_New(self.optim_algo.runtime.getTypeCode('SALOME_TYPES/Parameter'))
obs_switch.setEltAtRank("name", "switch_value")
- obs_switch.setEltAtRank("value", self.switch_value)
+ if sys.version_info.major < 3:
+ obs_switch.setEltAtRank("value", self.switch_value)
+ else:
+ obs_switch.setEltAtRank("value", pickle.dumps(self.switch_value))
specificParameters.pushBack(obs_switch)
sample.setEltAtRank("specificParameters", specificParameters)
#print "Algorithme initialize"
# get the daStudy
- #print "[Debug] Input is ", input
- str_da_study = input.getStringValue()
+ # print "[Debug] Input is ", input
+ if sys.version_info.major < 3:
+ str_da_study = input.getStringValue()
+ else:
+ str_da_study = input.getBytes()
try:
self.da_study = pickle.loads(str_da_study)
except ValueError as e:
# Switch Value
obs_switch = pilot.StructAny_New(self.runtime.getTypeCode('SALOME_TYPES/Parameter'))
obs_switch.setEltAtRank("name", "switch_value")
- obs_switch.setEltAtRank("value", self.da_study.observers_dict[info]["number"])
+ if sys.version_info.major < 3:
+ obs_switch.setEltAtRank("value", self.da_study.observers_dict[info]["number"])
+ else:
+ obs_switch.setEltAtRank("value", pickle.dumps(self.da_study.observers_dict[info]["number"]))
specificParameters.pushBack(obs_switch)
# Var
# Remove Data Observer, so you can ...
var.removeDataObserver(self.obs)
# Pickle then ...
- var_str = pickle.dumps(var)
+ var_struct.setEltAtRank("value", pickle.dumps(var))
+ specificParameters.pushBack(var_struct)
# Add Again Data Observer
if self.da_study.observers_dict[info]["scheduler"] != "":
self.ADD.setObserver(Variable = info, ObjectFunction = self.obs, Scheduler = self.da_study.observers_dict[info]["scheduler"], Info = info)
else:
self.ADD.setObserver(Variable = info, ObjectFunction = self.obs, Info = info)
- var_struct.setEltAtRank("value", var_str)
- specificParameters.pushBack(var_struct)
# Info
info_struct = pilot.StructAny_New(self.runtime.getTypeCode('SALOME_TYPES/Parameter'))
info_struct.setEltAtRank("name", "info")
- info_struct.setEltAtRank("value", self.da_study.observers_dict[info]["info"])
+ if sys.version_info.major < 3:
+ info_struct.setEltAtRank("value", self.da_study.observers_dict[info]["info"])
+ else:
+ info_struct.setEltAtRank("value", pickle.dumps(self.da_study.observers_dict[info]["info"]))
specificParameters.pushBack(info_struct)
sample.setEltAtRank("specificParameters", specificParameters)
self.pool.pushInSample(local_counter, sample)
# Wait
- import sys, traceback
try:
while True:
self.signalMasterAndWait()