From: Jean-Philippe ARGAUD Date: Wed, 3 Apr 2019 13:44:51 +0000 (+0200) Subject: Tests update for vector error identification X-Git-Tag: V9_3_0rc2~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4e49a4877e2f523dfc99e6e737d08842a228cc1b;p=modules%2Fadao.git Tests update for vector error identification --- diff --git a/bin/AdaoCatalogGenerator.py b/bin/AdaoCatalogGenerator.py index ef5d30d..153f5ef 100644 --- a/bin/AdaoCatalogGenerator.py +++ b/bin/AdaoCatalogGenerator.py @@ -125,6 +125,12 @@ def AdjointOperatorInNS(filename): if cr.match(ln): return 1 return 0 AdjointOperatorInNS.info = u"The Python file has to contain explicitly an \\"AdjointOperator\\" function definition with only one pair of vectors as argument." +def ColDataFileExtVal(filename): + __readable = (".csv", ".tsv", ".txt", ".npy", ".npz") + if os.path.exists(filename) and os.path.splitext(filename)[1] in __readable: + return 1 + return 0 +ColDataFileExtVal.info = u"The data file has to contain explicitly one or more number columns with separator, or one variable, that can fit in a unique continuous vector." """%(module_version.name,module_version.cata) # Important : validators=[...] pour que les conditions soient traitees simultanement, en "ET", et pas en "OU" (choisi dans le cas du tuple a la place de la liste) @@ -134,7 +140,7 @@ def F_{data_name}(statut, fv=NoCheckInNS) : return FACT( statut = statut, FROM = SIMP(statut = "o", typ = "TXM", into=({data_into}), defaut={data_default}), SCRIPT_DATA = BLOC ( condition = " FROM in ( 'Script', ) ", - SCRIPT_FILE = SIMP(statut = "o", typ = "FichierNoAbs", validators=[OnlyStr(), FileExtVal('py'), FunctionVal(fv)], fr="En attente d'un nom de fichier script, avec ou sans le chemin complet pour le trouver, contenant si nécessaire la définition d'une variable interne de même nom que le concept parent", ang="Waiting for a script file name, with or without the full path to find it, containing if necessary the definition of an internal variable of the same name as the parent concept"), + SCRIPT_FILE = SIMP(statut = "o", typ = ("FichierNoAbs",'Python Files (*.py)',), validators=[OnlyStr(), FileExtVal('py'), FunctionVal(fv)], fr="En attente d'un nom de fichier script, avec ou sans le chemin complet pour le trouver, contenant si nécessaire la définition d'une variable interne de même nom que le concept parent", ang="Waiting for a script file name, with or without the full path to find it, containing if necessary the definition of an internal variable of the same name as the parent concept"), ), STRING_DATA = BLOC ( condition = " FROM in ( 'String', ) ", 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"), diff --git a/src/daEficas/generator_adao.py b/src/daEficas/generator_adao.py index d0bc6a5..9b66d87 100644 --- a/src/daEficas/generator_adao.py +++ b/src/daEficas/generator_adao.py @@ -165,6 +165,8 @@ class AdaoGenerator(PythonGenerator): data = self.dictMCVal[search_type + "STRING_DATA__STRING"] elif from_type == "Script": data = self.dictMCVal[search_type + "SCRIPT_DATA__SCRIPT_FILE"] + elif from_type == "DataFile": + data = self.dictMCVal[search_type + "DATA_DATA__DATA_FILE"] elif from_type == "ScriptWithSwitch": data = self.dictMCVal[search_type + "SCRIPTWITHSWITCH_DATA__SCRIPTWITHSWITCH_FILE"] elif from_type == "ScriptWithFunctions": @@ -176,7 +178,7 @@ class AdaoGenerator(PythonGenerator): else: raise Exception('From Type unknown', from_type) - if from_type == "String" or from_type == "Script": + if from_type == "String" or from_type == "Script" or from_type == "DataFile": self.text_da += data_name + "_config = {}\n" self.text_da += data_name + "_config['Type'] = '" + data_type + "'\n" self.text_da += data_name + "_config['From'] = '" + from_type + "'\n" diff --git a/test/test6703/Doc_TUI_Exemple_03.py b/test/test6703/Doc_TUI_Exemple_03.py index 8db3f8e..4d70372 100644 --- a/test/test6703/Doc_TUI_Exemple_03.py +++ b/test/test6703/Doc_TUI_Exemple_03.py @@ -108,10 +108,10 @@ def assertAlmostEqualArrays(first, second, places=7, msg=None, delta=None): if msg is not None: print(msg) if delta is not None: - if ( (numpy.asarray(first) - numpy.asarray(second)) > float(delta) ).any(): + if ( numpy.abs(numpy.asarray(first) - numpy.asarray(second)) > float(delta) ).any(): raise AssertionError("%s != %s within %s places"%(first,second,delta)) else: - if ( (numpy.asarray(first) - numpy.asarray(second)) > 10**(-int(places)) ).any(): + if ( numpy.abs(numpy.asarray(first) - numpy.asarray(second)) > 10**(-int(places)) ).any(): raise AssertionError("%s != %s within %i places"%(first,second,places)) return max(abs(numpy.asarray(first) - numpy.asarray(second))) diff --git a/test/test6704/Doc_TUI_Exemple_03_en_multifonction.py b/test/test6704/Doc_TUI_Exemple_03_en_multifonction.py index 7b9e5f3..ddf12a8 100644 --- a/test/test6704/Doc_TUI_Exemple_03_en_multifonction.py +++ b/test/test6704/Doc_TUI_Exemple_03_en_multifonction.py @@ -115,10 +115,10 @@ def assertAlmostEqualArrays(first, second, places=7, msg=None, delta=None): if msg is not None: print(msg) if delta is not None: - if ( (numpy.asarray(first) - numpy.asarray(second)) > float(delta) ).any(): + if ( numpy.abs(numpy.asarray(first) - numpy.asarray(second)) > float(delta) ).any(): raise AssertionError("%s != %s within %s places"%(first,second,delta)) else: - if ( (numpy.asarray(first) - numpy.asarray(second)) > 10**(-int(places)) ).any(): + if ( numpy.abs(numpy.asarray(first) - numpy.asarray(second)) > 10**(-int(places)) ).any(): raise AssertionError("%s != %s within %i places"%(first,second,places)) return max(abs(numpy.asarray(first) - numpy.asarray(second))) diff --git a/test/test6711/Doc_TUI_Exemple_01_Savings.py b/test/test6711/Doc_TUI_Exemple_01_Savings.py index b5ef7a7..839b538 100644 --- a/test/test6711/Doc_TUI_Exemple_01_Savings.py +++ b/test/test6711/Doc_TUI_Exemple_01_Savings.py @@ -87,10 +87,10 @@ def assertAlmostEqualArrays(first, second, places=7, msg=None, delta=None): if msg is not None: print(msg) if delta is not None: - if ( (numpy.asarray(first) - numpy.asarray(second)) > float(delta) ).any(): + if ( numpy.abs(numpy.asarray(first) - numpy.asarray(second)) > float(delta) ).any(): raise AssertionError("%s != %s within %s places"%(first,second,delta)) else: - if ( (numpy.asarray(first) - numpy.asarray(second)) > 10**(-int(places)) ).any(): + if ( numpy.abs(numpy.asarray(first) - numpy.asarray(second)) > 10**(-int(places)) ).any(): raise AssertionError("%s != %s within %i places"%(first,second,places)) return max(abs(numpy.asarray(first) - numpy.asarray(second))) diff --git a/test/test6904/Definition_complete_de_cas_3DVAR.py b/test/test6904/Definition_complete_de_cas_3DVAR.py index 35d3135..67cbfac 100644 --- a/test/test6904/Definition_complete_de_cas_3DVAR.py +++ b/test/test6904/Definition_complete_de_cas_3DVAR.py @@ -143,8 +143,8 @@ class InTest(unittest.TestCase): # ---------- ecart = assertAlmostEqualArrays(Xoptimum, [ 2., 3., 4.]) # - print(" The maximal absolute error in the test is of %.2e."%ecart) - print(" The results are correct.") + print("The maximal absolute error in the test is of %.2e."%ecart) + print("The results are correct.") print("") # return Xoptimum @@ -156,10 +156,10 @@ def assertAlmostEqualArrays(first, second, places=7, msg=None, delta=None): if msg is not None: print(msg) if delta is not None: - if ( (numpy.asarray(first) - numpy.asarray(second)) > float(delta) ).any(): + if ( numpy.abs(numpy.asarray(first) - numpy.asarray(second)) > float(delta) ).any(): raise AssertionError("%s != %s within %s places"%(first,second,delta)) else: - if ( (numpy.asarray(first) - numpy.asarray(second)) > 10**(-int(places)) ).any(): + if ( numpy.abs(numpy.asarray(first) - numpy.asarray(second)) > 10**(-int(places)) ).any(): raise AssertionError("%s != %s within %i places"%(first,second,places)) return max(abs(numpy.asarray(first) - numpy.asarray(second))) diff --git a/test/test6904/Definition_complete_de_cas_Blue.py b/test/test6904/Definition_complete_de_cas_Blue.py index 43c96da..dad2cbc 100644 --- a/test/test6904/Definition_complete_de_cas_Blue.py +++ b/test/test6904/Definition_complete_de_cas_Blue.py @@ -153,10 +153,10 @@ def assertAlmostEqualArrays(first, second, places=7, msg=None, delta=None): if msg is not None: print(msg) if delta is not None: - if ( (numpy.asarray(first) - numpy.asarray(second)) > float(delta) ).any(): + if ( numpy.abs(numpy.asarray(first) - numpy.asarray(second)) > float(delta) ).any(): raise AssertionError("%s != %s within %s places"%(first,second,delta)) else: - if ( (numpy.asarray(first) - numpy.asarray(second)) > 10**(-int(places)) ).any(): + if ( numpy.abs(numpy.asarray(first) - numpy.asarray(second)) > 10**(-int(places)) ).any(): raise AssertionError("%s != %s within %i places"%(first,second,places)) return max(abs(numpy.asarray(first) - numpy.asarray(second))) diff --git a/test/test6904/Definition_complete_de_cas_NLLS.py b/test/test6904/Definition_complete_de_cas_NLLS.py index 033e355..ab0e44f 100644 --- a/test/test6904/Definition_complete_de_cas_NLLS.py +++ b/test/test6904/Definition_complete_de_cas_NLLS.py @@ -151,10 +151,10 @@ def assertAlmostEqualArrays(first, second, places=7, msg=None, delta=None): if msg is not None: print(msg) if delta is not None: - if ( (numpy.asarray(first) - numpy.asarray(second)) > float(delta) ).any(): + if ( numpy.abs(numpy.asarray(first) - numpy.asarray(second)) > float(delta) ).any(): raise AssertionError("%s != %s within %s places"%(first,second,delta)) else: - if ( (numpy.asarray(first) - numpy.asarray(second)) > 10**(-int(places)) ).any(): + if ( numpy.abs(numpy.asarray(first) - numpy.asarray(second)) > 10**(-int(places)) ).any(): raise AssertionError("%s != %s within %i places"%(first,second,places)) return max(abs(numpy.asarray(first) - numpy.asarray(second)))