From c2592a25ab3f8e558648f2bb9d5e193170ef9d35 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20Ribes?= Date: Fri, 1 Apr 2011 10:02:34 +0200 Subject: [PATCH] Aller Ok pour test017 i MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit (reste à faire lorsqu'il y a plusieurs variables) --- .../daYacsIntegration/daOptimizerLoop.py | 29 ++++++++++++------- .../daSalome/test017_3DVAR_function_script.py | 4 +-- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/daSalome/daYacsIntegration/daOptimizerLoop.py b/src/daSalome/daYacsIntegration/daOptimizerLoop.py index edf727e..dfa5a4f 100644 --- a/src/daSalome/daYacsIntegration/daOptimizerLoop.py +++ b/src/daSalome/daYacsIntegration/daOptimizerLoop.py @@ -39,20 +39,29 @@ class OptimizerHooks: # Les données # TODO à faire - parameter_1D = pilot.SequenceAny_New(self.optim_algo.runtime.getTypeCode("double")) #print data #print data.ndim #print data.shape #print data[:,0] #print data.flatten() #print data.flatten().shape - it = data.flat - for val in it: - print val - parameter_1D.pushBack(val) + + parameter_1D = pilot.SequenceAny_New(self.optim_algo.runtime.getTypeCode("double")) parameter_2D = pilot.SequenceAny_New(parameter_1D.getType()) - parameter_2D.pushBack(parameter_1D) parameters_3D = pilot.SequenceAny_New(parameter_2D.getType()) + if isinstance(data, type((1,2))): + for dat in data: + param = pilot.SequenceAny_New(self.optim_algo.runtime.getTypeCode("double")) + it = dat.flat + for val in it: + param.pushBack(val) + parameter_2D.pushBack(param) + else: + param = pilot.SequenceAny_New(self.optim_algo.runtime.getTypeCode("double")) + it = data.flat + for val in it: + param.pushBack(val) + parameter_2D.pushBack(param) parameters_3D.pushBack(parameter_2D) sample.setEltAtRank("inputValues", parameters_3D) @@ -95,7 +104,7 @@ class OptimizerHooks: return Y else: print "sync false is not yet implemented" - raise daStudy.daError("sync == false not yet implemented") + self.optim_algo.setError("sync == false not yet implemented") def Tangent(self, X, sync = 1): print "Call Tangent OptimizerHooks" @@ -132,7 +141,7 @@ class OptimizerHooks: return Y else: print "sync false is not yet implemented" - raise daStudy.daError("sync == false not yet implemented") + self.optim_algo.setError("sync == false not yet implemented") def Adjoint(self, (X, Y), sync = 1): print "Call Adjoint OptimizerHooks" @@ -143,7 +152,7 @@ class OptimizerHooks: local_counter = self.sample_counter # 2: Put sample in the job pool - sample = self.create_sample(Y, "Tangent") + sample = self.create_sample((X,Y), "Adjoint") self.optim_algo.pool.pushInSample(local_counter, sample) # 3: Wait @@ -171,7 +180,7 @@ class OptimizerHooks: return Z else: print "sync false is not yet implemented" - raise daStudy.daError("sync == false not yet implemented") + self.optim_algo.setError("sync == false not yet implemented") class AssimilationAlgorithm_asynch(SALOMERuntime.OptimizerAlgASync): diff --git a/src/tests/daSalome/test017_3DVAR_function_script.py b/src/tests/daSalome/test017_3DVAR_function_script.py index ce55cca..09f2e4c 100644 --- a/src/tests/daSalome/test017_3DVAR_function_script.py +++ b/src/tests/daSalome/test017_3DVAR_function_script.py @@ -7,8 +7,6 @@ for param in computation["specificParameters"]: if param["name"] == "method": method = param["value"] print "Method found is", method -print computation["inputValues"] -print computation["inputValues"][0][0] dimension = 300 H = numpy.matrix(numpy.core.identity(dimension)) @@ -26,6 +24,6 @@ if method == "Tangent": result = FunctionH(numpy.matrix(computation["inputValues"][0][0]).T) if method == "Adjoint": - result = AdjointH(numpy.matrix(computation["inputValues"][0][0]).T) + result = AdjointH((numpy.matrix(computation["inputValues"][0][0]).T, numpy.matrix(computation["inputValues"][0][1]).T)) print "Computation end" -- 2.39.2