From 762abebd1e3694dcd973fbd035c4fb6ecbc0a9c9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9?= Date: Thu, 22 Apr 2010 15:51:37 +0200 Subject: [PATCH] Premier test ok ! --- resources/DATASSIMSchemaCatalog.xml | 12 ++++++++++ .../daYacsSchemaCreator/help_methods.py | 16 ++++++++++++++ src/daSalome/daYacsSchemaCreator/methods.py | 11 ++++++++++ src/tests/daSalome/test000_Blue.py | 22 +++++++++++++++++++ 4 files changed, 61 insertions(+) diff --git a/resources/DATASSIMSchemaCatalog.xml b/resources/DATASSIMSchemaCatalog.xml index 18077f5..44f5fc5 100644 --- a/resources/DATASSIMSchemaCatalog.xml +++ b/resources/DATASSIMSchemaCatalog.xml @@ -118,4 +118,16 @@ ADD.analyze() + + + + + diff --git a/src/daSalome/daYacsSchemaCreator/help_methods.py b/src/daSalome/daYacsSchemaCreator/help_methods.py index b61588b..9621af3 100644 --- a/src/daSalome/daYacsSchemaCreator/help_methods.py +++ b/src/daSalome/daYacsSchemaCreator/help_methods.py @@ -69,6 +69,22 @@ def check_study(study_config): if key in AssimData: check_data(key, study_config[key]) + # Analyse + if "Analysis" in study_config.keys(): + analysis_config = study_config["Analysis"] + if "From" not in analysis_config: + logging.fatal("Analysis found but From is not defined in the analysis configuration !") + sys.exit(1) + else: + if analysis_config["From"] != "string": + logging.fatal("Analysis From defined in the study configuration does not have a correct type : " + str(analysis_config["From"]) + + "\n You can have : string") + sys.exit(1) + if "Data" not in analysis_config: + logging.fatal("Analysis found but Data is not defined in the analysis configuration !") + sys.exit(1) + + def check_data(data_name, data_config): logging.debug("[check_data] " + data_name) diff --git a/src/daSalome/daYacsSchemaCreator/methods.py b/src/daSalome/daYacsSchemaCreator/methods.py index b07119f..5071ae0 100644 --- a/src/daSalome/daYacsSchemaCreator/methods.py +++ b/src/daSalome/daYacsSchemaCreator/methods.py @@ -104,6 +104,17 @@ def create_yacs_proc(study_config): proc.edAddDFLink(CAS_node.getOutputPort("Study"), execute_node.getInputPort("Study")) # Step 4: create post-processing from user configuration + if "Analysis" in study_config.keys(): + analysis_config = study_config["Analysis"] + if analysis_config["From"] == "string": + factory_analysis_node = catalogAd._nodeMap["SimpleUserAnalysis"] + analysis_node = factory_analysis_node.cloneNode("User Analysis") + default_script = analysis_node.getScript() + final_script = default_script + analysis_config["Data"] + analysis_node.setScript(final_script) + proc.edAddChild(analysis_node) + proc.edAddCFLink(compute_bloc, analysis_node) + proc.edAddDFLink(execute_node.getOutputPort("Study"), analysis_node.getInputPort("Study")) return proc diff --git a/src/tests/daSalome/test000_Blue.py b/src/tests/daSalome/test000_Blue.py index 1ad1721..0e994da 100644 --- a/src/tests/daSalome/test000_Blue.py +++ b/src/tests/daSalome/test000_Blue.py @@ -1,3 +1,4 @@ +#-*-coding:iso-8859-1-*- study_config = {} study_config["Name"] = "test000_Blue" study_config["Algorithm"] = "Blue" @@ -31,3 +32,24 @@ ObservationOperator_config["Data"] = "1 0 0;0 1 0;0 0 1" ObservationOperator_config["Type"] = "Matrix" ObservationOperator_config["From"] = "string" study_config["ObservationOperator"] = ObservationOperator_config + +Analysis_config = {} +Analysis_config["Data"] = """ +import numpy +precision = 1.e-13 + +Xa = ADD.get("Analysis") +print +print " Nombre d'analyses :",Xa.stepnumber() +print " Analyse résultante :",Xa.valueserie(0) +# +# Vérification du résultat +# ------------------------ +if max(numpy.array(Xa.valueserie(0))-numpy.array([0.25, 1.25, 2.25])) > precision: + raise ValueError("Résultat du test erroné") +else: + print " Test correct, erreur maximale inférieure à %s"%precision + print +""" +Analysis_config["From"] = "string" +study_config["Analysis"] = Analysis_config -- 2.39.2