From a250cdf7a1e606a3b95862df79990de887c8e4c8 Mon Sep 17 00:00:00 2001 From: Jean-Philippe ARGAUD Date: Sun, 14 Dec 2014 09:02:12 +0100 Subject: [PATCH] Improving matrix default behaviour for user --- bin/AdaoCatalogGenerator.py | 20 ++++++++++++++----- .../daNumerics/ApproximatedDerivatives.py | 2 +- .../daYacsSchemaCreator/infos_daComposant.py | 9 ++++++--- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/bin/AdaoCatalogGenerator.py b/bin/AdaoCatalogGenerator.py index b7ff1ce..fd6fd45 100644 --- a/bin/AdaoCatalogGenerator.py +++ b/bin/AdaoCatalogGenerator.py @@ -54,7 +54,7 @@ def F_${data_name}(statut) : return FACT(statut = statut, ), STRING_DATA = BLOC ( condition = " FROM in ( 'String', ) ", - STRING = SIMP(statut = "o", typ = "TXM", fr="En attente d'une chaine de caractères entre guillements. Pour construire un vecteur ou une matrice, ce doit être une suite de nombres, utilisant un espace ou une virgule pour séparer deux éléments et un point-virgule pour séparer deux lignes", ang="Waiting for a string in quotes. To build a vector or a matrix, it has to be a float serie, using a space or comma to separate two elements in a line, a semi-colon to separate rows"), + STRING = SIMP(statut = "o", typ = "TXM", ${ms_default} fr="En attente d'une chaine de caractères entre guillements. Pour construire un vecteur ou une matrice, ce doit être une suite de nombres, utilisant un espace ou une virgule pour séparer deux éléments et un point-virgule pour séparer deux lignes", ang="Waiting for a string in quotes. To build a vector or a matrix, it has to be a float serie, using a space or comma to separate two elements in a line, a semi-colon to separate rows"), ), SCRIPTWITHFUNCTIONS_DATA = BLOC ( condition = " FROM in ( 'ScriptWithFunctions', ) ", @@ -278,6 +278,7 @@ for data_input_name in infos.DataTypeDict.keys(): data_name = data_input_name data_into = "" data_default = "" + ms_default = "" # On recupere les differentes facon d'entrer les donnees for basic_type in infos.DataTypeDict[data_input_name]: @@ -285,10 +286,13 @@ for data_input_name in infos.DataTypeDict.keys(): # On choisit le default data_default = "\"" + infos.DataTypeDefaultDict[data_input_name] + "\"" + if infos.DataSValueDefaultDict.has_key(data_input_name): + ms_default = "defaut=\"" + infos.DataSValueDefaultDict[data_input_name] + "\"," mem_file.write(data_method.substitute(data_name = data_name, data_into = data_into, - data_default = data_default)) + data_default = data_default, + ms_default = ms_default)) # Step 2: On cree les fonctions qui permettent de rentrer les donnees des algorithmes for assim_data_input_name in infos.AssimDataDict.keys(): @@ -320,14 +324,20 @@ for opt_name in infos.OptDict.keys(): data_name = opt_name data_into = "" data_default = "" + ms_default = "" for choice in infos.OptDict[opt_name]: data_into += "\"" + choice + "\", " + + # On choisit le default data_default = "\"" + infos.OptDefaultDict[opt_name] + "\"" + if infos.DataSValueDefaultDict.has_key(opt_name): + ms_default = "defaut=\"" + infos.DataSValueDefaultDict[opt_name] + "\"," - mem_file.write(data_method.substitute(data_name = data_name, - data_into = data_into, - data_default = data_default)) + mem_file.write(data_method.substitute(data_name = data_name, + data_into = data_into, + data_default = data_default, + ms_default = ms_default)) # Step 4: On ajoute la methode optionnelle init # TODO uniformiser avec le step 3 diff --git a/src/daComposant/daNumerics/ApproximatedDerivatives.py b/src/daComposant/daNumerics/ApproximatedDerivatives.py index 35a38a6..56b08df 100644 --- a/src/daComposant/daNumerics/ApproximatedDerivatives.py +++ b/src/daComposant/daNumerics/ApproximatedDerivatives.py @@ -184,7 +184,7 @@ class FDApproximation(object): logging.debug("FDA Approximation centrée...: %s"%(self.__centeredDF)) # if X is None or len(X)==0: - raise ValueError("Nominal point X for approximate derivatives can not be None or void.") + raise ValueError("Nominal point X for approximate derivatives can not be None or void (X=%s)."%(str(X),)) # _X = numpy.asmatrix(numpy.ravel( X )).T # diff --git a/src/daSalome/daYacsSchemaCreator/infos_daComposant.py b/src/daSalome/daYacsSchemaCreator/infos_daComposant.py index 1840081..b892573 100644 --- a/src/daSalome/daYacsSchemaCreator/infos_daComposant.py +++ b/src/daSalome/daYacsSchemaCreator/infos_daComposant.py @@ -202,6 +202,9 @@ DataTypeDefaultDict["DiagonalSparseMatrix"] = "String" DataTypeDefaultDict["Function"] = "ScriptWithOneFunction" DataTypeDefaultDict["Dict"] = "Script" +DataSValueDefaultDict = {} +DataSValueDefaultDict["ScalarSparseMatrix"] = "1." + # Assimilation data input AssimDataDict = {} AssimDataDict["Background"] = ["Vector", "VectorSerie"] @@ -218,12 +221,12 @@ AssimDataDict["ControlInput"] = ["Vector", "VectorSerie"] AssimDataDefaultDict = {} AssimDataDefaultDict["Background"] = "Vector" -AssimDataDefaultDict["BackgroundError"] = "Matrix" +AssimDataDefaultDict["BackgroundError"] = "ScalarSparseMatrix" AssimDataDefaultDict["Observation"] = "Vector" -AssimDataDefaultDict["ObservationError"] = "Matrix" +AssimDataDefaultDict["ObservationError"] = "ScalarSparseMatrix" AssimDataDefaultDict["ObservationOperator"] = "Function" AssimDataDefaultDict["EvolutionModel"] = "Function" -AssimDataDefaultDict["EvolutionError"] = "Matrix" +AssimDataDefaultDict["EvolutionError"] = "ScalarSparseMatrix" AssimDataDefaultDict["AlgorithmParameters"] = "Dict" AssimDataDefaultDict["UserDataInit"] = "Dict" AssimDataDefaultDict["CheckingPoint"] = "Vector" -- 2.39.2