From: Jean-Philippe ARGAUD Date: Sun, 30 Sep 2012 19:34:12 +0000 (+0200) Subject: Improving independance and test for internal variables X-Git-Tag: V6_6_0~23 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=12cd17d02353c3bd81b1677e485931d386cc28b2;p=modules%2Fadao.git Improving independance and test for internal variables --- diff --git a/src/daSalome/daYacsSchemaCreator/methods.py b/src/daSalome/daYacsSchemaCreator/methods.py index 688f9a6..f686caf 100644 --- a/src/daSalome/daYacsSchemaCreator/methods.py +++ b/src/daSalome/daYacsSchemaCreator/methods.py @@ -483,43 +483,46 @@ def create_yacs_proc(study_config): node_script += """# ==============================================\n""" node_script += script_str.read() node_script += """# ==============================================\n""" + node_script += """__method = None\n""" node_script += """for param in computation["specificParameters"]:\n""" - node_script += """ if param["name"] == "method": method = param["value"]\n""" - node_script += """ else: method = ""\n""" - node_script += """logging.info("ComputationFunctionNode: Found method is \'%s\'"%method)\n""" + node_script += """ if param["name"] == "method": __method = param["value"]\n""" + node_script += """if __method not in ["Direct", "Tangent", "Adjoint"]:\n""" + node_script += """ raise ValueError("ComputationFunctionNode: no valid computation method is given, it has to be Direct, Tangent or Adjoint (\'%s\' given)."%__method)\n""" + node_script += """logging.debug("ComputationFunctionNode: Found method is \'%s\'"%__method)\n""" node_script += """#\n""" node_script += """#\n""" - node_script += """if method == "Direct":\n""" + node_script += """__data = []\n""" + node_script += """if __method == "Direct":\n""" node_script += """ try:\n""" node_script += """ DirectOperator\n""" node_script += """ except NameError:\n""" node_script += """ raise ValueError("ComputationFunctionNode: DirectOperator not found in the imported user script file")\n""" - node_script += """ logging.info("ComputationFunctionNode: Direct computation")\n""" - node_script += """ Xcurrent = computation["inputValues"][0][0][0]\n""" - node_script += """ data = DirectOperator(numpy.matrix( Xcurrent ).T)\n""" + node_script += """ logging.debug("ComputationFunctionNode: Direct computation")\n""" + node_script += """ __Xcurrent = computation["inputValues"][0][0][0]\n""" + node_script += """ __data = DirectOperator(numpy.matrix( __Xcurrent ).T)\n""" node_script += """#\n""" - node_script += """if method == "Tangent":\n""" + node_script += """if __method == "Tangent":\n""" node_script += """ try:\n""" node_script += """ TangentOperator\n""" node_script += """ except NameError:\n""" node_script += """ raise ValueError("ComputationFunctionNode: TangentOperator not found in the imported user script file")\n""" - node_script += """ logging.info("ComputationFunctionNode: Tangent computation")\n""" - node_script += """ Xcurrent = computation["inputValues"][0][0][0]\n""" - node_script += """ dXcurrent = computation["inputValues"][0][0][1]\n""" - node_script += """ data = TangentOperator((numpy.matrix( Xcurrent ).T, numpy.matrix( dXcurrent ).T))\n""" + node_script += """ logging.debug("ComputationFunctionNode: Tangent computation")\n""" + node_script += """ __Xcurrent = computation["inputValues"][0][0][0]\n""" + node_script += """ __dXcurrent = computation["inputValues"][0][0][1]\n""" + node_script += """ __data = TangentOperator((numpy.matrix( __Xcurrent ).T, numpy.matrix( __dXcurrent ).T))\n""" node_script += """#\n""" - node_script += """if method == "Adjoint":\n""" + node_script += """if __method == "Adjoint":\n""" node_script += """ try:\n""" node_script += """ AdjointOperator\n""" node_script += """ except NameError:\n""" node_script += """ raise ValueError("ComputationFunctionNode: AdjointOperator not found in the imported user script file")\n""" - node_script += """ logging.info("ComputationFunctionNode: Adjoint computation")\n""" - node_script += """ Xcurrent = computation["inputValues"][0][0][0]\n""" - node_script += """ Ycurrent = computation["inputValues"][0][0][1]\n""" - node_script += """ data = AdjointOperator((numpy.matrix( Xcurrent ).T, numpy.matrix( Ycurrent ).T))\n""" + node_script += """ logging.debug("ComputationFunctionNode: Adjoint computation")\n""" + node_script += """ __Xcurrent = computation["inputValues"][0][0][0]\n""" + node_script += """ __Ycurrent = computation["inputValues"][0][0][1]\n""" + node_script += """ __data = AdjointOperator((numpy.matrix( __Xcurrent ).T, numpy.matrix( __Ycurrent ).T))\n""" node_script += """#\n""" - node_script += """logging.info("ComputationFunctionNode: Formatting the output")\n""" - node_script += """it = data.flat\n""" + node_script += """logging.debug("ComputationFunctionNode: Formatting the output")\n""" + node_script += """it = numpy.ravel(__data)\n""" node_script += """outputValues = [[[[]]]]\n""" node_script += """for val in it:\n""" node_script += """ outputValues[0][0][0].append(val)\n""" @@ -633,43 +636,46 @@ def create_yacs_proc(study_config): node_script += " sys.path.insert(0,filepath)\n" node_script += script_str.read() node_script += """# ==============================================\n""" + node_script += """__method = None\n""" node_script += """for param in computation["specificParameters"]:\n""" - node_script += """ if param["name"] == "method": method = param["value"]\n""" - node_script += """ else: method = ""\n""" - node_script += """logging.info("ComputationFunctionNode: Found method is \'%s\'"%method)\n""" + node_script += """ if param["name"] == "method": __method = param["value"]\n""" + node_script += """if __method not in ["Direct", "Tangent", "Adjoint"]:\n""" + node_script += """ raise ValueError("ComputationFunctionNode: no valid computation method is given, it has to be Direct, Tangent or Adjoint (\'%s\' given)."%__method)\n""" + node_script += """logging.debug("ComputationFunctionNode: Found method is \'%s\'"%__method)\n""" node_script += """#\n""" node_script += """#\n""" - node_script += """if method == "Direct":\n""" + node_script += """__data = []\n""" + node_script += """if __method == "Direct":\n""" node_script += """ try:\n""" node_script += """ DirectOperator\n""" node_script += """ except NameError:\n""" node_script += """ raise ValueError("ComputationFunctionNode: mandatory DirectOperator not found in the imported user script file")\n""" - node_script += """ logging.info("ComputationFunctionNode: Direct computation")\n""" - node_script += """ Xcurrent = computation["inputValues"][0][0][0]\n""" - node_script += """ data = DirectOperator(numpy.matrix( Xcurrent ).T)\n""" + node_script += """ logging.debug("ComputationFunctionNode: Direct computation")\n""" + node_script += """ __Xcurrent = computation["inputValues"][0][0][0]\n""" + node_script += """ __data = DirectOperator(numpy.matrix( __Xcurrent ).T)\n""" node_script += """#\n""" - node_script += """if method == "Tangent":\n""" + node_script += """if __method == "Tangent":\n""" node_script += """ try:\n""" node_script += """ TangentOperator\n""" node_script += """ except NameError:\n""" node_script += """ raise ValueError("ComputationFunctionNode: mandatory TangentOperator not found in the imported user script file")\n""" - node_script += """ logging.info("ComputationFunctionNode: Tangent computation")\n""" - node_script += """ Xcurrent = computation["inputValues"][0][0][0]\n""" - node_script += """ dXcurrent = computation["inputValues"][0][0][1]\n""" - node_script += """ data = TangentOperator((numpy.matrix( Xcurrent ).T, numpy.matrix( dXcurrent ).T))\n""" + node_script += """ logging.debug("ComputationFunctionNode: Tangent computation")\n""" + node_script += """ __Xcurrent = computation["inputValues"][0][0][0]\n""" + node_script += """ __dXcurrent = computation["inputValues"][0][0][1]\n""" + node_script += """ __data = TangentOperator((numpy.matrix( __Xcurrent ).T, numpy.matrix( __dXcurrent ).T))\n""" node_script += """#\n""" - node_script += """if method == "Adjoint":\n""" + node_script += """if __method == "Adjoint":\n""" node_script += """ try:\n""" node_script += """ AdjointOperator\n""" node_script += """ except NameError:\n""" node_script += """ raise ValueError("ComputationFunctionNode: mandatory AdjointOperator not found in the imported user script file")\n""" - node_script += """ logging.info("ComputationFunctionNode: Adjoint computation")\n""" - node_script += """ Xcurrent = computation["inputValues"][0][0][0]\n""" - node_script += """ Ycurrent = computation["inputValues"][0][0][1]\n""" - node_script += """ data = AdjointOperator((numpy.matrix( Xcurrent ).T, numpy.matrix( Ycurrent ).T))\n""" + node_script += """ logging.debug("ComputationFunctionNode: Adjoint computation")\n""" + node_script += """ __Xcurrent = computation["inputValues"][0][0][0]\n""" + node_script += """ __Ycurrent = computation["inputValues"][0][0][1]\n""" + node_script += """ __data = AdjointOperator((numpy.matrix( __Xcurrent ).T, numpy.matrix( __Ycurrent ).T))\n""" node_script += """#\n""" - node_script += """logging.info("ComputationFunctionNode: Formatting the output")\n""" - node_script += """it = data.flat\n""" + node_script += """logging.debug("ComputationFunctionNode: Formatting the output")\n""" + node_script += """it = numpy.ravel(__data)\n""" node_script += """outputValues = [[[[]]]]\n""" node_script += """for val in it:\n""" node_script += """ outputValues[0][0][0].append(val)\n"""